module documentation

Functionality for communicating the required user interface for a thing.

Class Accordion The data required for creating an accordion in the UI.
Class ActionButton The data required for creating an actionButton in Vue.
Class BulletBlock The data required for creating a block text.
Class Container The data required for creating <div> in the UI.
Class HeaderBlock The data required for header.
Class PropertyControl The data required for creating an actionButton in Vue.
Class SafeHTMLParser An HTMLParser that only allows a very limited subset of HTML.
Class TextBlock The data required for creating a block text.
Class UIElementList A list of user interface elements.
Function action_button_for Create a ActionButton data for the specified Thing Action.
Function property_control_for Create an PropertyControl data for the specified Thing Property.
Function sanitise_html Santitise HTML to only have a small list of allowed tags.
Function sanitize_http_url Santitise any url only allowing http and https without queries.
Function strip_control_chars Remove unprintable characters.
Constant ALLOWED_SCHEMES Undocumented
Constant ALLOWED_TAGS Undocumented
Constant UI_ELEMENT_RESPONSE Undocumented
Variable HtmlFragment Undocumented
Variable UIElementModels Undocumented
def action_button_for(thing: lt.Thing, action_name: str, **kwargs: Any) -> ActionButton: (source)

Create a ActionButton data for the specified Thing Action.

Parameters
thing:lt.ThingThe instance of the thing that has the action.
action_name:strThe name of the action to create a button for.
**kwargs:AnyAny attribute of ActionButton except for thing or action.
Returns
ActionButtonAn ActionButton (Pydantic Model) object with all the information the webapp needs to create the action button.
def property_control_for(thing: lt.Thing, property_name: str, **kwargs: Any) -> PropertyControl: (source)

Create an PropertyControl data for the specified Thing Property.

Parameters
thing:lt.ThingThe instance of the thing that has the property to be controlled.
property_name:strThe name of the property to create a control for.
**kwargs:AnyAny attribute of PropertyControl except for thing or property_name. If label is not set here it will be the property name.
Returns
PropertyControlUndocumented
def sanitise_html(html: str) -> str: (source)

Santitise HTML to only have a small list of allowed tags.

Tags allowed without attrs: <i>, <b>,

Tags allowed with attrs: <a> is allowed with href only. This automatically appends target="_blank" rel="noopener noreferrer" so the link opens externally.

Self closing tags allowed <br>.

Parameters
html:strThe input HTML.
Returns
strThe sanitised HTML.
def sanitize_http_url(url: str) -> str | None: (source)

Santitise any url only allowing http and https without queries.

def strip_control_chars(input_string: str) -> str: (source)

Remove unprintable characters.

ALLOWED_SCHEMES: set[str] = (source)

Undocumented

Value
set(['http', 'https'])
ALLOWED_TAGS: set[str] = (source)

Undocumented

Value
set(['i', 'b', 'a'])
UI_ELEMENT_RESPONSE = (source)

Undocumented

Value
{200: {'description': 'A list of UI element specifications.',
       'model': UIElementList}}
HtmlFragment = (source)

Undocumented

UIElementModels = (source)

Undocumented