Ship the web L1/plugin stack (bind tables, variable-named db.init, live render) and tighten the admin UI with sidebar, toolbar, forms, and activity log. Co-authored-by: Cursor <cursoragent@cursor.com>
2.3 KiB
title: ext/web smoke (offline) description: Variable-name tables + page region methods.
ext/web/web.mq.md lib/json.mq.md lib/sys.mq.md
main
web.ensure_plugin
nav =
| 前端变量 | 后端数据库 | 绑定css样式 |
|---|---|---|
| 首页 | / | |
| 文档 | /docs |
*links = > web.as_links table=nav *
*ln = > len value=links *
ln== 2
print text=nav-ok
print text=nav-bad
项*名= > json.get value=项key=label *print text=
名
*binds = > web.as_bind table=nav *
*bn = > len value=binds *
bn== 2
print text=bind-ok
print text=bind-bad
*page = > web.page title=Smoke *
*page = > page.nav table=nav *
*html = > page.render *
*parts = > split value=html sep=首页 *
*n = > len value=parts *
n> 1
print text=render-ok
print text=render-bad
*dir = > sys.env_get name=TMPDIR *
dir_= 1-
*dir = /tmp *
*slash = > json.parse text={"a":"/mq-web-gold-"} *
*a = > json.get value=slash key=a *
*pid = > sys.env_get name=USER *
*dbpath = dir + a + pid + ".db" *
*url = "sqlite:" + dbpath *
*db = > web.db url=url *
articles =
| 字段 | 类型 | 可空 |
|---|---|---|
| id | integer | false |
| title | text | false |
*articles = > db.init name=articles fields=articles *
种子 =
| @ | title |
|---|---|
| 1 | hello |
db.insert table=articlesrows=种子
主体 =
| 前端变量 | 后端数据库 | 绑定css样式 |
|---|---|---|
| title | title | card-title |
*page = > web.page title=Smoke db_url=url *
*page = > page.nav table=nav *
*page = > page.main table=articles bind=主体 intro="
Smoke
" * *html2 = > page.render *
*parts2 = > split value=html2 sep=hello *
*n2 = > len value=parts2 *
n2> 1
print text=live-ok
print text=live-bad
*文章 = > db.follow table=articles *
*page = > web.page title=Smoke *
*page = > page.nav table=nav *
*page = > page.follow name=main live=文章 *
*html3 = > page.render *
*parts3 = > split value=html3 sep=hello *
*n3 = > len value=parts3 *
n3> 1
print text=follow-ok
print text=follow-bad