Skip to content
Peter edited this page Sep 28, 2024 · 6 revisions

RTML is my equivalent to HTML and used as the standard form web-pages sent over the PeterOS networking system.

Overview

Unlike HTML, RTML does not currently support element hierarchy, all elements are processed in the order simply they are provided.

Example RTML:

{
    { 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" }
}

Elements

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

Element types

TEXT

Simple text only element with no interaction


LINK

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"

DOM-LINK

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"

INPUT

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

BUTTON

A clickable button. When pushed sends a RTTP message to the current URL

  • action: 'SUBMIT'|'PUSH' - Action to perform when the button is pressed

SUBMIT

Sends contents of form elements.

Message body:

{
    type = 'BUTTON_SUBMIT',
    vals: {
        ['name']: 'value'
    }
}

PUSH

Sends the ID of the button that was pushed.

Message body:

{
    type = 'BUTTON_PUSH',
    id = 'button_id'
}

LUA object

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-XML file

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

Tags

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 to 1.
  • If the y attribute is omitted, its defaulted to the line after the lowest element before it in the file or 1 if it is the first element.

<RTML>

File header tag. Includes RTML-XML version and metadata

  • version: number - RTML-XML version number. Current version is 1

<body>

Body tag. All page elements must be inside this tag.


<text>

Equivalent to TEXT element type. Text of the element is placed between the opening and closing tags


<link>

Equivalent to LINK element type. Text of the element is placed between the opening and closing tags


<dom-link>

Equivalent to DOM-LINK element type. Text of the element is placed between the opening and closing tags


<input/>

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 />)


<button>

Equivalent to BUTTON element type. Text of the element is placed between the opening and closing tags


Clone this wiki locally