--- 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 json:lib/json.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` 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. Styles stay as data tables, `make_style` turns them into CSS — 样式即数据、装配即函数. > ensure_plugin **> web_style name=`name` table=`table`** ## 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. *`m` = > json.set map=None key=sel value=text* **> json.set map=None key="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 Merge browser effect keys into one return map (omit `None`). Route E effects included. *`out` = > json.set map=None key="_mq" value=True* 1. `set_text` != None *`out` = > json.set map=out key="set_text" value=set_text* 1. `set_value` != None *`out` = > json.set map=out key="set_value" value=set_value* 1. `set_attr` != None *`out` = > json.set map=out key="set_attr" value=set_attr* 1. `set_class` != None *`out` = > json.set map=out key="set_class" value=set_class* 1. `toggle_class` != None *`out` = > json.set map=out key="toggle_class" value=toggle_class* 1. `set_style` != None *`out` = > json.set map=out key="set_style" value=set_style* 1. `set_html` != None *`out` = > json.set map=out key="set_html" value=set_html* 1. `render_list` != None *`out` = > json.set map=out key="render_list" value=render_list* 1. `navigate` != None *`out` = > json.set map=out key="navigate" value=navigate* 1. `storage` != None *`out` = > json.set map=out key="storage" value=storage* 1. `ws` != None *`out` = > json.set map=out key="ws" value=ws* 1. `fetch` != None *`out` = > json.set map=out key="fetch" value=fetch* 1. `fetch_all` != None *`out` = > json.set map=out key="fetch_all" value=fetch_all* 1. `after` != None *`out` = > json.set map=out key="after" value=after* 1. `interval` != None *`out` = > json.set map=out key="interval" value=interval* 1. `clear_interval` != None *`out` = > json.set map=out key="clear_interval" value=clear_interval* 1. `focus` != None *`out` = > json.set map=out key="focus" value=focus* 1. `blur` != None *`out` = > json.set map=out key="blur" value=blur* 1. `scroll_into` != None *`out` = > json.set map=out key="scroll_into" value=scroll_into* **out** ## list_html + `sel` + `tag`="li" + `items` Build a `render_list` effect: `{ render_list: { sel: { tag, items } } }`. *`spec` = > json.set map=None key="tag" value=tag* *`spec` = > json.set map=spec key="items" value=items* *`m` = > json.set map=None key=sel value=spec* **> json.set map=None key="render_list" value=m** # page + `title`="Marqdo Web" + `intro`="" > ensure_plugin **> web_page_new title=`title` intro=`intro`** ## compose_components + `components` Assemble nav / sidebar / footer from a page table (`|组件|样式|` or `|src|style|`). **> 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`). Use it to ship a hand-written theme alongside the assembled shell. **> 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`** ## 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|` or ZH `|关系|地址|类型|…|`). `rel=script` / `module` become `