--- title: ext/web/web description: Official web site classes (English). Tables + methods; no bag glue. import plugin:lib/plugin.mq.md import sys:lib/sys.mq.md import table:lib/table.mq.md --- ## ensure_plugin Load the ABI v2 `web` plugin once. *p = > plugin.native_path name="web"* 1. `p` > plugin.load path=`p` 2. * > print text=ext/web: native web plugin not found (build marqdo_plugin_web or marqdo ext add web) > sys.exit code=1 **** ## make_style + `name`="" + `table` + `strict`=False Assemble a GFM style table into a CSS string. Two shapes are accepted: `|选择器|属性|值|` rule rows (arbitrary selectors; rows sharing a selector are merged, and a leading `|媒体|` column groups rows into `@media` blocks), or `|属性|值|` property rows wrapped as `.name { … }`. Selectors starting with `@keyframes name` emit keyframe blocks (`属性` = stop `from`/`to`/`N%`, `值` = `prop: val` or use `@keyframes name from` + normal 属性/值). Quote CSS values that contain `/` (e.g. `"16/9"`, `"1 / 5"`); bare `1 / 5` is integer division and becomes a numeric cell — default mode warns, `strict=True` errors. For complex themes prefer `page.css` (raw string, no table eval) or an external `static/*.css` via `page.head`. Styles stay as data tables, `make_style` turns them into CSS — 样式即数据、装配即函数. > ensure_plugin **> web_style name=`name` table=`table` strict=`strict`** ## make_images + `table` Assemble a GFM image table into an HTML fragment (`div.mq-images` of `
` / ``). Columns: `src`/`alt`/`title`/`class`/ `href`/`width`/`height`/`loading`/`caption` (ZH: `源`/`替代`/`标题`/`类`/ `链接`/`宽度`/`高度`/`加载`/`图注`). Images stay as data — 图片即数据、装配即函数. > ensure_plugin **> web_images table=`table`** ## make_head + `table` Assemble a Head resource table into HTML (`` / `"** 2. * **""** 2. * **""** ## text_patch + `sel` + `text` Shortcut: build a `set_text` effects map `{ set_text: { sel: text } }` for browser return values. Prefer authoring with `lib/browser` + GFM tables in client `.mq.md` ([marqdo-dev](../../.cursor/skills/marqdo-dev/SKILL.md)). *`m` = > table.put in=None at=sel value=text* **> table.put in=None at="set_text" value=m** ## dom_patch + `set_text`=None + `set_value`=None + `set_attr`=None + `set_class`=None + `toggle_class`=None + `set_style`=None + `set_html`=None + `render_list`=None + `navigate`=None + `storage`=None + `ws`=None + `fetch`=None + `fetch_all`=None + `after`=None + `interval`=None + `clear_interval`=None + `focus`=None + `blur`=None + `scroll_into`=None + `canvas`=None + `audio`=None + `read_file`=None + `observe`=None + `unobserve`=None + `wire`=None Merge browser effect keys into one return map (omit `None`). Route E/F effects included. *`out` = > table.put in=None at="_mq" value=True* 1. `set_text` != None *`out` = > table.put in=`out` at="set_text" value=set_text* 1. `set_value` != None *`out` = > table.put in=`out` at="set_value" value=set_value* 1. `set_attr` != None *`out` = > table.put in=`out` at="set_attr" value=set_attr* 1. `set_class` != None *`out` = > table.put in=`out` at="set_class" value=set_class* 1. `toggle_class` != None *`out` = > table.put in=`out` at="toggle_class" value=toggle_class* 1. `set_style` != None *`out` = > table.put in=`out` at="set_style" value=set_style* 1. `set_html` != None *`out` = > table.put in=`out` at="set_html" value=set_html* 1. `render_list` != None *`out` = > table.put in=`out` at="render_list" value=render_list* 1. `navigate` != None *`out` = > table.put in=`out` at="navigate" value=navigate* 1. `storage` != None *`out` = > table.put in=`out` at="storage" value=storage* 1. `ws` != None *`out` = > table.put in=`out` at="ws" value=ws* 1. `fetch` != None *`out` = > table.put in=`out` at="fetch" value=fetch* 1. `fetch_all` != None *`out` = > table.put in=`out` at="fetch_all" value=fetch_all* 1. `after` != None *`out` = > table.put in=`out` at="after" value=after* 1. `interval` != None *`out` = > table.put in=`out` at="interval" value=interval* 1. `clear_interval` != None *`out` = > table.put in=`out` at="clear_interval" value=clear_interval* 1. `focus` != None *`out` = > table.put in=`out` at="focus" value=focus* 1. `blur` != None *`out` = > table.put in=`out` at="blur" value=blur* 1. `scroll_into` != None *`out` = > table.put in=`out` at="scroll_into" value=scroll_into* 1. `canvas` != None *`out` = > table.put in=`out` at="canvas" value=canvas* 1. `audio` != None *`out` = > table.put in=`out` at="audio" value=audio* 1. `read_file` != None *`out` = > table.put in=`out` at="read_file" value=read_file* 1. `observe` != None *`out` = > table.put in=`out` at="observe" value=observe* 1. `unobserve` != None *`out` = > table.put in=`out` at="unobserve" value=unobserve* 1. `wire` != None *`out` = > table.put in=`out` at="wire" value=wire* **out** ## list_html + `sel` + `tag`="li" + `items` Build a `render_list` effect: `{ render_list: { sel: { tag, items } } }`. *`spec` = > table.put in=None at="tag" value=tag* *`spec` = > table.put in=`spec` at="items" value=items* *`m` = > table.put in=None at=sel value=spec* **> table.put in=None at="render_list" value=m** # page + `title`="Marqdo Web" + `intro`="" + `shell_css`=None + `layout`=None + `asset_version`=None > ensure_plugin **> web_page_new title=`title` intro=`intro` shell_css=`shell_css` layout=`layout` asset_version=`asset_version`** ## shell_css + `mode`=full Framework shell CSS mode for this page: `full` (default), `minimal` (vars only), or `off`/`none`. *`out` = > table.put in=`self` at="shell_css" value=mode* **out** ## layout + `layout`=sidebar Page chrome layout: `sidebar` (default when a side slot exists), `stacked` (single column; no `has-sidebar` grid), `bare` (main only), or `rail`. *`out` = > table.put in=`self` at="layout" value=layout* **out** ## asset_version + `version`="" Default `?v=` bump for head scripts/styles that omit a per-row `version` column. *`out` = > table.put in=`self` at="asset_version" value=version* **out** ## compose_components + `components` Assemble nav / sidebar / footer from a page table (`|组件|样式|` or `|src|style|`). Nav bind tables may include optional `媒体`/`media` (responsive show) and `当`/`when` (`auth` / `guest` / `hide`) columns — see C4 conditional nav. **> web_compose_components page=`self` components=`components`** ## compose_main + `main` Assemble main from a bind table (`|属性|值|样式|` or `|front|back|css|`). **> web_compose_main page=`self` main=`main`** ## query + `query` Attach a DB where-condition map for the main bind. Values may contain `{param}` placeholders that are resolved from dynamic-route params (e.g. `/post/{slug}`). **> web_page_query page=`self` query=`query`** ## order + `order` Set a default `ORDER BY` for the main bind (e.g. `-created_at` for newest first). **> web_page_order page=`self` order=`order`** ## link_prefix + `prefix` Prefix for card links in the main bind (default `/post/`). Cards whose bind has an `href`/`链接` field become ``. **> web_page_link_prefix page=`self` prefix=`prefix`** ## css + `css` Append a **raw** CSS string to the page's stylesheet (`styles_css`). Skips table-cell expression evaluation — use for themes with `/`, `@keyframes`, or long media queries. Hand-written theme alongside the assembled shell; or link `static/theme.css` via `head`. **> web_page_css page=`self` css=`css`** ## detail + `detail`=True Render the main bind's first row as a full article (title/meta/tags/body) instead of a list of cards. Set on the dynamic post page so `/post/{slug}` shows one post. **> web_page_detail page=`self` detail=`detail`** ## chrome + `nav_html`="" + `footer_html`="" + `body_class`="" Override default header/footer list chrome with raw HTML (site navbar / footer). Optional `body_class` is appended to ``. **> web_page_chrome page=`self` nav_html=`nav_html` footer_html=`footer_html` body_class=`body_class`** ## meta + `meta` SEO / OpenGraph metadata as a data table (`|key|value|`). Keys such as `title`, `description`, `canonical`, `og:type` become `` tags at render time. Special keys `icon` / `favicon` / `apple-touch-icon` emit `` (not ``). **> web_page_meta page=`self` meta=`meta`** ## head + `table` Assemble `` resources from a GFM table (`|rel|href|type|sizes|media|as|crossorigin|defer|async|version|` or ZH `|关系|地址|…|推迟|异步|版本|`). `rel=script` / `module` become `