Add Chinese web-site example and 网页.mq.md smoke.

Mirrors the English sample on port 18082 using only Chinese class APIs for page, db, form, and app.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
cflmyandCursor committed 2026-08-12 09:20:34 +08:00
1 parent c181b74a88
commit a0c56fa352
10 files changed
+287

No files matched your search

+10
View File
@@ -0,0 +1,10 @@
# examples/web-site-zh
中文作者面示例:只导入 `ext/web/网页.mq.md`(不用英文 `web.mq.md`)。
```bash
cargo build -p marqdo_plugin_web
cargo run -- examples/web-site-zh/index.mq.md
```
打开 http://127.0.0.1:18082/ — `/about`、`/new`、`/admin`。
@@ -0,0 +1,9 @@
## foot
`foot` =
| 属性 | 值 | 样式 |
|------|-----|------|
| Marqdo | https://github.com | |
**`foot`**
+12
View File
@@ -0,0 +1,12 @@
## nav
`nav` =
| 属性 | 值 | 样式 |
|------|-----|------|
| 首页 | / | |
| 关于 | /about | |
| 写文章 | /new | |
| 后台 | /admin | |
**`nav`**
@@ -0,0 +1,10 @@
## side
`side` =
| 属性 | 值 | 样式 |
|------|-----|------|
| 笔记 | / | |
| 文档 | https://github.com | |
**`side`**
+22
View File
@@ -0,0 +1,22 @@
## schema
`fields` =
| 字段 | 类型 | 可空 |
|------|------|------|
| id | integer | false |
| title | text | false |
| body | text | true |
**`fields`**
## seed
`rows` =
| id | title | body |
|----|-------|------|
| 1 | 你好 Marqdo | 第一篇来自 GFM 表格。 |
| 2 | 代码即文档 | 页面表就是程序。 |
**`rows`**
+19
View File
@@ -0,0 +1,19 @@
---
title: db/index
description: 打开 sqlite、建表、幂等种子。
> ext/web/网页.mq.md
> articles.mq.md as articles
---
## open
*`store` = > 网页.数据库 地址="sqlite:data/site-zh.db" *
*`fields` = > articles.schema *
> `store`.初始化 名=articles 字段=`fields`
*`rows` = > `store`.查询 表=articles 上限=1 *
1. `rows`
**`store`**
2. *
*`seed` = > articles.seed *
> `store`.插入 表=articles 行=`seed`
**`store`**
+64
View File
@@ -0,0 +1,64 @@
---
title: 中文站点示例
description: Home + /about + /new(表单嵌入)+ 后台;只用 ext/web/网页.mq.md。
> ext/web/网页.mq.md
> styles/shell.mq.md
> components/nav.mq.md
> components/side.mq.md
> components/foot.mq.md
> db/articles.mq.md
> db/index.mq.md as db
---
# main
`home` =
| 组件 | 样式 |
|------|------|
| nav.`nav` | shell.`topnav` |
| side.`side` | shell.`side_panel` |
| foot.`foot` | |
`index` =
| 属性 | 值 | 样式 |
|------|-----|------|
| `title` | articles.`articles`.title | shell.`card_title` |
| `body` | articles.`articles`.body | shell.`card_body` |
`article_fields` =
| 字段 | 标签 | 类型 | 必填 | 默认 |
|------|------|------|------|------|
| title | 标题 | text | true | |
| body | 正文 | textarea | false | |
`article_rules` =
| 字段 | 规则 | 消息 |
|------|------|------|
| title | required | 标题不能为空 |
| title | max:120 | 标题太长 |
| body | max:8000 | 正文太长 |
*`store` = > db.open *
*`page` = > 网页.页面 标题="Marqdo 中文站" 引言="<h1>中文站</h1><p>表格 + 类方法。</p>" *
*`page` = > `page`.组件装配 组件=`home` *
*`page` = > `page`.主体装配 主体=`index` *
*`about` = > 网页.页面 标题="关于" 引言="<h1>关于</h1><p>导入网页.mq.md 即用中文 API。</p>" *
*`about` = > `about`.组件装配 组件=`home` *
*`article_form` = > 网页.表单 表=articles 动作=插入 *
*`article_form` = > `article_form`.字段 字段=`article_fields` *
*`article_form` = > `article_form`.规则 规则=`article_rules` *
*`new` = > 网页.页面 标题="写文章" 引言="<h1>写文章</h1><p>表单嵌在主区。</p>" *
*`new` = > `new`.组件装配 组件=`home` *
*`new` = > `new`.表单装配 id=article 表单=`article_form` *
*`app` = > 网页.应用 页面=`page` 数据库=`store` 后台=True 主机=127.0.0.1 端口=18082 *
*`app` = > `app`.路由 路径=/about 页面=`about` *
*`app` = > `app`.路由 路径=/new 页面=`new` *
> `app`.监听
+42
View File
@@ -0,0 +1,42 @@
## topnav
`topnav` =
| 属性 | 值 |
|------|-----|
| background | #ffffff |
| border-bottom | 1px solid #e7e5e4 |
**`topnav`**
## side_panel
`side_panel` =
| 属性 | 值 |
|------|-----|
| background | #f5f5f4 |
**`side_panel`**
## card_title
`card_title` =
| 属性 | 值 |
|------|-----|
| font-size | 1.15rem |
| margin | 0 0 0.35rem |
**`card_title`**
## card_body
`card_body` =
| 属性 | 值 |
|------|-----|
| color | #57534e |
| margin | 0 |
**`card_body`**
+82
View File
@@ -0,0 +1,82 @@
---
title: web zh API smoke
description: Offline Chinese 网页.mq.md assemble (no listen).
> ext/web/网页.mq.md
> web-fixtures/components/nav.mq.md
> web-fixtures/components/side.mq.md
> web-fixtures/components/foot.mq.md
> web-fixtures/db/articles.mq.md as articles
> lib/json.mq.md
---
# main
*`store` = > 网页.数据库 地址="sqlite:web-fixtures/data/zh-smoke.db" *
*`schema` = > articles.schema *
> `store`.初始化 名=articles 字段=`schema`
> `store`.执行 sql="DELETE FROM articles"
> `store`.执行 sql="DELETE FROM sqlite_sequence WHERE name='articles'"
`layout` =
| 组件 | 样式 |
|------|------|
| nav.`nav` | |
| side.`side` | |
| foot.`foot` | |
`index` =
| 属性 | 值 | 样式 |
|------|-----|------|
| `title` | articles.`articles`.title | |
| `body` | articles.`articles`.body | |
`seed` =
| title | body |
|-------|------|
| 中文种子 | 正文 |
> `store`.插入 表=articles 行=`seed`
*`page` = > 网页.页面 标题="中文烟测" 引言="<h1>中文</h1>" *
*`page` = > `page`.组件装配 组件=`layout` *
*`page` = > `page`.主体装配 主体=`index` *
*`html` = > `page`.渲染 数据库=`store` *
1. `html`
> print text=render-ok
2. *
> print text=render-fail
*`nav` = > json.get value=`page` key=nav *
1. `nav`
> print text=compose-ok
2. *
> print text=compose-fail
`fields` =
| 字段 | 标签 | 类型 | 必填 | 默认 |
|------|------|------|------|------|
| title | 标题 | text | true | |
*`f` = > 网页.表单 表=articles 动作=插入 *
*`f` = > `f`.字段 字段=`fields` *
*`page` = > `page`.表单装配 id=article 表单=`f` *
*`fid` = > json.get value=`page` key=form_id *
1. `fid` == "article"
> print text=form-ok
2. *
> print text=form-fail
*`app` = > 网页.应用 页面=`page` 数据库=`store` 主机=127.0.0.1 端口=18082 *
*`about` = > 网页.页面 标题="关于" 引言="<p>关于</p>" *
*`app` = > `app`.路由 路径=/about 页面=`about` *
*`routes` = > json.get value=`app` key=routes *
*`routed` = > json.get value=`routes` key="/about" *
1. `routed`
> print text=route-ok
2. *
> print text=route-fail
+17
View File
@@ -1341,6 +1341,23 @@ all-ok",
);
}
#[test]
fn ext_web_zh_smoke() {
let status = Command::new("cargo")
.args(["build", "-p", "marqdo_plugin_web"])
.current_dir(env!("CARGO_MANIFEST_DIR"))
.status()
.expect("build web plugin");
assert!(status.success(), "failed to build marqdo_plugin_web");
assert_out(
"tests/ext/web-zh-smoke.mq.md",
"render-ok
compose-ok
form-ok
route-ok",
);
}
#[test]
fn ext_agent_framework_smoke() {
let status = Command::new("cargo")