Pages and cards
m.screen
One page of the machine, drawn by your Ownbox.
m.screen(path, *, owner_only=False, title=None)@m.screen(m.home, title="Quotes")
def quotes_page(query, person):
return {"v": 1, "title": "Quotes", "blocks": [
{"kind": "figures", "items": [{"value": 2, "label": "waiting"}]},
{"kind": "actions", "items": [{"run": "check_quotes", "label": "Check now"}]}]}At m.home or under it. The function answers with screen.json, a dict of blocks your Ownbox draws in its own look (text, figures, list, table, actions and settings), or with sdk.page(...). It may take query, person ({"id", "role"}) and path, by name. owner_only=True makes a page only the owner opens. A custom machine's page is only read: no JavaScript, no image, no form of its own. Its one form is a settings block, saved by your Ownbox. Use it as a decorator.
- Needs in machine.yaml
- Nothing
m.panel("inbox", title="Quotes waiting",
render=lambda: {"v": 1, "title": "Quotes waiting", "blocks": [{"kind": "text", "text": "Two."}]})In slot. render() answers with screen.json of at most 6 blocks and no settings, or sdk.page(...)'s body; it may take person by name. A card is drawn for anyone signed in: check person["role"] for what only the owner should see. Today the Inbox's screen offers the slot inbox.
- Needs in machine.yaml
- Nothing
url = m.link(m.home + "/quotes")Only for a page under m.home; anything else raises ValueError.
- Needs in machine.yaml
- Nothing
- Returns
https://<the Ownbox>/my/....
sdk.page
A page as HTML, for a machine written before screen.json.
sdk.page(path, *, title, lede='', body)page = sdk.page(m.home, title="Quotes", body="<p>Two quotes are waiting.</p>")title and lede are plain words; body is HTML your Ownbox cuts to its allowlist: no script, style, form or image, every attribute but class, colspan and rowspan dropped, and links only to the machine's own pages. A machine written now answers with screen.json instead.
- Returns
- A page for
m.screento return.