-
Notifications
You must be signed in to change notification settings - Fork 0
RTML
RTML is my equivalent to HTML and used as the standard form web-pages sent over the PeterOS networking system.
Unlike HTML, RTML does not currently support element hierarchy, all elements are processed in the order simply they are provided.
{
{ type="TEXT", x=1, y=1, text="City Bank" },
{ type="LINK", x=1, y=2, text="About", href="/about" },
{ type="LINK", x=7, y=2, text="Login", href="/login" },
{ type="LINK", x=13, y=2, text="Exchange", href="/exch" }
}
All elements have some common attributes:
-
type: string
- The type code of the element -
x: integer
,y: integer
- Position of the element -
text: string
- The text to display in the element -
color: nil|integer|string
- Text color (Optional) -
bgColor: nil|integer|string
- Background color (Optional) -
id: string
- Element unique ID
Some elements are Form Elements and also use the following attributes:
-
name: string
- The name of the element when the form is submitted
Simple text only element with no interaction
Simple link element. text
is the visible text, and href
is the link.
-
href: string
- Destination of the link (path only) ie."/account/password"
or"page"
Link element that can redirect to a full URL rather than just path
-
href: string
- Full URL including domain (method is still optional) ie."abc.com/home"
Text input field. (Form Element)
-
len: number
- Length (in characters) of the input -
hide: boolean?
- If the text in the input should be hidden and replaced with*
s -
next: string?
- Name of the next element to focus when cycled. If not present, will auto-focus next input provided
A clickable button. When pushed sends a RTTP message to the current URL
-
action: 'SUBMIT'|'PUSH'
- Action to perform when the button is pressed
Sends contents of form elements.
Message body:
{
type = 'BUTTON_SUBMIT',
vals: {
['name']: 'value'
}
}
Sends the ID of the button that was pushed.
Message body:
{
type = 'BUTTON_PUSH',
id = 'button_id'
}
When sent over the network RTML is sent as a LUA object formatted like the example in the overview. Some servers also support loading RTML as LUA object files.
RTML can also be stored in an HTML like file using XML.
The net.rtml.rtmlLoader
library provides functions for loading and parsing the RTML-XML
Example file:
<?xml version="1.0" encoding="UTF-8"?>
<RTML version="1">
<body>
<text x="1" y="1" >
Some text here
</text>
<link x="1" y="1" href="link" >
Link text
</link>
<dom-link x="1" y="1" href="abc.com/page" >
Link text
</dom-link>
<input x="1" y="1" len="5" hide="false" name="input-name" next="input2" />
<button x="1" y="1" action="SUBMIT" >
Button text
</button>
</body>
</RTML>
And XSD schema can be found at https://github.com/Platratio34/peterOS/tree/v1.8/os/net/rtml/rtml.xsd
All tags that are equivalent to RTML elements have the same attributes as their associated tag EXCEPT the type
attribute.
In addition, the some attributes have special behavior if omitted
- If the
x
attribute is omitted, its defaulted to1
. - If the
y
attribute is omitted, its defaulted to the line after the lowest element before it in the file or1
if it is the first element.
File header tag. Includes RTML-XML version and metadata
-
version: number
- RTML-XML version number. Current version is1
Body tag. All page elements must be inside this tag.
Equivalent to TEXT
element type.
Text of the element is placed between the opening and closing tags
Equivalent to LINK
element type.
Text of the element is placed between the opening and closing tags
Equivalent to DOM-LINK
element type.
Text of the element is placed between the opening and closing tags
Equivalent to BUTTON
element type.
Text of the element is placed between the opening and closing tags
Input tags must be self closing (ie. <input />
)
Equivalent to BUTTON
element type.
Text of the element is placed between the opening and closing tags