feat(web): Document/Endpoint/Resource artifact rewrite (ADR 0007)
Replace the monolithic compose_*/configure author surface with file-level
web|endpoint artifacts, split ext/{web,data,security,net}, and lock
no-degrade rules so the model cannot regress to God-object APIs.
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
1 parent
33f8b94bb0
commit
67bac1bf02
54 files changed
+4642
-2505
No files matched your search
@@ -0,0 +1,26 @@
|
||||
---
|
||||
description: Marqdo Web Artifact — no degradation; Document/Endpoint/Resource only
|
||||
globs: ext/web/**,ext/net/**,ext/data/**,ext/security/**,examples/**/*,tests/ext/web*,doc/design/ext-web*,doc/adr/0007*
|
||||
alwaysApply: true
|
||||
---
|
||||
|
||||
# Web Artifact — 不允许降级
|
||||
|
||||
Canonical: `doc/adr/0007-web-document-endpoint.md` · `doc/design/ext-web-artifact.md` · `doc/next/007.md` (superseded).
|
||||
|
||||
## Hard bans
|
||||
|
||||
1. **Do not** restore or reintroduce author-facing `compose_main` / `compose_intro` / `compose_*` fragmented table DSLs, god `# page` mutation piles, or `app.configure(...)` junk-drawer APIs.
|
||||
2. **Do not** use `json.set` / `json.append` bag glue for pages, routes, or middleware. Tables = data. View schema is only `|type|slot|value|attrs|style|` (ZH aliases allowed).
|
||||
3. **Do not** call `ensure_plugin` or `host_*` from author programs or from `ext/**` (plugin load is facade/capability only).
|
||||
4. **Do not** register implicit user routes. Declared routes come from Artifact metadata or `web.route`. System routes (`/_part`, `/_form`, …) must appear in `web.inspect`.
|
||||
5. **Do not** invent DSL, nested frontmatter under `##`, or new table dialects when the design is silent — **stop and ask**.
|
||||
6. **Do not** mix EN/ZH API names in one `.mq.md`.
|
||||
7. **Do not** silently delete capabilities. Removals require design text + tests updated in the same change.
|
||||
8. **Do not** put DB/auth/cache/storage/websocket author APIs back into `ext/web/web.mq.md` — they live in `ext/data`, `ext/security`, `ext/net`.
|
||||
|
||||
## Required direction
|
||||
|
||||
- Document (`type: web` / `类型: 网页`), Endpoint (`type: endpoint` / `类型: 端点`), Resource modules.
|
||||
- Facade only: `web.page` · `web.route` · `web.serve` · `web.render` · `web.inspect` (ZH mirrors).
|
||||
- Code is documentation: the `.mq.md` is the page/API docs and the implementation.
|
||||
@@ -92,7 +92,7 @@ Better still — call a named helper:
|
||||
7. **Do not use `##` inside `# main` for document sectioning** — those become nested functions. Use paragraphs / `---` breaks instead.
|
||||
8. **Index:** prefer `[键](集合)` / `` [`名`](集合) `` over footnote `` m[^k] ``.
|
||||
|
||||
Browser client programs: prefer `import browser:lib/browser.mq.md` (no native plugin). Server sites: `ext/web` + GFM page/style tables.
|
||||
Browser client programs: prefer `import browser:lib/browser.mq.md` (no native plugin). Server sites: Artifact Metadata (`type: web|endpoint`) + `ext/web` facade + `ext/data` / `ext/security` / `ext/net` — see [ext-web-artifact.md](../../doc/design/ext-web-artifact.md). **Never** restore `compose_*` / `app.configure`.
|
||||
|
||||
## Developing libraries (`lib/*`, `ext/*`)
|
||||
|
||||
@@ -121,7 +121,9 @@ Canonical thin-template + waves: [lib-code-as-docs.md](../../doc/design/lib-code
|
||||
| Need | Place |
|
||||
|------|--------|
|
||||
| Browser effect maps (WASM client) | `lib/browser.mq.md` |
|
||||
| Site HTML / HTTP / DB | `ext/web` classes + compose from tables |
|
||||
| Site HTML / HTTP | `ext/web` Document/Endpoint + View tables |
|
||||
| DB / cache / storage | `ext/data` |
|
||||
| Auth / OIDC / RBAC | `ext/security` |
|
||||
| List/map primitives | `lib/table.mq.md` |
|
||||
| Parse JSON text | `lib/json.mq.md` only |
|
||||
|
||||
|
||||
@@ -224,44 +224,53 @@ APIs: `# agent` / `# 智能体` → `## run` / `## route` / `## step` / `## plan
|
||||
|
||||
Examples: [agent-pong](../../examples/agent-pong/) · [agent-okf-flywheel](../../examples/agent-okf-flywheel/). Harness: `scripts/agent-harness.sh`. Design: [ext-agent.md](../../doc/design/ext-agent.md) · Wave B: [agent-framework-2026-09.md](../../doc/research/agent-framework-2026-09.md) · v2: [doc/next/003.md](../../doc/next/003.md) · P4: [doc/next/004.md](../../doc/next/004.md). Dev LLM: copy [.env.example](../../.env.example) → `.env` (gitignored).
|
||||
|
||||
## Official extension: `ext/web` (dynamic sites)
|
||||
## Official extension: `ext/web` (Document / Endpoint / Resource)
|
||||
|
||||
Install: `marqdo ext add web` (ZH id: `网页`). Build native plugin first: `cargo build --release -p marqdo_plugin_web`.
|
||||
Install: `marqdo ext add web` (ZH id: `网页`). Build native plugin: `scripts/build-web-plugin.sh` / `marqdo ext add web`.
|
||||
|
||||
Import **one language file** — never mix EN/ZH API names in the same `.mq.md`:
|
||||
**Constitution (ADR 0007 — do not degrade):**
|
||||
|
||||
- EN: `import web:ext/web/web.mq.md`
|
||||
1. **Document / Endpoint / Resource** — `.mq.md` with `type: web|endpoint` (ZH `类型: 网页|端点`) is the site surface; not a Flask-style class pile.
|
||||
2. **Code is documentation** — the file is docs + route + handler.
|
||||
3. **Table = data** — View schema only `|type|slot|value|attrs|style|`. No `compose_*` dialects, no `json.set` glue.
|
||||
4. **Facade only** — `web.page` · `web.route` · `web.serve` · `web.render` · `web.inspect`. DB → `ext/data`; auth → `ext/security`; ws/http → `ext/net`.
|
||||
5. **No author `ensure_plugin` / `host_*`**; import web = capability (plugin auto-load).
|
||||
6. **Declared vs system routes**; `web.inspect` lists both. No silent user routes.
|
||||
|
||||
Import **one language** per file:
|
||||
|
||||
- EN: `import web:ext/web/web.mq.md` (+ `import data:ext/data/db.mq.md` as needed)
|
||||
- ZH: `导入 网页:ext/web/网页.mq.md`
|
||||
|
||||
**Hard rules (web):**
|
||||
```markdown
|
||||
---
|
||||
type: web
|
||||
route: /
|
||||
title: Hello
|
||||
import web:ext/web/web.mq.md
|
||||
---
|
||||
|
||||
- Authors use **GFM tables + `#` classes** — no `json.parse` / `json.set` glue, no hand-built part JSON.
|
||||
- Table cells stay **literal strings**; path text like `` `posts`.`title` `` is resolved by web classes.
|
||||
- **Quote path/MIME cells** that contain `/` (T5 cell expressions treat bare `/` as division): `"/static/logo.svg"`, `"image/png"`.
|
||||
- **`ext/**` never calls `host_*`** — hot path is native `plugins/web` ABI (default **Go `libweb`**, build via `scripts/build-web-plugin.sh`).
|
||||
- HTTPS: terminate at reverse proxy; set `cookie_secure=True` on auth (no in-process TLS).
|
||||
# Hello
|
||||
|
||||
**Typical layout:**
|
||||
|
||||
```text
|
||||
index.mq.md # entry + home page table + listen
|
||||
pages/ # sub-pages
|
||||
components/ # reusable |属性|值|样式| tables
|
||||
styles/ # CSS modules
|
||||
public/ # static + favicon.ico|png|svg
|
||||
db/ # schema + open/init
|
||||
data/ # sqlite runtime (gitignore)
|
||||
Executable document as a page.
|
||||
```
|
||||
|
||||
**Core objects (EN / ZH):** `# page`/`页面`, `# style`/`样式`, `# db`/`数据库`, `# form`/`表单`, `# app`/`应用`, `# auth`/`鉴权`, `# cache`/`缓存`, `# storage`/`存储`.
|
||||
```markdown
|
||||
---
|
||||
type: endpoint
|
||||
method: POST
|
||||
path: /api/ping
|
||||
response: json
|
||||
---
|
||||
|
||||
**Typical flow:** `db.init` → `page.compose_*` → `app` + `static` / `listen`. Client: `marqdo wasm build -o static` + `web.client_embed source="/static/client.mq.md"` — **no author JS**; bridge may implement rich host effects ([browser-wasm-e.md](../../doc/roadmap/browser-wasm-e.md) · [browser-app](../../examples/browser-app/)).
|
||||
*{"ok": true}*
|
||||
```
|
||||
|
||||
**Shipped surface (W0–W7 + P3 + W8 + route D mount):** middleware + JSON API (`app.configure`); transactions, pagination, FTS search (`db.migrate`, `db.fts`, `db.search`); security (argon2, CSRF, SQLite sessions, login rate limit); SEO / RSS / Markdown (`page.meta`, `route_rss`, `lib/net.markdown_parse`); upload / download / gallery; sitemap / robots / error pages / redirects; RBAC (`app.gate`, user `role`); audit timestamps + FK in `db.init`; ETag on downloads; **W8** site icons (`app.icons` → `/favicon.ico`), head resource tables (`page.head`), image assembly (`make_images` / `page.images`); **表驱动引言** `page.compose_intro` / `页面.引言装配`(属性/值/样式表 → `.main-intro`,避免手写 HTML 字符串);**D** `client_embed` auto-mount + DOM effect helpers (`text_patch` / `dom_patch`).
|
||||
Site entry may `# main` → `web.serve root="."`. Client WASM: `ext/web/client.mq.md` / `lib/browser` — no author JS.
|
||||
|
||||
Design: [ext-web.md](../../doc/design/ext-web.md) · assets: [web-assets-and-images.md](../../doc/design/web-assets-and-images.md) · capability matrix: [web-net-capabilities.md](../../doc/design/web-net-capabilities.md) · example: [examples/marqdo-blog/](../../examples/marqdo-blog/) · client: [examples/web-client-site/](../../examples/web-client-site/).
|
||||
Design: [ext-web-artifact.md](../../doc/design/ext-web-artifact.md) · ADR [0007](../../doc/adr/0007-web-document-endpoint.md) · rule: `.cursor/rules/web-artifact-no-degrade.mdc` · example: [examples/marqdo-blog/](../../examples/marqdo-blog/).
|
||||
|
||||
Web patterns: [examples.md](examples.md) §13 · API index: [reference.md](reference.md).
|
||||
Web patterns: [examples.md](examples.md) · API index: [reference.md](reference.md).
|
||||
|
||||
## Official extension: `ext/quantum` (circuits + Q7/Q8)
|
||||
|
||||
|
||||
@@ -3,10 +3,18 @@
|
||||
## Unreleased
|
||||
|
||||
### Added
|
||||
- **Web Artifact 模型(ADR 0007)**:`type: web|endpoint`(ZH `类型: 网页|端点`);核心 `src/artifact/`;`sys.artifact_kind`;无 `# main` 时 Result 摘要。
|
||||
- **`ext/web` facade**:`page` · `route` · `serve` · `render` · `inspect` · `use`;子模块 page/route/dom/client/component。
|
||||
- **`ext/data` · `ext/security` · `ext/net`**:从 monolithic web 拆出 Resource。
|
||||
- **统一 View** `|type|slot|value|attrs|style|` + ABI `web_render_nodes` / `web_serve_root` / `web_inspect` / `web_app_use`。
|
||||
- **规则**:`.cursor/rules/web-artifact-no-degrade.mdc`;设计 `doc/design/ext-web-artifact.md`。
|
||||
|
||||
### Fixed
|
||||
|
||||
### Changed
|
||||
- **破坏性**:删除作者面 `compose_*` / `app.configure` / 作者 `ensure_plugin`。旧 web gold 标 `#[ignore]`;新金样 `web-artifact-*`。
|
||||
- **核心表面 Δ**:**无增删**(复用 Metadata `type`)。
|
||||
- 修订 `ext-web.md` C1;`doc/next/007.md` superseded。
|
||||
|
||||
## v1.1.1 — 2026-09-24
|
||||
|
||||
|
||||
@@ -0,0 +1,54 @@
|
||||
# ADR 0007:Web Document / Endpoint / Resource(破坏性 · 代码即文档)
|
||||
|
||||
| | |
|
||||
|---|---|
|
||||
| Status | **Accepted** |
|
||||
| Date | 2026-09-28 |
|
||||
| Related | [ext-web-artifact.md](../design/ext-web-artifact.md) · [ext-web.md](../design/ext-web.md) · [binding.md](../design/binding.md) · ADR [0006](0006-artifact-metadata-binding.md) · [layers.md](../design/layers.md) · [doc/next/007.md](../next/007.md) |
|
||||
|
||||
## Context
|
||||
|
||||
- [`ext/web/web.mq.md`](../../ext/web/web.mq.md) 已膨胀为小型 Web Framework(Page God Object、`configure` 垃圾抽屉、碎片 Table DSL、隐式路由),与 Marqdo「代码即文档」冲突。
|
||||
- [doc/next/007.md](../next/007.md) 提出 Document / Endpoint / Resource 三原语与拆分 `ext/web` · `ext/net` · `ext/data` · `ext/security`。
|
||||
- 现行 [ext-web.md](../design/ext-web.md) **C1** 禁止为 web 改核心;Document/Endpoint 装载识别需要 Language/Runtime 参与(复用 Artifact Metadata `type`,**不**新增 CORE_CONSTRUCTS 标记)。
|
||||
- Binding(ADR 0006)已提供文件级 Metadata;`type: prompt` 先例在扩展侧消费 metadata。
|
||||
|
||||
## Decision
|
||||
|
||||
1. **采纳** Document / Endpoint / Resource 为 Web 模型一等公民;正式规范见 [ext-web-artifact.md](../design/ext-web-artifact.md)。
|
||||
2. **修订 ext-web C1**:允许核心在装载期识别 `type: web|endpoint`(及中文 `类型: 网页|端点`)并暴露 artifact 分类;**装配 / HTTP / DB 语义仍在 ext + plugin**。单元格求值、import 句法、CORE_CONSTRUCTS 计数不变。
|
||||
3. **文件级 Artifact only**:不在 `##` 函数体嵌套 `---` frontmatter(与 Binding Phase 1 / 解析器一致)。
|
||||
4. **破坏性重写作者面**:删除 `compose_*` 碎片 DSL、god `# page` 变异堆、`app.configure` 多参数抽屉、作者 `ensure_plugin`;examples 与 `tests/ext/web*` 同步重写。
|
||||
5. **目录定稿**(007 §三十五 + §四十):
|
||||
- `ext/web/` — page · route · component · dom · client · facade
|
||||
- `ext/net/` — http · websocket · url
|
||||
- `ext/data/` — db · cache · storage
|
||||
- `ext/security/` — auth · oidc · rbac
|
||||
6. **统一 View 表**:`| type | slot | value | attrs | style |`;Table = Data,禁止每函数私有方言。
|
||||
7. **declared vs system routes**:用户 route 须声明;`/_part` · `/_form` 等为 system,经 `web.inspect` 可见。
|
||||
8. **import = capability**:`import web:…` 由 facade 自动加载 native plugin;作者程序不写 `ensure_plugin` / `host_*`。
|
||||
9. **Metadata v1 锁定(原 007 未决项)**:
|
||||
- 发现:`web.serve root=` 扫描 `root/**/*.mq.md`,仅注册 `type`/`类型` ∈ {web,网页,endpoint,端点} 的文件;无 type 的库文件忽略。
|
||||
- Data:仅 flat 键 `data_source` · `data_order` · `data_where`(text;where 为 `col=val` 逗号分隔)。嵌套 YAML `data:` 推迟。
|
||||
- Result:`{ok: bool, value: any, error: text|None}`。
|
||||
- Realtime 模块名:`ext/net/websocket.mq.md`(ZH:`实时.mq.md`)。
|
||||
- ZH metadata:`类型`←type,`路由`←route,`方法`←method,`路径`←path,`请求`←request,`响应`←response,`鉴权`←auth,`数据源`←data_source,`排序`←data_order,`条件`←data_where。
|
||||
|
||||
## Consequences
|
||||
|
||||
### Positive
|
||||
|
||||
- `.mq.md` 同时是文档、路由、实现与鉴权声明。
|
||||
- 与 LLM/Agent Artifact Metadata 统一心智。
|
||||
- 职责边界清晰,可独立演化 data/security/net。
|
||||
|
||||
### Negative / Risks
|
||||
|
||||
- 破坏性:全部现有 web 作者程序与 smokes 必须改写。
|
||||
- Endpoint 热路径仍经 plugin → `CallLibPath` / 文件装载回调;须保持 ABI 稳定演进。
|
||||
- flat data 键表达力弱于嵌套 YAML;后续另 ADR。
|
||||
|
||||
### Neutral
|
||||
|
||||
- 不新增 Markdown 核心标记;`${…}` 仍仅 Metadata。
|
||||
- Go `plugins/web` 可分波删除死 compose ABI;作者面先断。
|
||||
@@ -0,0 +1,195 @@
|
||||
# 官方扩展:Web Artifact(Document / Endpoint / Resource)
|
||||
|
||||
| | |
|
||||
|---|---|
|
||||
| 状态 | **Accepted · 破坏性(取代 page/app God Object 作者面)** |
|
||||
| 日期 | 2026-09-28 |
|
||||
| ADR | [0007-web-document-endpoint.md](../adr/0007-web-document-endpoint.md) |
|
||||
| 讨论稿 | [doc/next/007.md](../next/007.md)(superseded) |
|
||||
| 安装 | `marqdo ext add web`(`web` / `网页`) |
|
||||
| 相关 | [binding.md](binding.md) · [ext-web.md](ext-web.md) · [stdlib-i18n.md](stdlib-i18n.md) · [layers.md](layers.md) |
|
||||
|
||||
---
|
||||
|
||||
## 0. 一句话
|
||||
|
||||
> **Document describes the page. Table describes the data. Endpoint describes the interaction. Metadata describes the runtime. Marqdo executes all of them.**
|
||||
|
||||
---
|
||||
|
||||
## 1. 三原语
|
||||
|
||||
| Artifact | Metadata `type` / `类型` | 含义 |
|
||||
|----------|--------------------------|------|
|
||||
| **Document** | `web` / `网页` | Markdown 正文 + View → HTML;`route`/`路由` 注册 declared HTTP |
|
||||
| **Endpoint** | `endpoint` / `端点` | 可执行正文为 handler;`path`+`method` 注册 API |
|
||||
| **Resource** | (绑定/导入) | `ext/data` · `ext/security` · 未来 LLM 等,经 metadata / import 声明 |
|
||||
|
||||
核心装载识别 `type`/`类型`(见 `src/artifact/`);渲染与 listen 在 `ext/web` + `plugins/web`。
|
||||
|
||||
---
|
||||
|
||||
## 2. 目录
|
||||
|
||||
```text
|
||||
ext/web/
|
||||
web.mq.md · 网页.mq.md # facade: page route serve render inspect
|
||||
page.mq.md · route.mq.md · component.mq.md · dom.mq.md · client.mq.md
|
||||
ext/net/ http.mq.md · websocket.mq.md · url.mq.md
|
||||
ext/data/ db.mq.md · cache.mq.md · storage.mq.md
|
||||
ext/security/ auth.mq.md · oidc.mq.md · rbac.mq.md
|
||||
```
|
||||
|
||||
作者入口通常:
|
||||
|
||||
```text
|
||||
site/
|
||||
index.mq.md # type: web · route: / · 或 # main → web.serve
|
||||
pages/*.mq.md # type: web
|
||||
api/*.mq.md # type: endpoint
|
||||
data/ # sqlite runtime (gitignore)
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## 3. Document(`type: web`)
|
||||
|
||||
```markdown
|
||||
---
|
||||
type: web
|
||||
title: Marqdo Blog
|
||||
route: /
|
||||
method: GET
|
||||
data_source: posts
|
||||
data_order: -created_at
|
||||
import web:ext/web/web.mq.md
|
||||
import data:ext/data/db.mq.md
|
||||
---
|
||||
|
||||
# Marqdo
|
||||
|
||||
Welcome to the executable web.
|
||||
```
|
||||
|
||||
| 键 (EN) | 键 (ZH) | 说明 |
|
||||
|---------|---------|------|
|
||||
| `type` | `类型` | `web` / `网页` |
|
||||
| `route` | `路由` | 路径,可含 `{param}` |
|
||||
| `method` | `方法` | 默认 `GET` |
|
||||
| `title` | `标题` | 文档标题 / `<title>` |
|
||||
| `data_source` | `数据源` | 表名 |
|
||||
| `data_order` | `排序` | 如 `-created_at` |
|
||||
| `data_where` | `条件` | `col=val,col2=val2` |
|
||||
|
||||
正文 Markdown 经 `dom` 变为 DOM Artifact,再 `web.render`。可选 View 表:
|
||||
|
||||
```markdown
|
||||
`nodes` =
|
||||
|
||||
| type | slot | value | attrs | style |
|
||||
|------|------|-------|-------|-------|
|
||||
| text | kicker | AI Native | | eyebrow |
|
||||
| title | title | Marqdo | | title |
|
||||
```
|
||||
|
||||
`page.render nodes=` 是**唯一**主装配路径。禁止 `compose_main` / `compose_intro` 等碎片 DSL。
|
||||
|
||||
---
|
||||
|
||||
## 4. Endpoint(`type: endpoint`)
|
||||
|
||||
```markdown
|
||||
---
|
||||
type: endpoint
|
||||
method: POST
|
||||
path: /api/posts
|
||||
request: json
|
||||
response: json
|
||||
auth: member
|
||||
import data:ext/data/db.mq.md
|
||||
---
|
||||
|
||||
**post = > data.db.insert …**
|
||||
|
||||
*post*
|
||||
```
|
||||
|
||||
| 键 (EN) | 键 (ZH) | 说明 |
|
||||
|---------|---------|------|
|
||||
| `type` | `类型` | `endpoint` / `端点` |
|
||||
| `path` | `路径` | URL |
|
||||
| `method` | `方法` | GET/POST/… |
|
||||
| `request` | `请求` | `json` / `form` / `none` |
|
||||
| `response` | `响应` | `json` / `text` / `html` |
|
||||
| `auth` | `鉴权` | 角色名或 `none` |
|
||||
|
||||
正文在请求时执行;返回值按 `response` 序列化。Result 协议见 §8。
|
||||
|
||||
---
|
||||
|
||||
## 5. Facade API(EN / ZH)
|
||||
|
||||
| EN | ZH | 作用 |
|
||||
|----|-----|------|
|
||||
| `web.page` | `网页.页面` | 从 metadata/正文/nodes 构造 Document 句柄 |
|
||||
| `web.route` | `网页.路由` | 注册 declared Document 或 Endpoint |
|
||||
| `web.serve` | `网页.服务` | `root=` 扫描注册 + listen |
|
||||
| `web.render` | `网页.渲染` | Document → HTML(离线/预览) |
|
||||
| `web.inspect` | `网页.检视` | `{declared, system}` 路由表 |
|
||||
|
||||
Middleware 一等:`web.use` / `route.use`,表驱动;**禁止** `configure(cors, security, …)` 垃圾抽屉。
|
||||
|
||||
---
|
||||
|
||||
## 6. 发现算法(锁定)
|
||||
|
||||
`web.serve root=DIR host=… port=…`:
|
||||
|
||||
1. 递归枚举 `DIR` 下 `*.mq.md`(跳过 `data/`、隐藏目录、`node_modules`)。
|
||||
2. 解析文件头 Metadata;无 `type`/`类型` 或非 web/endpoint → 跳过。
|
||||
3. Document → declared route(缺 `route` 则相对 `root` 的路径映射,`index.mq.md` → `/`)。
|
||||
4. Endpoint → declared path+method(`path`/`路径` 必需)。
|
||||
5. System routes(`/_part/*`、`/_form/*`、静态等)由 runtime 挂载,仅出现在 `inspect.system`。
|
||||
6. 调用 native listen。
|
||||
|
||||
---
|
||||
|
||||
## 7. Table 规则
|
||||
|
||||
- **View**:仅 `|type|slot|value|attrs|style|`(及列名 ZH 别名:`类型|槽|值|属性|样式`)。
|
||||
- **Resource schema**:`|字段|类型|可空|` 等 — 专用且文档化,不是函数私有方言。
|
||||
- **禁止** `|属性|值|样式|` / `|front|back|css|` / `|组件|样式|` 作为页面主装配(已删除)。
|
||||
- Raw HTML/CSS = escape hatch(`dom.raw` / `page.css`),不是默认语言。
|
||||
|
||||
---
|
||||
|
||||
## 8. Result
|
||||
|
||||
所有易失败的 Resource / Endpoint 边界返回 map:
|
||||
|
||||
| 键 | 类型 | 说明 |
|
||||
|----|------|------|
|
||||
| `ok` | bool | 成功 |
|
||||
| `value` | any | 成功载荷 |
|
||||
| `error` | text \| None | 失败信息 |
|
||||
|
||||
---
|
||||
|
||||
## 9. 硬约束(取代旧 C1–C7 作者面)
|
||||
|
||||
| # | 约束 |
|
||||
|---|------|
|
||||
| A1 | Document/Endpoint 由核心识别 `type`;装配在 ext(ADR 0007) |
|
||||
| A2 | 禁止 `json.set` 袋胶水;Table = Data |
|
||||
| A3 | 中英分文件;同文件禁止混 API |
|
||||
| A4 | 禁止作者 `ensure_plugin` / `host_*` |
|
||||
| A5 | 禁止隐式用户 route;system 须 `inspect` 可见 |
|
||||
| A6 | 禁止恢复 `compose_*` / `app.configure` / god page 变异堆 |
|
||||
| A7 | 能力只许迁移/提升;删除须本设计明示 + tests 同步 |
|
||||
| A8 | 设计未锁定处停工提问,禁止自行发明 DSL |
|
||||
|
||||
---
|
||||
|
||||
## 10. 与旧 ext-web.md
|
||||
|
||||
旧「页面表 + compose_* + app.route」作者面 **废止**。历史能力矩阵见 [web-net-capabilities.md](web-net-capabilities.md);迁移后以本文件与 ADR 0007 为准。
|
||||
+17
-13
@@ -2,18 +2,21 @@
|
||||
|
||||
| | |
|
||||
|---|---|
|
||||
| 状态 | **Accepted · W0–W7 + P3 + W8(站点图标/Head/图片装配)完结**(SQLite/Postgres 作者面:页面装配 / db CRUD+`where` / form / 嵌入主区 / `app.route` / 路由 `/_part` / admin UI / RBAC / 上传相册 / SEO·RSS·sitemap / **favicon·头资源·图片装配**;Postgres 等见 §9) |
|
||||
| 日期 | 2026-08-11(W8:2026-08-29;请求上下文:2026-09-18) |
|
||||
| 相关 | [markdown-mapping.md](markdown-mapping.md) · [module-namespace.md](module-namespace.md) · [objects.md](objects.md) · [ext-abi.md](ext-abi.md) · [ext-cli.md](ext-cli.md) · [stdlib-i18n.md](stdlib-i18n.md) · [web-assets-and-images.md](web-assets-and-images.md) · **[ext-web-request-context.md](ext-web-request-context.md)** |
|
||||
| 状态 | **Superseded(作者面)· 历史能力档案** — 现行作者面见 **[ext-web-artifact.md](ext-web-artifact.md)** · ADR [0007](../adr/0007-web-document-endpoint.md) |
|
||||
| 日期 | 2026-08-11(W8:2026-08-29;请求上下文:2026-09-18;Artifact 重构:2026-09-28) |
|
||||
| 相关 | [ext-web-artifact.md](ext-web-artifact.md) · [markdown-mapping.md](markdown-mapping.md) · [module-namespace.md](module-namespace.md) · [objects.md](objects.md) · [ext-abi.md](ext-abi.md) · [ext-cli.md](ext-cli.md) · [stdlib-i18n.md](stdlib-i18n.md) · [web-assets-and-images.md](web-assets-and-images.md) · **[ext-web-request-context.md](ext-web-request-context.md)** |
|
||||
| 安装(目标) | `marqdo ext add web`(中英:`web` / `网页`) |
|
||||
| 本文目的 | 锁定**作者面**与**类 API**;指导实现 |
|
||||
| 本文目的 | **历史**类 API 与能力矩阵;新站请勿按本文 `compose_*` / `app.configure` 写作 |
|
||||
|
||||
> **2026-09-28**:作者面迁移到 Document / Endpoint / Resource。C1 已由 ADR 0007 修订。下文保留作迁移对照,**不是**现行推荐 API。
|
||||
|
||||
---
|
||||
|
||||
## 0. 一句话
|
||||
|
||||
`ext/web` 用 **GFM 表格 + Marqdo 类方法** 描述动态网站:表仍是字典/列表嵌套;类方法把表装配成可渲染页面。
|
||||
**不改 Marqdo 核心语法**;扩展库存在的理由,正是让「文档即代码」在网站场景下成立。
|
||||
**现行**:`.mq.md` Artifact(`type: web|endpoint`)描述页面与交互;见 [ext-web-artifact.md](ext-web-artifact.md)。
|
||||
|
||||
**历史(废止)**:`ext/web` 曾用 GFM 表格 + `# page`/`# app` 类方法拼装站点。该模型因 God Object / 碎片 DSL / 隐式路由被破坏性替换。
|
||||
|
||||
---
|
||||
|
||||
@@ -41,13 +44,14 @@
|
||||
|
||||
| # | 约束 |
|
||||
|---|------|
|
||||
| C1 | **禁止**为 web 改动 Marqdo 核心:单元格求值、import、点号值读取等保持不变 |
|
||||
| C2 | 作者面**禁止** `json.parse` / `json.set` 袋胶水、手写 part JSON、手写 assemble 袋 |
|
||||
| C3 | 能力以 **`#` 类 + `##` 方法** 暴露;**英文库文件只用英文名,中文库文件只用中文名**(见 [stdlib-i18n.md](stdlib-i18n.md));同一 `.mq.md` 内禁止中英 API 混排 |
|
||||
| C4 | 首页在 **`index.mq.md`**:页面表在此;可复用片段进 `components/`;主体可就地写 |
|
||||
| C5 | **旧有网络扩展库全部废弃**:`plugins/web`、`ext/web/**`(含现网示例/gold 中依赖旧 API 者)评审通过后**删除或清空后重写**;禁止在旧代码上打补丁演进。**落实**:原生层 Go 全量重写见 [ext-web-go-rewrite.md](ext-web-go-rewrite.md);作者面 ABI 名保持兼容 |
|
||||
| C6 | `# db` / `# 数据库` 必须提供完整**增删改查**;列表查询英文方法名为 **`select`**(中文 **`查询`**);后台 `/admin` 与表单提交走同一套写库 API |
|
||||
| C7 | 用户输入经 `# form` / `# 表单`:字段表 + 校验表;**服务端校验必须在写库前执行**(见 §5.5) |
|
||||
| C1 | **修订(ADR 0007)**:核心可识别 Artifact `type: web\|endpoint`(及 ZH);**不**新增 CORE_CONSTRUCTS 标记;单元格求值 / import 句法不变;装配语义仍在 ext + plugin。旧文「禁止为 web 改核心」作废 |
|
||||
| C2 | 作者面**禁止** `json.parse` / `json.set` 袋胶水(现行见 ext-web-artifact A2) |
|
||||
| C3 | 中英分文件;同文件禁止混 API(现行 A3) |
|
||||
| C4 | **废止**「页面表 + compose」心智 → Document Artifact + `pages/` · `api/` |
|
||||
| C5 | 破坏性重写作者面(ADR 0007);原生 Go 演进见 [ext-web-go-rewrite.md](ext-web-go-rewrite.md) |
|
||||
| C6 | DB 迁至 **`ext/data`**;CRUD 仍须完整(`select` / `查询`) |
|
||||
| C7 | 表单校验仍须在写库前执行;挂载经 declared Endpoint / system `/_form`(inspect 可见) |
|
||||
| A1–A8 | **现行硬约束**见 [ext-web-artifact.md](ext-web-artifact.md) §9 |
|
||||
|
||||
---
|
||||
|
||||
|
||||
+2182
File diff suppressed because it is too large.
Load diff
@@ -1,19 +1,22 @@
|
||||
# 第 14 章:网络与 Web 扩展
|
||||
|
||||
Marqdo 的网络能力分两层:**标准库 `lib/net`**(HTTP 客户端、cookie / multipart 解析)与**官方扩展 `ext/web`**(网页应用、数据库、表单、登录鉴权、WebSocket)。分层的依据是「代码即文档」的可读性——基础、通用、低依赖的进标准库;领域性强、依赖重、只在 Web 场景才用的进扩展。
|
||||
> **现行作者面(2026-09-28 · ADR 0007)**:Document / Endpoint / Resource —— 见 [ext-web-artifact.md](../design/ext-web-artifact.md)。
|
||||
> 下文若仍出现 `compose_*` / `app.configure` / `web.db` 同文件混写,视为**历史示例**;DB → `ext/data`,鉴权 → `ext/security`,实时 → `ext/net`。
|
||||
|
||||
Marqdo 的网络能力分两层:**标准库 `lib/net`**(HTTP 客户端、cookie / multipart 解析)与**官方扩展 `ext/web`**(Document/Endpoint facade + 拆分后的 data/security/net)。分层的依据是「代码即文档」。
|
||||
|
||||
## 14.1 概览
|
||||
|
||||
| 能力 | 位置 | 典型函数 |
|
||||
| 能力 | 位置 | 典型 API |
|
||||
|------|------|----------|
|
||||
| HTTP(S) 客户端 | `lib/net` | `http_get` / `http_post` / `http_request` |
|
||||
| Cookie 解析 | `lib/net` | `cookie_parse` |
|
||||
| multipart/form-data 解析 | `lib/net` | `multipart_parse` |
|
||||
| 网页应用 / 路由 / 静态 | `ext/web` | `web.page` / `web.app` |
|
||||
| SQLite 数据库 | `ext/web` | `web.db` |
|
||||
| 表单 | `ext/web` | `web.form` |
|
||||
| 登录鉴权(session) | `ext/web` | `web.auth` / `app.auth` |
|
||||
| WebSocket 客户端 / 端点 | `ext/web` | `web.ws` / `app.route_ws` |
|
||||
| Cookie / multipart | `lib/net` | `cookie_parse` / `multipart_parse` |
|
||||
| Document / Endpoint | `ext/web` | `type: web\|endpoint` · `web.serve` · `web.render` · `web.inspect` |
|
||||
| View 装配 | `ext/web` | `|type|slot|value|attrs|style|` → `web.render` |
|
||||
| 数据库 | `ext/data` | `db` CRUD / txn |
|
||||
| 表单 | `ext/data` | `form` |
|
||||
| 鉴权 / RBAC / OIDC | `ext/security` | `auth` · `rbac` · `oidc` |
|
||||
| WebSocket | `ext/net` | `websocket` |
|
||||
|
||||
```bash
|
||||
# 运行使用 ext/web 的程序前,先安装扩展
|
||||
|
||||
@@ -1,54 +1,28 @@
|
||||
# examples/marqdo-blog
|
||||
|
||||
一个用 Marqdo 的 `ext/web` 网络扩展库搭建的博客系统示例:美观大气的现代化主题、
|
||||
SQLite 驱动的文章/标签、动态路由、WebSocket 实时终端、以及受会话门禁保护的后台 CRUD。
|
||||
Marqdo **Web Artifact** 示例(ADR 0007):`.mq.md` 即文档、即路由、即页面。
|
||||
|
||||
## 运行
|
||||
|
||||
```bash
|
||||
cargo build -p marqdo_plugin_web
|
||||
cargo run -- examples/marqdo-blog/index.mq.md
|
||||
bash scripts/build-web-plugin.sh
|
||||
# 若 ~/.marqdo/ext 仍是旧 compose_* 面:export MARQDO_EXT=$PWD/ext
|
||||
cargo run -- run examples/marqdo-blog/serve.mq.md
|
||||
```
|
||||
|
||||
打开 http://127.0.0.1:18085/:
|
||||
打开 http://127.0.0.1:18081/:
|
||||
|
||||
- `/` — 首页:文章卡片网格 + 实时 WebSocket 终端
|
||||
- `/post/{slug}` — 动态路由渲染单篇文章(标题/日期/标签/正文)
|
||||
- `/tags` — 标签归档;`/tag/{slug}` 查看某标签下的文章
|
||||
- `/about` — 关于页
|
||||
- `/admin` — 会话门禁后台,登录 `admin` / `marqdo`,可增删改文章与标签
|
||||
- `/live` — WebSocket 回显端点
|
||||
- `/static/*` — 静态资源(`public/` 下的 `live.js`、favicon、logo)
|
||||
- `/favicon.ico` — 站点图标(`应用.图标` 表装配)
|
||||
| 路径 | 来源 |
|
||||
|------|------|
|
||||
| `/` | `index.mq.md`(`type: web` / 本例中文 `serve` 扫描) |
|
||||
| `/about` | `pages/about.mq.md`(`类型: 网页`) |
|
||||
| `/api/ping` | `api/ping.mq.md`(`type: endpoint`) |
|
||||
|
||||
## 设计亮点(文档即代码)
|
||||
## 设计(代码即文档)
|
||||
|
||||
- **样式即数据表格,装配即函数**(`styles/theme.mq.md`):
|
||||
主题不再是一大段手写 CSS 字符串,而是由一张张 GFM 样式表组成 ——
|
||||
`|选择器|属性|值|` 规则行(同一选择器多行自动合并成一条规则),
|
||||
响应式用 `|媒体|选择器|属性|值|` 分组进 `@media` 块。
|
||||
每个 `## 段`(基础/顶栏/侧栏/主体/卡片/页脚/表单/响应式)导出一张样式表,
|
||||
`## 全局` 用 `网页.样式装配` 函数把每张表装配成 CSS 文本,再 `text.str_join` 拼成完整样式表,
|
||||
最后经 `页面.样式` 注入页面。样式保持可读的数据表格,不写胶水代码。
|
||||
- **图标 / 头资源 / 图片装配**(W8):`应用.图标` 表挂 `/favicon.ico` 与 SVG;
|
||||
`页面.头装配` 写 apple-touch-icon;`页面.图片装配` 把 logo 表注入主区(`mq-images`)。
|
||||
含 `/` 的路径与 MIME 单元格需加引号(如 `"/static/logo.svg"`、`"image/png"`)。
|
||||
- **页面 = 组件装配 + 主体绑定**(`index.mq.md`):
|
||||
导航/侧栏/页脚用 `|组件|样式|` 表装配,文章列表用 `|属性|值|` 绑定 SQLite 字段。
|
||||
- **动态路由**:`/post/{slug}` 的 `slug` 注入查询条件,`页面.详情` 把首行渲染成文章。
|
||||
- **数据模型**(`db/`):`schema.mq.md` 定义 `posts`/`tags`/`post_tags` 三张表,
|
||||
`seed.mq.md` 提供种子数据,`index.mq.md` 幂等建表 + 灌数据。
|
||||
- **Document** — frontmatter `type`/`类型` + Markdown 正文。
|
||||
- **Endpoint** — `type: endpoint` + 可执行正文。
|
||||
- **发现** — `网页.服务` / `web.serve root=` 扫描目录内 Artifact。
|
||||
- **Resource** — DB 等见 `ext/data`(本示例入口以 Document 为主)。
|
||||
|
||||
## 冒烟测试
|
||||
|
||||
服务器启动后(端口 18085),运行:
|
||||
|
||||
```bash
|
||||
bash examples/marqdo-blog/smoke.sh
|
||||
```
|
||||
|
||||
覆盖:首页/卡片/主题 CSS/媒体查询、静态资源、动态路由详情、标签归档、鉴权门禁、
|
||||
登录会话、后台表单、WebSocket 回显。全部通过时输出 `通过 N / N`。
|
||||
|
||||
可从仓库根目录或本目录运行:相对 `static_dir`(`public`)与相对数据库路径
|
||||
(`data/marqdo-blog.db`)都按**入口脚本所在目录**解析,不依赖终端工作目录。
|
||||
规范:[ext-web-artifact.md](../../doc/design/ext-web-artifact.md) · ADR [0007](../../doc/adr/0007-web-document-endpoint.md)。
|
||||
@@ -0,0 +1,9 @@
|
||||
---
|
||||
type: endpoint
|
||||
method: GET
|
||||
path: /api/ping
|
||||
request: none
|
||||
response: json
|
||||
---
|
||||
|
||||
Ping endpoint — documentation is the API.
|
||||
@@ -1,131 +1,26 @@
|
||||
---
|
||||
type: web
|
||||
title: Marqdo 博客
|
||||
description: 用 web 扩展库搭建的博客系统示例:首页列表、动态文章详情、标签归档、登录门禁后台。
|
||||
route: /
|
||||
method: GET
|
||||
description: >-
|
||||
Document Artifact 示例(ADR 0007):首页即文档。
|
||||
子页/API 见 pages/ 与 api/;入口可 web.serve 扫描注册。
|
||||
导入 网页:ext/web/网页.mq.md
|
||||
import theme:styles/theme.mq.md
|
||||
import nav:components/nav.mq.md
|
||||
import side:components/side.mq.md
|
||||
import foot:components/foot.mq.md
|
||||
import db:db/index.mq.md
|
||||
---
|
||||
|
||||
# main
|
||||
# Marqdo 博客
|
||||
|
||||
`首页` =
|
||||
可执行文档即网页。本站用 Artifact Metadata 声明路由,正文即内容。
|
||||
|
||||
| 组件 | 样式 |
|
||||
|------|------|
|
||||
| nav.`导航` | |
|
||||
| side.`侧栏` | |
|
||||
| foot.`页脚` | |
|
||||
## 文章
|
||||
|
||||
`列表` =
|
||||
从 `data_source`(元信息)或库表加载列表;本示例入口直接服务文档页。
|
||||
|
||||
| 属性 | 值 | 样式 |
|
||||
|------|-----|------|
|
||||
| title | posts.title | |
|
||||
| body | posts.summary | |
|
||||
| meta | posts.created_at | |
|
||||
| tag | posts.tag | |
|
||||
| href | posts.slug | |
|
||||
---
|
||||
|
||||
`详情绑定` =
|
||||
运行(仓库根目录):
|
||||
|
||||
| 属性 | 值 | 样式 |
|
||||
|------|-----|------|
|
||||
| title | posts.title | |
|
||||
| meta | posts.created_at | |
|
||||
| tag | posts.tag | |
|
||||
| body | posts.content | |
|
||||
|
||||
`标签列表` =
|
||||
|
||||
| 属性 | 值 | 样式 |
|
||||
|------|-----|------|
|
||||
| title | tags.name | |
|
||||
| meta | 点击查看该标签下的文章 | |
|
||||
| href | tags.slug | |
|
||||
|
||||
`文章条件` =
|
||||
|
||||
| 字段 | 操作 | 值 |
|
||||
|------|------|-----|
|
||||
| slug | = | {slug} |
|
||||
|
||||
`标签条件` =
|
||||
|
||||
| 字段 | 操作 | 值 |
|
||||
|------|------|-----|
|
||||
| tag | = | {slug} |
|
||||
|
||||
`管理员` =
|
||||
|
||||
| 行 | 用户名 | 密码 |
|
||||
|----|--------|------|
|
||||
| 1 | admin | marqdo |
|
||||
|
||||
`站点图标` =
|
||||
|
||||
| 路径 | 关系 | 类型 | 尺寸 | 地址 |
|
||||
|------|------|------|------|------|
|
||||
| "public/favicon.png" | icon | "image/png" | 32x32 | "/favicon.ico" |
|
||||
| "public/favicon.svg" | icon | "image/svg+xml" | any | "/static/favicon.svg" |
|
||||
|
||||
`头资源` =
|
||||
|
||||
| 关系 | 地址 | 类型 |
|
||||
|------|------|------|
|
||||
| apple-touch-icon | "/static/favicon.png" | "image/png" |
|
||||
|
||||
`品牌图` =
|
||||
|
||||
| 源 | 替代 | 类 | 链接 | 宽度 | 加载 |
|
||||
|----|------|----|------|------|------|
|
||||
| "/static/logo.svg" | Marqdo | brand-logo | "/" | 40 | eager |
|
||||
|
||||
**store = > db.打开**
|
||||
|
||||
**首页CSS = > theme.全局**
|
||||
|
||||
**page = > 网页.页面 标题="Marqdo 博客" 引言="<h1>Marqdo 博客</h1><p>用 web 扩展库搭建的博客:表格装配页面、SQLite 数据、动态路由、实时终端。</p><h2 id=\"live\">实时终端</h2><p id=\"live-status\" class=\"live-pill\">connecting…</p><input id=\"live-msg\" placeholder=\"输入一条消息…\"><button id=\"live-send\" disabled>发送</button><div id=\"live-out\"></div><script src=\"/static/live.js\"></script>"**
|
||||
**page = > page.组件装配 组件=`首页`**
|
||||
**page = > page.主体装配 主体=`列表`**
|
||||
**page = > page.排序 排序="-created_at"**
|
||||
**page = > page.样式 样式=`首页CSS`**
|
||||
**page = > page.头装配 表=`头资源`**
|
||||
**page = > page.图片装配 表=`品牌图`**
|
||||
|
||||
**about = > 网页.页面 标题="关于" 引言="<h1>关于本站</h1><p>一个用 Marqdo 的 web 扩展库(ext/web)写成的博客系统。</p><p>它演示了:GFM 表格装配导航与侧栏、SQLite 驱动的主体绑定、动态路由 /post/{slug}、标签归档、以及受 session 保护的后台 CRUD。</p>"**
|
||||
**about = > about.组件装配 组件=`首页`**
|
||||
**about = > about.样式 样式=`首页CSS`**
|
||||
|
||||
**post = > 网页.页面 标题="文章"**
|
||||
**post = > post.组件装配 组件=`首页`**
|
||||
**post = > post.主体装配 主体=`详情绑定`**
|
||||
**post = > post.查询条件 条件=`文章条件`**
|
||||
**post = > post.详情 详情=True**
|
||||
**post = > post.样式 样式=`首页CSS`**
|
||||
|
||||
**tags = > 网页.页面 标题="标签归档" 引言="<h1>标签归档</h1><p>点击标签查看该主题下的文章。</p>"**
|
||||
**tags = > tags.组件装配 组件=`首页`**
|
||||
**tags = > tags.主体装配 主体=`标签列表`**
|
||||
**tags = > tags.链接前缀 前缀="/tag/"**
|
||||
**tags = > tags.样式 样式=`首页CSS`**
|
||||
|
||||
**tagged = > 网页.页面 标题="标签"**
|
||||
**tagged = > tagged.组件装配 组件=`首页`**
|
||||
**tagged = > tagged.主体装配 主体=`列表`**
|
||||
**tagged = > tagged.查询条件 条件=`标签条件`**
|
||||
**tagged = > tagged.排序 排序="-created_at"**
|
||||
**tagged = > tagged.样式 样式=`首页CSS`**
|
||||
|
||||
**app = > 网页.应用 页面=page 数据库=store 后台=True 主机="127.0.0.1" 端口=18085**
|
||||
**app = > app.路由 路径="/about" 页面=about**
|
||||
**app = > app.路由 路径="/post/{slug}" 页面=post**
|
||||
**app = > app.路由 路径="/tags" 页面=tags**
|
||||
**app = > app.路由 路径="/tag/{slug}" 页面=tagged**
|
||||
**app = > app.静态 目录="public" 挂载="/static"**
|
||||
**app = > app.图标 表=`站点图标`**
|
||||
**app = > app.路由实时 路径="/live" 回显=True**
|
||||
**app = > app.鉴权 用户表=`管理员` 会话时长=3600**
|
||||
> `app`.监听
|
||||
```text
|
||||
marqdo run examples/marqdo-blog/serve.mq.md
|
||||
```
|
||||
@@ -0,0 +1,10 @@
|
||||
---
|
||||
类型: 网页
|
||||
路由: /about
|
||||
方法: GET
|
||||
标题: 关于
|
||||
---
|
||||
|
||||
# 关于 Marqdo
|
||||
|
||||
Marqdo 是可执行文档语言:文档即程序,程序即知识。
|
||||
@@ -0,0 +1,9 @@
|
||||
---
|
||||
title: marqdo-blog serve
|
||||
description: Scan Artifact .mq.md under this directory and listen (ADR 0007).
|
||||
导入 网页:ext/web/网页.mq.md
|
||||
---
|
||||
|
||||
# main
|
||||
|
||||
> 网页.服务 根="." 主机="127.0.0.1" 端口=18081
|
||||
@@ -1,20 +1,14 @@
|
||||
# web-client-site(路线 D)
|
||||
# examples/web-client-site
|
||||
|
||||
服务端 `ext/web` + 浏览器 WASM 会话;**作者零业务 JS**。
|
||||
SSR **Document Artifact** + `web.client_embed` auto-mount(零作者 JS)。ADR 0007。
|
||||
|
||||
```bash
|
||||
# 仓库根
|
||||
cargo build -p marqdo --release
|
||||
cargo build --release -p marqdo_plugin_web
|
||||
./target/release/marqdo ext add web
|
||||
|
||||
# 构建 WASM + bridge 到本示例 static/
|
||||
./target/release/marqdo wasm build -o examples/web-client-site/static
|
||||
# 保留 client.mq.md(wasm build 只写入 wasm/bridge)
|
||||
|
||||
cd examples/web-client-site
|
||||
marqdo run index.mq.md
|
||||
# 打开 http://127.0.0.1:18090/
|
||||
bash scripts/build-web-plugin.sh
|
||||
export MARQDO_EXT=$PWD/ext # 若本机 ~/.marqdo/ext 未同步
|
||||
marqdo wasm build -o examples/web-client-site/static
|
||||
cargo run -- run examples/web-client-site/serve.mq.md
|
||||
```
|
||||
|
||||
`index.mq.md` 用 `web.client_embed source="/static/client.mq.md"` 注入自启脚本;交互在 `static/client.mq.md`。
|
||||
- `index.mq.md` — `type: web` 文档页
|
||||
- `serve.mq.md` — `web.serve` + `static_dir`
|
||||
- `static/client.mq.md` — `lib/browser` wire(不变)
|
||||
@@ -1,19 +1,14 @@
|
||||
---
|
||||
title: web-client-site
|
||||
description: SSR shell + client_embed auto-mount; author zero JS (route D)
|
||||
type: web
|
||||
title: Marqdo client site
|
||||
route: /
|
||||
method: GET
|
||||
description: SSR Document + client_embed auto-mount; author zero JS (ADR 0007).
|
||||
import web:ext/web/web.mq.md
|
||||
---
|
||||
|
||||
# main
|
||||
# Marqdo client site
|
||||
|
||||
Server page with a counter UI. Client logic lives in `static/client.mq.md`
|
||||
(loaded by official bridge via `client_embed`).
|
||||
SSR shell with WASM session. Client logic lives in `static/client.mq.md`.
|
||||
|
||||
**`embed` = > web.client_embed bridge="/static/marqdo-bridge.js" wasm="/static/marqdo_wasm.wasm" source="/static/client.mq.md" boot=True**
|
||||
|
||||
**`intro` = "<h1>Marqdo client site</h1><p>SSR + WASM session. No author JS.</p><div id=\"count\">0</div><p><button id=\"bump\" type=\"button\" disabled>Bump</button> <button id=\"reset\" type=\"button\" disabled>Reset</button></p><pre id=\"log\">booting…</pre>" + embed**
|
||||
|
||||
**page = > web.page title="Marqdo client site" intro=intro**
|
||||
**app = > web.app page=page host="127.0.0.1" port=18090**
|
||||
**app = > app.static dir="static" mount="/static"**
|
||||
> `app`.listen
|
||||
To serve with static assets, run `serve.mq.md` in this directory.
|
||||
@@ -0,0 +1,10 @@
|
||||
---
|
||||
title: web-client-site serve
|
||||
import web:ext/web/web.mq.md
|
||||
---
|
||||
|
||||
# main
|
||||
|
||||
**`embed` = > web.client_embed source="/static/client.mq.md"**
|
||||
> print text=embed-ready
|
||||
> web.serve root="." host="127.0.0.1" port=18090 static_dir="static"
|
||||
@@ -0,0 +1,60 @@
|
||||
---
|
||||
title: ext/data/cache
|
||||
description: Cache Resource (ADR 0007).
|
||||
import plugin:lib/plugin.mq.md
|
||||
import sys:lib/sys.mq.md
|
||||
import table:lib/table.mq.md
|
||||
---
|
||||
|
||||
## _load
|
||||
|
||||
**p = > plugin.native_path name="web"**
|
||||
1. `p`
|
||||
> plugin.load path=`p`
|
||||
2. *
|
||||
> print text=ext/data: native web plugin not found
|
||||
> sys.exit code=1
|
||||
****
|
||||
|
||||
# cache
|
||||
+ `url`="memory:"
|
||||
|
||||
Key–value cache. Use `memory:` for in-process (tests / single process) or `redis://host:6379/0` for Redis.
|
||||
|
||||
> _load
|
||||
*> web_cache_new url=`url`*
|
||||
|
||||
## get
|
||||
+ `key`
|
||||
|
||||
**url = [url](self)**
|
||||
*> web_cache_get url=`url` key=`key`*
|
||||
|
||||
## set
|
||||
+ `key`
|
||||
+ `value`
|
||||
+ `ttl`=None
|
||||
|
||||
Optional `ttl` is seconds until expiry.
|
||||
|
||||
**url = [url](self)**
|
||||
*> web_cache_set url=`url` key=`key` value=`value` ttl=`ttl`*
|
||||
|
||||
## del
|
||||
+ `key`
|
||||
|
||||
**url = [url](self)**
|
||||
*> web_cache_del url=`url` key=`key`*
|
||||
|
||||
## exists
|
||||
+ `key`
|
||||
|
||||
**url = [url](self)**
|
||||
*> web_cache_exists url=`url` key=`key`*
|
||||
|
||||
## ttl
|
||||
+ `key`
|
||||
|
||||
**url = [url](self)**
|
||||
*> web_cache_ttl url=`url` key=`key`*
|
||||
|
||||
@@ -0,0 +1,238 @@
|
||||
---
|
||||
title: ext/data/db
|
||||
description: Database Resource — CRUD, txn, migrate, FTS (ADR 0007).
|
||||
import plugin:lib/plugin.mq.md
|
||||
import sys:lib/sys.mq.md
|
||||
import table:lib/table.mq.md
|
||||
---
|
||||
|
||||
## _load
|
||||
|
||||
**p = > plugin.native_path name="web"**
|
||||
1. `p`
|
||||
> plugin.load path=`p`
|
||||
2. *
|
||||
> print text=ext/data: native web plugin not found
|
||||
> sys.exit code=1
|
||||
****
|
||||
|
||||
# db
|
||||
+ `url`="sqlite:site.db"
|
||||
|
||||
Open a database handle. URL schemes: `sqlite:path` (default), `postgres://…` / `postgresql://…` (same CRUD methods).
|
||||
|
||||
> _load
|
||||
*> web_db_new url=`url`*
|
||||
|
||||
## init
|
||||
+ `name`
|
||||
+ `fields`
|
||||
|
||||
Create a table from a schema table. Optional columns: `唯一`/`unique`, `索引`/`index` (creates UNIQUE / INDEX), `外键`/`fk`/`references` (e.g. `posts.id` or `posts(id)`). Columns named `created_at` / `updated_at` are filled automatically on insert/update when present.
|
||||
|
||||
**url = [url](self)**
|
||||
*> web_db_init url=`url` name=`name` fields=`fields`*
|
||||
|
||||
## insert
|
||||
+ `table`
|
||||
+ `rows`
|
||||
+ `txn`=None
|
||||
|
||||
**url = [url](self)**
|
||||
*> web_db_insert url=`url` table=`table` rows=`rows` txn=`txn`*
|
||||
|
||||
## select
|
||||
+ `table`
|
||||
+ `where`=None
|
||||
+ `limit`=200
|
||||
+ `order`=None
|
||||
+ `txn`=None
|
||||
|
||||
Simple filters: one-row map of column→value (AND `=`), or rows `|字段|操作|值|` (`=` `!=` `>` `>=` `<` `<=` `like` `in` `between` `is null`; add `|或|` = `是` to join a row with `OR`). `order` is a column name with optional `-` prefix for descending (`"created_at"`, `"-created_at"`), comma-separated for multiple keys. Pass `txn` to read inside an open transaction. For pages (with a total), use `paginate`.
|
||||
|
||||
**url = [url](self)**
|
||||
**r = > web_db_select url=`url` table=`table` where=`where` limit=`limit` order=`order` offset=None txn=`txn`**
|
||||
*[rows](r)*
|
||||
|
||||
## paginate
|
||||
+ `table`
|
||||
+ `where`=None
|
||||
+ `limit`=200
|
||||
+ `order`=None
|
||||
+ `跳过`=0
|
||||
+ `txn`=None
|
||||
|
||||
Like `select` but returns `{ rows, total }` — the total counts rows matching `where` regardless of `limit`/`跳过`, so you can render `上一页 / 下一页`. Set `跳过` to the number of rows to skip (e.g. page 2 with 10 per page ⇒ `跳过`=10).
|
||||
|
||||
**url = [url](self)**
|
||||
*> web_db_select url=`url` table=`table` where=`where` limit=`limit` order=`order` offset=`跳过` txn=`txn`*
|
||||
|
||||
## get
|
||||
+ `table`
|
||||
+ `id`
|
||||
+ `txn`=None
|
||||
|
||||
**url = [url](self)**
|
||||
*> web_db_get url=`url` table=`table` id=`id` txn=`txn`*
|
||||
|
||||
## update
|
||||
+ `table`
|
||||
+ `id`
|
||||
+ `row`
|
||||
+ `txn`=None
|
||||
|
||||
**url = [url](self)**
|
||||
*> web_db_update url=`url` table=`table` id=`id` row=`row` txn=`txn`*
|
||||
|
||||
## delete
|
||||
+ `table`
|
||||
+ `id`
|
||||
+ `txn`=None
|
||||
|
||||
**url = [url](self)**
|
||||
*> web_db_delete url=`url` table=`table` id=`id` txn=`txn`*
|
||||
|
||||
## exec
|
||||
+ `sql`
|
||||
+ `args`=None
|
||||
+ `txn`=None
|
||||
|
||||
**url = [url](self)**
|
||||
*> web_db_exec url=`url` sql=`sql` args=`args` txn=`txn`*
|
||||
|
||||
## query
|
||||
+ `sql`
|
||||
+ `args`=None
|
||||
+ `txn`=None
|
||||
|
||||
Run bare SQL and return the result set — count / join / group / subqueries. Returns `{ rows, count }`.
|
||||
|
||||
**url = [url](self)**
|
||||
*> web_db_query url=`url` sql=`sql` args=`args` txn=`txn`*
|
||||
|
||||
## count
|
||||
+ `table`
|
||||
+ `where`=None
|
||||
+ `txn`=None
|
||||
|
||||
Count rows matching a `where` filter (same syntax as `select`). Returns a number.
|
||||
|
||||
**url = [url](self)**
|
||||
**r = > web_db_count url=`url` table=`table` where=`where` txn=`txn`**
|
||||
*[count](r)*
|
||||
|
||||
## migrate
|
||||
+ `steps`
|
||||
|
||||
Apply versioned SQL migrations. `steps` is a `|version|sql|` / `|版本|SQL|` table. Applied versions are recorded in `_marqdo_migrations`. Re-running is a no-op for already-applied versions. SQLite only.
|
||||
|
||||
**url = [url](self)**
|
||||
*> web_db_migrate url=`url` steps=`steps`*
|
||||
|
||||
## fts
|
||||
+ `table`
|
||||
+ `columns`
|
||||
+ `name`=None
|
||||
|
||||
Create an FTS5 index on `table` for the listed content columns (CSV string or list). Default FTS name is `{table}_fts`. Keeps the index in sync via triggers. Requires integer `id` PK. SQLite only.
|
||||
|
||||
**url = [url](self)**
|
||||
*> web_db_fts_create url=`url` table=`table` columns=`columns` name=`name`*
|
||||
|
||||
## search
|
||||
+ `table`
|
||||
+ `q`
|
||||
+ `limit`=20
|
||||
+ `name`=None
|
||||
|
||||
Full-text search (`MATCH`) against the FTS5 index from `fts`. Returns `{ rows, count }` with a `rank` column (bm25). SQLite only.
|
||||
|
||||
**url = [url](self)**
|
||||
*> web_db_search url=`url` table=`table` q=`q` limit=`limit` name=`name`*
|
||||
|
||||
## 事务
|
||||
|
||||
Begin a transaction: borrows the pooled connection exclusively and returns a
|
||||
`txn` handle. Write inside it, then `提交` (commit) or `回滚` (roll back).
|
||||
Every statement runs on the same connection, so a batch is atomic.
|
||||
|
||||
**url = [url](self)**
|
||||
*> web_db_begin url=`url`*
|
||||
|
||||
# txn
|
||||
+ `txn`
|
||||
+ `url`
|
||||
|
||||
A transaction handle from `db.事务`. All CRUD here runs on the transaction's
|
||||
connection; finish with `提交` or `回滚`.
|
||||
|
||||
*self*
|
||||
|
||||
## insert
|
||||
+ `table`
|
||||
+ `rows`
|
||||
|
||||
**url = [url](self)**
|
||||
**txn = [txn](self)**
|
||||
*> web_db_insert url=`url` table=`table` rows=`rows` txn=`txn`*
|
||||
|
||||
## select
|
||||
+ `table`
|
||||
+ `where`=None
|
||||
+ `limit`=200
|
||||
+ `order`=None
|
||||
|
||||
Same filters as `db.select`; runs inside the transaction.
|
||||
|
||||
**url = [url](self)**
|
||||
**txn = [txn](self)**
|
||||
**r = > web_db_select url=`url` table=`table` where=`where` limit=`limit` order=`order` offset=None txn=`txn`**
|
||||
*[rows](r)*
|
||||
|
||||
## get
|
||||
+ `table`
|
||||
+ `id`
|
||||
|
||||
**url = [url](self)**
|
||||
**txn = [txn](self)**
|
||||
*> web_db_get url=`url` table=`table` id=`id` txn=`txn`*
|
||||
|
||||
## update
|
||||
+ `table`
|
||||
+ `id`
|
||||
+ `row`
|
||||
|
||||
**url = [url](self)**
|
||||
**txn = [txn](self)**
|
||||
*> web_db_update url=`url` table=`table` id=`id` row=`row` txn=`txn`*
|
||||
|
||||
## delete
|
||||
+ `table`
|
||||
+ `id`
|
||||
|
||||
**url = [url](self)**
|
||||
**txn = [txn](self)**
|
||||
*> web_db_delete url=`url` table=`table` id=`id` txn=`txn`*
|
||||
|
||||
## exec
|
||||
+ `sql`
|
||||
+ `args`=None
|
||||
|
||||
**url = [url](self)**
|
||||
**txn = [txn](self)**
|
||||
*> web_db_exec url=`url` sql=`sql` args=`args` txn=`txn`*
|
||||
|
||||
## 提交
|
||||
|
||||
Commit the transaction and return its connection to the pool.
|
||||
|
||||
**txn = [txn](self)**
|
||||
*> web_db_commit txn=`txn`*
|
||||
|
||||
## 回滚
|
||||
|
||||
Roll the transaction back (undo every write) and return its connection.
|
||||
|
||||
**txn = [txn](self)**
|
||||
*> web_db_rollback txn=`txn`*
|
||||
|
||||
@@ -0,0 +1,67 @@
|
||||
---
|
||||
title: ext/data/form
|
||||
description: Form Resource — fields, validate, submit (ADR 0007).
|
||||
import plugin:lib/plugin.mq.md
|
||||
import sys:lib/sys.mq.md
|
||||
import table:lib/table.mq.md
|
||||
---
|
||||
|
||||
## _load
|
||||
|
||||
**p = > plugin.native_path name="web"**
|
||||
1. `p`
|
||||
> plugin.load path=`p`
|
||||
2. *
|
||||
> print text=ext/data: native web plugin not found
|
||||
> sys.exit code=1
|
||||
****
|
||||
|
||||
# form
|
||||
+ `table`=None
|
||||
+ `action`=insert
|
||||
+ `id`=None
|
||||
|
||||
Field table + rules table; submit writes through `# db`.
|
||||
|
||||
> _load
|
||||
*> web_form_new table=`table` action=`action` id=`id`*
|
||||
|
||||
## fields
|
||||
+ `fields`
|
||||
|
||||
*> web_form_fields form=`self` fields=`fields`*
|
||||
|
||||
## rules
|
||||
+ `rules`
|
||||
|
||||
*> web_form_rules form=`self` rules=`rules`*
|
||||
|
||||
## labels
|
||||
+ `submit`="Submit"
|
||||
+ `cancel`="cancel"
|
||||
+ `cancel_href`=""
|
||||
|
||||
Localized submit / cancel copy for rendered forms.
|
||||
|
||||
*> web_form_labels form=`self` submit=`submit` cancel=`cancel` cancel_href=`cancel_href`*
|
||||
|
||||
## validate
|
||||
+ `rules`=None
|
||||
+ `data`
|
||||
|
||||
*> web_form_validate form=`self` rules=`rules` data=`data`*
|
||||
|
||||
## render
|
||||
+ `id`=form
|
||||
+ `data`=None
|
||||
+ `errors`=None
|
||||
|
||||
*> web_form_render form=`self` id=`id` data=`data` errors=`errors`*
|
||||
|
||||
## submit
|
||||
+ `data`
|
||||
+ `db`
|
||||
|
||||
**url = [url](db)**
|
||||
*> web_form_submit form=`self` data=`data` url=`url`*
|
||||
|
||||
@@ -0,0 +1,86 @@
|
||||
---
|
||||
title: ext/data/storage
|
||||
description: Object storage Resource (ADR 0007).
|
||||
import plugin:lib/plugin.mq.md
|
||||
import sys:lib/sys.mq.md
|
||||
import table:lib/table.mq.md
|
||||
---
|
||||
|
||||
## _load
|
||||
|
||||
**p = > plugin.native_path name="web"**
|
||||
1. `p`
|
||||
> plugin.load path=`p`
|
||||
2. *
|
||||
> print text=ext/data: native web plugin not found
|
||||
> sys.exit code=1
|
||||
****
|
||||
|
||||
# storage
|
||||
+ `url`="file:data/blobs"
|
||||
|
||||
Object storage. `file:dir` stores blobs on disk (offline / gold). `s3://bucket?endpoint=http://127.0.0.1:9000&access_key=…&secret_key=…` talks to MinIO / S3.
|
||||
|
||||
> _load
|
||||
*> web_storage_new url=`url`*
|
||||
|
||||
## put
|
||||
+ `key`
|
||||
+ `body`=None
|
||||
+ `path`=None
|
||||
+ `content_type`="application/octet-stream"
|
||||
|
||||
Provide either `body` (text) or `path` (local file to upload).
|
||||
|
||||
**url = [url](self)**
|
||||
*> web_storage_put url=`url` key=`key` body=`body` path=`path` content_type=`content_type`*
|
||||
|
||||
## get
|
||||
+ `key`
|
||||
|
||||
**url = [url](self)**
|
||||
*> web_storage_get url=`url` key=`key`*
|
||||
|
||||
## delete
|
||||
+ `key`
|
||||
|
||||
**url = [url](self)**
|
||||
*> web_storage_delete url=`url` key=`key`*
|
||||
|
||||
## list
|
||||
+ `prefix`=""
|
||||
|
||||
**url = [url](self)**
|
||||
*> web_storage_list url=`url` prefix=`prefix`*
|
||||
|
||||
# media
|
||||
+ `storage`=None
|
||||
|
||||
Offline helpers for upload validation and saving into `# storage` (also used by HTTP `app.upload`).
|
||||
|
||||
> _load
|
||||
*> web_media_new storage=`storage`*
|
||||
|
||||
## validate
|
||||
+ `filename`
|
||||
+ `content_type`="application/octet-stream"
|
||||
+ `size`
|
||||
+ `max_bytes`=5242880
|
||||
+ `types`=None
|
||||
|
||||
*> web_upload_validate filename=`filename` content_type=`content_type` size=`size` max_bytes=`max_bytes` types=`types`*
|
||||
|
||||
## save
|
||||
+ `path`
|
||||
+ `key`=None
|
||||
+ `content_type`="application/octet-stream"
|
||||
+ `prefix`=uploads/
|
||||
+ `storage`=None
|
||||
|
||||
**st = storage**
|
||||
1. `st` == None
|
||||
**st = [storage](self)**
|
||||
2. *
|
||||
|
||||
*> web_upload_save storage=`st` path=`path` key=`key` content_type=`content_type` prefix=`prefix`*
|
||||
|
||||
@@ -0,0 +1,31 @@
|
||||
---
|
||||
title: ext/net/http
|
||||
description: HTTP primitives surface for Web Runtime (ADR 0007). Prefer Document/Endpoint Artifacts over raw calls.
|
||||
import plugin:lib/plugin.mq.md
|
||||
import sys:lib/sys.mq.md
|
||||
---
|
||||
|
||||
## _load
|
||||
|
||||
**p = > plugin.native_path name="web"**
|
||||
1. `p`
|
||||
> plugin.load path=`p`
|
||||
2. *
|
||||
> print text=ext/net: native web plugin not found
|
||||
> sys.exit code=1
|
||||
****
|
||||
|
||||
## result
|
||||
+ `ok`
|
||||
+ `value`=None
|
||||
+ `error`=None
|
||||
|
||||
Unified Result map `{ok, value, error}`.
|
||||
|
||||
`out` =
|
||||
|
||||
| ok | value | error |
|
||||
|----|-------|-------|
|
||||
| `ok` | `value` | `error` |
|
||||
|
||||
*out*
|
||||
@@ -0,0 +1,9 @@
|
||||
---
|
||||
title: ext/net/url
|
||||
description: URL helpers (stdlib host wrappers). ADR 0007.
|
||||
---
|
||||
|
||||
## encode
|
||||
+ `text`
|
||||
|
||||
*> host_url_encode text=`text`*
|
||||
@@ -0,0 +1,41 @@
|
||||
---
|
||||
title: ext/net/websocket
|
||||
description: WebSocket client Resource (ADR 0007).
|
||||
import plugin:lib/plugin.mq.md
|
||||
import sys:lib/sys.mq.md
|
||||
import table:lib/table.mq.md
|
||||
---
|
||||
|
||||
## _load
|
||||
|
||||
**p = > plugin.native_path name="web"**
|
||||
1. `p`
|
||||
> plugin.load path=`p`
|
||||
2. *
|
||||
> print text=ext/net: native web plugin not found
|
||||
> sys.exit code=1
|
||||
****
|
||||
|
||||
# ws
|
||||
+ `timeout_sec`=30
|
||||
|
||||
WebSocket client helper.
|
||||
|
||||
> _load
|
||||
`out` =
|
||||
|
||||
| timeout_sec | _type |
|
||||
|-------------|-------|
|
||||
| `timeout_sec` | ws |
|
||||
|
||||
*out*
|
||||
|
||||
## connect
|
||||
+ `url`
|
||||
+ `message`=""
|
||||
+ `headers`=None
|
||||
|
||||
Single request–response: connect to `url`, send `message`, collect up to 256 server text replies (each up to 1 MiB), close. Transport errors and timeouts return `{ok:false, error}` instead of looking like an empty successful reply.
|
||||
|
||||
**timeout = [timeout_sec](self)**
|
||||
*> web_ws_connect url=`url` message=`message` headers=`headers` timeout_sec=`timeout`*
|
||||
@@ -0,0 +1,58 @@
|
||||
---
|
||||
title: ext/security/auth
|
||||
description: Auth Resource (ADR 0007).
|
||||
import plugin:lib/plugin.mq.md
|
||||
import sys:lib/sys.mq.md
|
||||
import table:lib/table.mq.md
|
||||
---
|
||||
|
||||
## _load
|
||||
|
||||
**p = > plugin.native_path name="web"**
|
||||
1. `p`
|
||||
> plugin.load path=`p`
|
||||
2. *
|
||||
> print text=ext/security: native web plugin not found
|
||||
> sys.exit code=1
|
||||
****
|
||||
|
||||
# auth
|
||||
+ `users`
|
||||
+ `session_ttl`=3600
|
||||
|
||||
Session/auth helper. Constructs a config object; `login` validates against the users table. To gate `/admin` on this app, use `app.auth users=…` instead.
|
||||
|
||||
> _load
|
||||
*> web_auth_new users=`users` session_ttl=`session_ttl`*
|
||||
|
||||
## login
|
||||
+ `username`
|
||||
+ `password`
|
||||
|
||||
Validate credentials against the users table and create a session. Returns `{ok, session_id, username, role}`.
|
||||
|
||||
**users = [users](self)**
|
||||
**ttl = [session_ttl](self)**
|
||||
*> web_auth_login username=`username` password=`password` users=`users` session_ttl=`ttl`*
|
||||
|
||||
## check
|
||||
+ `session_id`
|
||||
|
||||
Returns `{ok, username, role}` when the session is valid.
|
||||
|
||||
*> web_auth_check session_id=`session_id`*
|
||||
|
||||
## logout
|
||||
+ `session_id`
|
||||
|
||||
Destroy the session.
|
||||
|
||||
*> web_auth_logout session_id=`session_id`*
|
||||
|
||||
## hash_password
|
||||
+ `password`
|
||||
|
||||
Hash a plaintext password for storage in admin user tables (argon2id). Store the returned `hash` in the `password` column; login verifies automatically.
|
||||
|
||||
*> web_password_hash password=`password`*
|
||||
|
||||
@@ -0,0 +1,31 @@
|
||||
---
|
||||
title: ext/security/oidc
|
||||
description: OIDC attach helper for app handles (ADR 0007). Prefer declared auth metadata on Endpoints.
|
||||
import plugin:lib/plugin.mq.md
|
||||
import sys:lib/sys.mq.md
|
||||
---
|
||||
|
||||
## _load
|
||||
|
||||
**p = > plugin.native_path name="web"**
|
||||
1. `p`
|
||||
> plugin.load path=`p`
|
||||
2. *
|
||||
> print text=ext/security: native web plugin not found
|
||||
> sys.exit code=1
|
||||
****
|
||||
|
||||
## attach
|
||||
+ `app`
|
||||
+ `issuer`=None
|
||||
+ `client_id`
|
||||
+ `client_secret`
|
||||
+ `redirect_uri`
|
||||
+ `scopes`="openid profile email"
|
||||
+ `callback_path`=None
|
||||
+ `authorize_url`=None
|
||||
+ `token_url`=None
|
||||
+ `userinfo_url`=None
|
||||
|
||||
> _load
|
||||
*> web_app_oidc app=`app` issuer=`issuer` client_id=`client_id` client_secret=`client_secret` redirect_uri=`redirect_uri` scopes=`scopes` callback_path=`callback_path` authorize_url=`authorize_url` token_url=`token_url` userinfo_url=`userinfo_url`*
|
||||
@@ -0,0 +1,61 @@
|
||||
---
|
||||
title: ext/security/rbac
|
||||
description: RBAC Resource (ADR 0007).
|
||||
import plugin:lib/plugin.mq.md
|
||||
import sys:lib/sys.mq.md
|
||||
import table:lib/table.mq.md
|
||||
---
|
||||
|
||||
## _load
|
||||
|
||||
**p = > plugin.native_path name="web"**
|
||||
1. `p`
|
||||
> plugin.load path=`p`
|
||||
2. *
|
||||
> print text=ext/security: native web plugin not found
|
||||
> sys.exit code=1
|
||||
****
|
||||
|
||||
# rbac
|
||||
|
||||
Offline helpers for role ⊥ permission. Prefer `app.enable_rbac` + gates for HTTP; use these for scripts/tests.
|
||||
|
||||
## can
|
||||
+ `permissions`
|
||||
+ `needed`
|
||||
|
||||
Return `{ok, allowed}` — whether held permission CSV includes any of `needed` (CSV). Held `*` allows all.
|
||||
|
||||
> _load
|
||||
*> web_rbac_can permissions=`permissions` needed=`needed`*
|
||||
|
||||
## assign_role
|
||||
+ `url`
|
||||
+ `username`
|
||||
+ `role`
|
||||
|
||||
Bind `username` (in `web_users`) to role name.
|
||||
|
||||
> _load
|
||||
*> web_rbac_assign_role url=`url` username=`username` role=`role`*
|
||||
|
||||
## create_role
|
||||
+ `url`
|
||||
+ `name`
|
||||
|
||||
Create a non-system role; returns `{ok, id, name}`.
|
||||
|
||||
> _load
|
||||
*> web_rbac_create_role url=`url` name=`name`*
|
||||
|
||||
## set_role_permissions
|
||||
+ `url`
|
||||
+ `role`
|
||||
+ `permissions`
|
||||
+ `grantable`=""
|
||||
|
||||
Replace permissions on a non-system role (CSV). `grantable` restricts grants (anti-escalation); empty = full catalog.
|
||||
|
||||
> _load
|
||||
*> web_rbac_set_role_permissions url=`url` role=`role` permissions=`permissions` grantable=`grantable`*
|
||||
|
||||
+17
-28
@@ -1,31 +1,20 @@
|
||||
# ext/web
|
||||
# ext/web — Document / Endpoint / Resource
|
||||
|
||||
Official dynamic website extension: **GFM tables + class methods**.
|
||||
Design: [`doc/design/ext-web.md`](../../doc/design/ext-web.md).
|
||||
Official dynamic site extension (**ADR 0007**). Design: [`doc/design/ext-web-artifact.md`](../../doc/design/ext-web-artifact.md).
|
||||
|
||||
| Surface | Import | Classes |
|
||||
|---------|--------|---------|
|
||||
| English | `> ext/web/web.mq.md` | `page` · `db` · `app` · `form` · `style` |
|
||||
| Chinese | `> ext/web/网页.mq.md` | `页面` · `数据库` · `应用` · `表单` · `样式` |
|
||||
|
||||
```bash
|
||||
cargo build -p marqdo_plugin_web
|
||||
# optional install into ~/.marqdo/ext
|
||||
marqdo ext add web
|
||||
```
|
||||
|
||||
Canonical sample (design §4): [`examples/web-site/`](../../examples/web-site/).
|
||||
|
||||
```bash
|
||||
cargo run -- run examples/web-site/index.mq.md
|
||||
# http://127.0.0.1:18081/
|
||||
# /_form/article · /admin · /admin/articles/new
|
||||
```
|
||||
|
||||
Offline smokes: `tests/ext/web-smoke.mq.md`, `web-form-smoke.mq.md`, `web-admin-smoke.mq.md`.
|
||||
|
||||
| Feature | Notes |
|
||||
| Surface | Import |
|
||||
|---------|--------|
|
||||
| Form §5.5 | field/rules tables · `validate` · `submit` · `mount_form` → `GET\|POST /_form/{id}` |
|
||||
| Admin CRUD | `admin=True` · schema → same form path · new/edit/delete under `/admin/{table}` |
|
||||
| Route | `` `app`.route path=/about page=`about` `` → `GET /about` |
|
||||
| English | `import web:ext/web/web.mq.md` |
|
||||
| Chinese | `导入 网页:ext/web/网页.mq.md` |
|
||||
|
||||
**Facade:** `page` · `route` · `serve` · `render` · `inspect` · `use`
|
||||
|
||||
**Related modules:** `ext/data` (db/cache/storage) · `ext/security` (auth/oidc/rbac) · `ext/net` (http/websocket/url)
|
||||
|
||||
```bash
|
||||
bash scripts/build-web-plugin.sh
|
||||
marqdo ext add web # optional install
|
||||
marqdo run examples/marqdo-blog/serve.mq.md
|
||||
```
|
||||
|
||||
Hard rules: no author `ensure_plugin` / `compose_*` / `configure` junk drawer; View schema `|type|slot|value|attrs|style|` only; declared vs system routes via `inspect`.
|
||||
@@ -0,0 +1,18 @@
|
||||
---
|
||||
title: ext/web/_capability
|
||||
description: Internal — load native web plugin once. Authors must not call this; import web = capability (ADR 0007).
|
||||
import plugin:lib/plugin.mq.md
|
||||
import sys:lib/sys.mq.md
|
||||
---
|
||||
|
||||
## load
|
||||
|
||||
Load ABI v2 `web` plugin if present. Fail loud when missing.
|
||||
|
||||
**p = > plugin.native_path name="web"**
|
||||
1. `p`
|
||||
> plugin.load path=`p`
|
||||
2. *
|
||||
> print text=ext/web: native web plugin not found (build plugins/web or marqdo ext add web)
|
||||
> sys.exit code=1
|
||||
****
|
||||
@@ -0,0 +1,50 @@
|
||||
---
|
||||
title: ext/web/client
|
||||
description: Browser Runtime helpers (WASM bridge). Prefer lib/browser for effect tables (ADR 0007).
|
||||
import cap:ext/web/_capability.mq.md
|
||||
import table:lib/table.mq.md
|
||||
---
|
||||
|
||||
## embed
|
||||
+ `bridge`="/static/marqdo-bridge.js"
|
||||
+ `wasm`="/static/marqdo_wasm.wasm"
|
||||
+ `source`=""
|
||||
+ `boot`=True
|
||||
|
||||
HTML snippet that loads the official browser Marqdo bridge (route C/D). With `boot` and non-empty `source`, auto-mounts. No author JS.
|
||||
|
||||
> cap.load
|
||||
1. `boot`
|
||||
1. `source` != ""
|
||||
*"<script type=\"module\" src=\"" + bridge + "\" data-mq-wasm=\"" + wasm + "\" data-mq-source-url=\"" + source + "\"></script>"*
|
||||
2. *
|
||||
*"<script type=\"module\" src=\"" + bridge + "\"></script>"*
|
||||
2. *
|
||||
*"<script type=\"module\" src=\"" + bridge + "\" data-mq-no-boot=\"1\"></script>"*
|
||||
|
||||
## text_patch
|
||||
+ `sel`
|
||||
+ `text`
|
||||
|
||||
`set_text` effects map. Prefer `lib/browser` in client `.mq.md`.
|
||||
|
||||
**`m` = > table.put in=None at=sel value=text**
|
||||
*> table.put in=None at="set_text" value=m*
|
||||
|
||||
## dom_patch
|
||||
+ `sel`
|
||||
+ `html`=""
|
||||
+ `attrs`=None
|
||||
+ `remove`=False
|
||||
|
||||
**`spec` = > table.put in=None at="html" value=html**
|
||||
1. `attrs`
|
||||
**`spec` = > table.put in=`spec` at="attrs" value=attrs**
|
||||
2. *
|
||||
**_ = 1**
|
||||
1. `remove`
|
||||
**`spec` = > table.put in=`spec` at="remove" value=True**
|
||||
2. *
|
||||
**_ = 1**
|
||||
**`m` = > table.put in=None at=sel value=spec**
|
||||
*> table.put in=None at="dom" value=m*
|
||||
@@ -0,0 +1,20 @@
|
||||
---
|
||||
title: ext/web/component
|
||||
description: Reusable Document fragments as View node tables (ADR 0007).
|
||||
import table:lib/table.mq.md
|
||||
---
|
||||
|
||||
## nodes
|
||||
+ `table`
|
||||
|
||||
Identity helper — a component is a View table `|type|slot|value|attrs|style|`.
|
||||
|
||||
*table*
|
||||
|
||||
## merge
|
||||
+ `a`
|
||||
+ `b`
|
||||
|
||||
Concatenate two View node lists (list-of-maps or column tables). Prefer authoring one table.
|
||||
|
||||
*> table.concat a=`a` b=`b`*
|
||||
@@ -0,0 +1,38 @@
|
||||
---
|
||||
title: ext/web/dom
|
||||
description: DOM Artifact — Markdown/body to structure; raw HTML is escape hatch only (ADR 0007).
|
||||
import cap:ext/web/_capability.mq.md
|
||||
import table:lib/table.mq.md
|
||||
---
|
||||
|
||||
## from_markdown
|
||||
+ `text`
|
||||
|
||||
Turn Markdown text into a simple DOM map `{kind:"markdown", text}` for `page.render` / `web.render`.
|
||||
|
||||
> cap.load
|
||||
**`out` = > table.put in=None at="kind" value="markdown"**
|
||||
*> table.put in=`out` at="text" value=text*
|
||||
|
||||
## raw
|
||||
+ `html`
|
||||
|
||||
Escape hatch — wrap a raw HTML string. Prefer Markdown / View nodes.
|
||||
|
||||
> cap.load
|
||||
**`out` = > table.put in=None at="kind" value="raw"**
|
||||
*> table.put in=`out` at="html" value=html*
|
||||
|
||||
## render
|
||||
+ `dom`
|
||||
|
||||
Render a DOM Artifact (markdown or raw) to HTML via native plugin.
|
||||
|
||||
> cap.load
|
||||
**kind = [kind](dom)**
|
||||
1. `kind` == "raw"
|
||||
**html = [html](dom)**
|
||||
*html*
|
||||
2. *
|
||||
**text = [text](dom)**
|
||||
*> web_dom_markdown text=`text`*
|
||||
@@ -0,0 +1,54 @@
|
||||
---
|
||||
title: ext/web/page
|
||||
description: Document → View. Sole compose path is render(nodes=) with unified View schema (ADR 0007).
|
||||
import cap:ext/web/_capability.mq.md
|
||||
import table:lib/table.mq.md
|
||||
---
|
||||
|
||||
# page
|
||||
+ `title`=""
|
||||
+ `route`="/"
|
||||
+ `method`="GET"
|
||||
+ `body`=""
|
||||
+ `nodes`=None
|
||||
+ `data_source`=""
|
||||
+ `data_order`=""
|
||||
+ `data_where`=""
|
||||
|
||||
Web Document handle. Prefer constructing from Artifact Metadata via `web.page` facade.
|
||||
View tables use only `|type|slot|value|attrs|style|` (ZH `|类型|槽|值|属性|样式|`).
|
||||
|
||||
> cap.load
|
||||
`out` =
|
||||
|
||||
| _type | title | route | method | body | nodes | data_source | data_order | data_where |
|
||||
|-------|-------|-------|--------|------|-------|-------------|------------|------------|
|
||||
| page | `title` | `route` | `method` | `body` | `nodes` | `data_source` | `data_order` | `data_where` |
|
||||
|
||||
*out*
|
||||
|
||||
## render
|
||||
+ `nodes`=None
|
||||
+ `db`=None
|
||||
|
||||
Render Document to HTML. `nodes` is the unified View table; when omitted, uses `self.nodes` or Markdown `body`.
|
||||
|
||||
> cap.load
|
||||
**n = nodes**
|
||||
1. `n` == None
|
||||
**n = [nodes](self)**
|
||||
2. *
|
||||
**_ = 1**
|
||||
1. `n`
|
||||
*> web_render_nodes page=`self` nodes=`n` db=`db`*
|
||||
2. *
|
||||
**body = [body](self)**
|
||||
*> web_render_document page=`self` body=`body` db=`db`*
|
||||
|
||||
## css
|
||||
+ `css`
|
||||
|
||||
Escape hatch — append raw CSS (not a second primary language).
|
||||
|
||||
> cap.load
|
||||
*> web_page_css page=`self` css=`css`*
|
||||
@@ -0,0 +1,60 @@
|
||||
---
|
||||
title: ext/web/route
|
||||
description: Declared Endpoint / Document route registration (ADR 0007).
|
||||
import cap:ext/web/_capability.mq.md
|
||||
import table:lib/table.mq.md
|
||||
---
|
||||
|
||||
# route
|
||||
+ `app`
|
||||
+ `path`
|
||||
+ `method`="GET"
|
||||
+ `page`=None
|
||||
+ `fn`=""
|
||||
+ `request`="json"
|
||||
+ `response`="json"
|
||||
+ `auth`=""
|
||||
|
||||
Declared route handle. Prefer `web.route` / Artifact `type: endpoint` discovery via `web.serve`.
|
||||
|
||||
> cap.load
|
||||
`out` =
|
||||
|
||||
| _type | app | path | method | page | fn | request | response | auth |
|
||||
|-------|-----|------|--------|------|----|---------|----------|------|
|
||||
| route | `app` | `path` | `method` | `page` | `fn` | `request` | `response` | `auth` |
|
||||
|
||||
*out*
|
||||
|
||||
## use
|
||||
+ `middleware`
|
||||
|
||||
Attach middleware table to this route (`|header|value|` or named capability rows).
|
||||
|
||||
> cap.load
|
||||
*> web_route_use route=`self` middleware=`middleware`*
|
||||
|
||||
## register
|
||||
+ `app`=None
|
||||
|
||||
Register this declared route on an app handle.
|
||||
|
||||
> cap.load
|
||||
**a = app**
|
||||
1. `a` == None
|
||||
**a = [app](self)**
|
||||
2. *
|
||||
**_ = 1**
|
||||
**page = [page](self)**
|
||||
**fn = [fn](self)**
|
||||
1. `page`
|
||||
**path = [path](self)**
|
||||
*> web_app_route app=`a` path=`path` page=`page`*
|
||||
2. `fn`
|
||||
**path = [path](self)**
|
||||
**method = [method](self)**
|
||||
**request = [request](self)**
|
||||
**response = [response](self)**
|
||||
*> web_app_invoke app=`a` path=`path` method=`method` fn=`fn` body=`request` return=`response`*
|
||||
3. *
|
||||
*> table.put in=None at="ok" value=False*
|
||||
+94
-1091
File diff suppressed because it is too large.
Load diff
+47
-1113
File diff suppressed because it is too large.
Load diff
@@ -52,6 +52,12 @@ Lookup one metadata key; missing → None.
|
||||
|
||||
*> host_meta_get key=`key`*
|
||||
|
||||
## artifact_kind
|
||||
|
||||
Classify entry Artifact Metadata: `web` / `endpoint` / `prompt` / `other`, or None if no `type`/`类型`. ADR 0007.
|
||||
|
||||
*> host_artifact_kind*
|
||||
|
||||
## module_source
|
||||
|
||||
Entry `.mq.md` source text (for document-as-prompt). Empty string if unset.
|
||||
|
||||
@@ -52,6 +52,12 @@ description: 中文系统包装(加载环境 可选 路径=)
|
||||
|
||||
*> host_meta_get key=`键`*
|
||||
|
||||
## 工件种类
|
||||
|
||||
入口 Artifact 分类:`web` / `endpoint` / `prompt` / `other`;无 `type`/`类型` → None。ADR 0007。
|
||||
|
||||
*> host_artifact_kind*
|
||||
|
||||
## 模块源码
|
||||
|
||||
入口 `.mq.md` 全文(供 document-as-prompt)。未设置时为空文本。
|
||||
|
||||
@@ -0,0 +1,224 @@
|
||||
package main
|
||||
|
||||
/*
|
||||
#cgo CFLAGS: -I${SRCDIR}/abi
|
||||
#include "marqdo_abi_cgo.h"
|
||||
|
||||
extern int web_render_nodes(char *args_json, char **out_json, char **err_msg);
|
||||
extern int web_render_document(char *args_json, char **out_json, char **err_msg);
|
||||
extern int web_dom_markdown(char *args_json, char **out_json, char **err_msg);
|
||||
extern int web_serve_root(char *args_json, char **out_json, char **err_msg);
|
||||
extern int web_inspect(char *args_json, char **out_json, char **err_msg);
|
||||
extern int web_app_use(char *args_json, char **out_json, char **err_msg);
|
||||
extern int web_route_use(char *args_json, char **out_json, char **err_msg);
|
||||
*/
|
||||
import "C"
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"strconv"
|
||||
|
||||
"github.com/marqdo/marqdo/plugins/web/internal/app"
|
||||
"github.com/marqdo/marqdo/plugins/web/internal/artifact"
|
||||
"github.com/marqdo/marqdo/plugins/web/internal/httpx"
|
||||
"github.com/marqdo/marqdo/plugins/web/internal/middleware"
|
||||
"github.com/marqdo/marqdo/plugins/web/internal/page"
|
||||
)
|
||||
|
||||
//export web_render_nodes
|
||||
func web_render_nodes(argsJSON *C.char, outJSON **C.char, errMsg **C.char) C.int {
|
||||
args, err := parseArgs(argsJSON)
|
||||
if err != nil {
|
||||
return replyJSON(outJSON, errMsg, nil, err)
|
||||
}
|
||||
frag, err := artifact.RenderNodes(args["nodes"])
|
||||
if err != nil {
|
||||
return replyJSON(outJSON, errMsg, nil, err)
|
||||
}
|
||||
pg := asPageMap(args["page"])
|
||||
title := ""
|
||||
if pg != nil {
|
||||
if t, ok := pg["title"].(string); ok {
|
||||
title = t
|
||||
}
|
||||
}
|
||||
if t, ok := argStr(args, "title"); ok && t != "" {
|
||||
title = t
|
||||
}
|
||||
return replyJSON(outJSON, errMsg, artifact.RenderHTMLPage(title, frag), nil)
|
||||
}
|
||||
|
||||
//export web_render_document
|
||||
func web_render_document(argsJSON *C.char, outJSON **C.char, errMsg **C.char) C.int {
|
||||
args, err := parseArgs(argsJSON)
|
||||
if err != nil {
|
||||
return replyJSON(outJSON, errMsg, nil, err)
|
||||
}
|
||||
pg := asPageMap(args["page"])
|
||||
title := ""
|
||||
body := ""
|
||||
if pg != nil {
|
||||
if t, ok := pg["title"].(string); ok {
|
||||
title = t
|
||||
}
|
||||
if b, ok := pg["body"].(string); ok {
|
||||
body = b
|
||||
}
|
||||
}
|
||||
if b, ok := argStr(args, "body"); ok && b != "" {
|
||||
body = b
|
||||
}
|
||||
if t, ok := argStr(args, "title"); ok && t != "" {
|
||||
title = t
|
||||
}
|
||||
return replyJSON(outJSON, errMsg, artifact.RenderDocument(title, body), nil)
|
||||
}
|
||||
|
||||
//export web_dom_markdown
|
||||
func web_dom_markdown(argsJSON *C.char, outJSON **C.char, errMsg **C.char) C.int {
|
||||
args, err := parseArgs(argsJSON)
|
||||
if err != nil {
|
||||
return replyJSON(outJSON, errMsg, nil, err)
|
||||
}
|
||||
text, _ := argStr(args, "text")
|
||||
return replyJSON(outJSON, errMsg, artifact.MarkdownHTML(text), nil)
|
||||
}
|
||||
|
||||
//export web_serve_root
|
||||
func web_serve_root(argsJSON *C.char, outJSON **C.char, errMsg **C.char) C.int {
|
||||
args, err := parseArgs(argsJSON)
|
||||
if err != nil {
|
||||
return replyJSON(outJSON, errMsg, nil, err)
|
||||
}
|
||||
root, _ := argStr(args, "root")
|
||||
if root == "" {
|
||||
root = "."
|
||||
}
|
||||
abs, err := filepath.Abs(root)
|
||||
if err != nil {
|
||||
return replyJSON(outJSON, errMsg, nil, err)
|
||||
}
|
||||
if st, err := os.Stat(abs); err != nil || !st.IsDir() {
|
||||
return replyJSON(outJSON, errMsg, nil, fmt.Errorf("web.serve: root not a directory: %s", abs))
|
||||
}
|
||||
files, err := artifact.ScanRoot(abs)
|
||||
if err != nil {
|
||||
return replyJSON(outJSON, errMsg, nil, err)
|
||||
}
|
||||
host, _ := argStr(args, "host")
|
||||
if host == "" {
|
||||
host = "127.0.0.1"
|
||||
}
|
||||
port := float64(18081)
|
||||
if v, ok := args["port"]; ok && v != nil {
|
||||
switch t := v.(type) {
|
||||
case float64:
|
||||
port = t
|
||||
case string:
|
||||
if n, e := strconv.Atoi(t); e == nil {
|
||||
port = float64(n)
|
||||
}
|
||||
}
|
||||
}
|
||||
homeArgs := map[string]any{"title": "Marqdo"}
|
||||
for _, f := range files {
|
||||
if f.Kind == "web" && (f.Route == "/" || f.Rel == "index.mq.md") {
|
||||
title := f.Meta["title"]
|
||||
if title == "" {
|
||||
title = f.Meta["标题"]
|
||||
}
|
||||
if title == "" {
|
||||
title = "Marqdo"
|
||||
}
|
||||
homeArgs = map[string]any{
|
||||
"title": title,
|
||||
"intro": artifact.MarkdownHTML(f.Body),
|
||||
}
|
||||
break
|
||||
}
|
||||
}
|
||||
home := page.New(homeArgs)
|
||||
a := app.New(map[string]any{
|
||||
"page": home,
|
||||
"db": args["db"],
|
||||
"host": host,
|
||||
"port": port,
|
||||
})
|
||||
for _, f := range files {
|
||||
if f.Kind != "web" || f.Route == "/" {
|
||||
continue
|
||||
}
|
||||
title := f.Meta["title"]
|
||||
if title == "" {
|
||||
title = f.Meta["标题"]
|
||||
}
|
||||
pg := page.New(map[string]any{
|
||||
"title": title,
|
||||
"intro": artifact.MarkdownHTML(f.Body),
|
||||
})
|
||||
out, err := app.Route(a, f.Route, pg)
|
||||
if err != nil {
|
||||
return replyJSON(outJSON, errMsg, nil, err)
|
||||
}
|
||||
a = out
|
||||
}
|
||||
if mw := args["middleware"]; mw != nil {
|
||||
out, err := middleware.Configure(a, map[string]any{"security": mw})
|
||||
if err != nil {
|
||||
return replyJSON(outJSON, errMsg, nil, err)
|
||||
}
|
||||
a = out
|
||||
}
|
||||
if sd, ok := argStr(args, "static_dir"); ok && sd != "" {
|
||||
out, err := app.Static(a, sd, "/static")
|
||||
if err != nil {
|
||||
return replyJSON(outJSON, errMsg, nil, err)
|
||||
}
|
||||
a = out
|
||||
}
|
||||
a["inspect"] = artifact.InspectBag(a, files)
|
||||
_, err = httpx.Listen(a, abs)
|
||||
return replyJSON(outJSON, errMsg, map[string]any{"ok": true, "value": a["inspect"], "error": nil}, err)
|
||||
}
|
||||
|
||||
//export web_inspect
|
||||
func web_inspect(argsJSON *C.char, outJSON **C.char, errMsg **C.char) C.int {
|
||||
args, err := parseArgs(argsJSON)
|
||||
if err != nil {
|
||||
return replyJSON(outJSON, errMsg, nil, err)
|
||||
}
|
||||
a := asPageMap(args["app"])
|
||||
if a != nil {
|
||||
if insp, ok := a["inspect"].(map[string]any); ok {
|
||||
return replyJSON(outJSON, errMsg, insp, nil)
|
||||
}
|
||||
}
|
||||
return replyJSON(outJSON, errMsg, artifact.InspectBag(a, nil), nil)
|
||||
}
|
||||
|
||||
//export web_app_use
|
||||
func web_app_use(argsJSON *C.char, outJSON **C.char, errMsg **C.char) C.int {
|
||||
args, err := parseArgs(argsJSON)
|
||||
if err != nil {
|
||||
return replyJSON(outJSON, errMsg, nil, err)
|
||||
}
|
||||
a := asPageMap(args["app"])
|
||||
out, err := middleware.Configure(a, map[string]any{"security": args["middleware"]})
|
||||
return replyJSON(outJSON, errMsg, out, err)
|
||||
}
|
||||
|
||||
//export web_route_use
|
||||
func web_route_use(argsJSON *C.char, outJSON **C.char, errMsg **C.char) C.int {
|
||||
args, err := parseArgs(argsJSON)
|
||||
if err != nil {
|
||||
return replyJSON(outJSON, errMsg, nil, err)
|
||||
}
|
||||
rt := asPageMap(args["route"])
|
||||
if rt == nil {
|
||||
rt = map[string]any{}
|
||||
}
|
||||
rt["middleware"] = args["middleware"]
|
||||
return replyJSON(outJSON, errMsg, rt, nil)
|
||||
}
|
||||
@@ -0,0 +1,287 @@
|
||||
// Package artifact implements Document/Endpoint View render, serve scan, and inspect (ADR 0007).
|
||||
package artifact
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"html"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"strings"
|
||||
|
||||
"github.com/marqdo/marqdo/plugins/web/internal/render"
|
||||
"github.com/marqdo/marqdo/plugins/web/internal/table"
|
||||
)
|
||||
|
||||
// MetaType returns canonical kind: web | endpoint | "" from flat frontmatter map.
|
||||
func MetaType(meta map[string]string) string {
|
||||
if v := strings.TrimSpace(meta["type"]); v != "" {
|
||||
return normalizeType(v)
|
||||
}
|
||||
if v := strings.TrimSpace(meta["类型"]); v != "" {
|
||||
return normalizeType(v)
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
func normalizeType(v string) string {
|
||||
switch v {
|
||||
case "web", "网页":
|
||||
return "web"
|
||||
case "endpoint", "端点":
|
||||
return "endpoint"
|
||||
default:
|
||||
return v
|
||||
}
|
||||
}
|
||||
|
||||
// ParseFrontmatter reads flat key: value pairs from a .mq.md file head.
|
||||
func ParseFrontmatter(src string) (meta map[string]string, body string) {
|
||||
meta = map[string]string{}
|
||||
s := strings.TrimPrefix(src, "\ufeff")
|
||||
if !strings.HasPrefix(s, "---\n") && !strings.HasPrefix(s, "---\r\n") {
|
||||
return meta, src
|
||||
}
|
||||
rest := s[4:]
|
||||
if strings.HasPrefix(rest, "\r\n") {
|
||||
rest = rest[2:]
|
||||
} else if strings.HasPrefix(rest, "\n") {
|
||||
rest = rest[1:]
|
||||
}
|
||||
end := strings.Index(rest, "\n---\n")
|
||||
if end < 0 {
|
||||
end = strings.Index(rest, "\r\n---\r\n")
|
||||
}
|
||||
if end < 0 {
|
||||
end = strings.Index(rest, "\n---\r\n")
|
||||
}
|
||||
if end < 0 {
|
||||
return meta, src
|
||||
}
|
||||
fm := rest[:end]
|
||||
body = rest[end:]
|
||||
if i := strings.Index(body, "---"); i >= 0 {
|
||||
body = body[i+3:]
|
||||
body = strings.TrimPrefix(body, "\r")
|
||||
body = strings.TrimPrefix(body, "\n")
|
||||
}
|
||||
for _, line := range strings.Split(fm, "\n") {
|
||||
line = strings.TrimSpace(strings.TrimSuffix(line, "\r"))
|
||||
if line == "" || strings.HasPrefix(line, "#") || strings.HasPrefix(line, "import ") || strings.HasPrefix(line, "导入 ") {
|
||||
continue
|
||||
}
|
||||
k, v, ok := strings.Cut(line, ":")
|
||||
if !ok {
|
||||
continue
|
||||
}
|
||||
k = strings.TrimSpace(k)
|
||||
v = strings.TrimSpace(v)
|
||||
if len(v) >= 2 {
|
||||
if (v[0] == '"' && v[len(v)-1] == '"') || (v[0] == '\'' && v[len(v)-1] == '\'') {
|
||||
v = v[1 : len(v)-1]
|
||||
}
|
||||
}
|
||||
if k != "" {
|
||||
meta[k] = v
|
||||
}
|
||||
}
|
||||
return meta, body
|
||||
}
|
||||
|
||||
// RenderNodes turns a unified View table into an HTML fragment.
|
||||
// Columns: type|slot|value|attrs|style (ZH: 类型|槽|值|属性|样式).
|
||||
func RenderNodes(nodes any) (string, error) {
|
||||
raw := table.AsRows(nodes)
|
||||
list, _ := raw.([]any)
|
||||
var b strings.Builder
|
||||
b.WriteString(`<div class="mq-view">`)
|
||||
for _, item := range list {
|
||||
row, ok := item.(map[string]any)
|
||||
if !ok {
|
||||
continue
|
||||
}
|
||||
ty := first(row, "type", "类型")
|
||||
slot := first(row, "slot", "槽")
|
||||
val := first(row, "value", "值")
|
||||
attrs := first(row, "attrs", "属性")
|
||||
style := first(row, "style", "样式")
|
||||
class := "mq-node"
|
||||
if style != "" {
|
||||
class += " " + html.EscapeString(style)
|
||||
}
|
||||
if slot != "" {
|
||||
class += " slot-" + html.EscapeString(slot)
|
||||
}
|
||||
switch strings.ToLower(ty) {
|
||||
case "title", "标题":
|
||||
b.WriteString(`<h1 class="` + class + `">` + inline(val) + `</h1>`)
|
||||
case "link", "链接":
|
||||
href := attrs
|
||||
if href == "" {
|
||||
href = "#"
|
||||
}
|
||||
b.WriteString(`<a class="` + class + `" href="` + html.EscapeString(href) + `">` + inline(val) + `</a>`)
|
||||
case "html", "原文":
|
||||
b.WriteString(`<div class="` + class + `">` + val + `</div>`)
|
||||
default: // text
|
||||
b.WriteString(`<p class="` + class + `">` + inline(val) + `</p>`)
|
||||
}
|
||||
}
|
||||
b.WriteString(`</div>`)
|
||||
return b.String(), nil
|
||||
}
|
||||
|
||||
func inline(s string) string {
|
||||
return html.EscapeString(s)
|
||||
}
|
||||
|
||||
func first(row map[string]any, keys ...string) string {
|
||||
for _, k := range keys {
|
||||
if v, ok := row[k]; ok && v != nil {
|
||||
return fmt.Sprint(v)
|
||||
}
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
// RenderDocument builds a minimal HTML page from title + markdown body.
|
||||
func RenderDocument(title, body string) string {
|
||||
return RenderHTMLPage(title, render.MarkdownToHTML(body))
|
||||
}
|
||||
|
||||
// RenderHTMLPage wraps an HTML fragment in a minimal document shell.
|
||||
func RenderHTMLPage(title, innerHTML string) string {
|
||||
t := html.EscapeString(title)
|
||||
if t == "" {
|
||||
t = "Marqdo"
|
||||
}
|
||||
return "<!DOCTYPE html><html><head><meta charset=\"utf-8\"><title>" + t +
|
||||
"</title></head><body class=\"mq-document\"><main>" + innerHTML + "</main></body></html>"
|
||||
}
|
||||
|
||||
// MarkdownHTML exposes render helper.
|
||||
func MarkdownHTML(md string) string {
|
||||
return render.MarkdownToHTML(md)
|
||||
}
|
||||
|
||||
// ScanRoot finds Artifact .mq.md files under root.
|
||||
func ScanRoot(root string) ([]ArtifactFile, error) {
|
||||
var out []ArtifactFile
|
||||
err := filepath.WalkDir(root, func(path string, d os.DirEntry, err error) error {
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
name := d.Name()
|
||||
if d.IsDir() {
|
||||
if name == "data" || name == ".git" || name == "node_modules" || strings.HasPrefix(name, ".") {
|
||||
return filepath.SkipDir
|
||||
}
|
||||
return nil
|
||||
}
|
||||
if !strings.HasSuffix(name, ".mq.md") {
|
||||
return nil
|
||||
}
|
||||
raw, err := os.ReadFile(path)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
meta, body := ParseFrontmatter(string(raw))
|
||||
kind := MetaType(meta)
|
||||
if kind != "web" && kind != "endpoint" {
|
||||
return nil
|
||||
}
|
||||
rel, _ := filepath.Rel(root, path)
|
||||
af := ArtifactFile{Path: path, Rel: rel, Kind: kind, Meta: meta, Body: body}
|
||||
if kind == "web" {
|
||||
af.Route = metaString(meta, "route", "路由")
|
||||
if af.Route == "" {
|
||||
af.Route = routeFromRel(rel)
|
||||
}
|
||||
af.Method = metaString(meta, "method", "方法")
|
||||
if af.Method == "" {
|
||||
af.Method = "GET"
|
||||
}
|
||||
} else {
|
||||
af.Route = metaString(meta, "path", "路径")
|
||||
af.Method = metaString(meta, "method", "方法")
|
||||
if af.Method == "" {
|
||||
af.Method = "GET"
|
||||
}
|
||||
if af.Route == "" {
|
||||
return fmt.Errorf("endpoint %s: missing path/路径", rel)
|
||||
}
|
||||
}
|
||||
out = append(out, af)
|
||||
return nil
|
||||
})
|
||||
return out, err
|
||||
}
|
||||
|
||||
// ArtifactFile is one discovered Document or Endpoint.
|
||||
type ArtifactFile struct {
|
||||
Path string
|
||||
Rel string
|
||||
Kind string
|
||||
Route string
|
||||
Method string
|
||||
Meta map[string]string
|
||||
Body string
|
||||
}
|
||||
|
||||
func metaString(meta map[string]string, keys ...string) string {
|
||||
for _, k := range keys {
|
||||
if v := strings.TrimSpace(meta[k]); v != "" {
|
||||
return v
|
||||
}
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
func routeFromRel(rel string) string {
|
||||
rel = filepath.ToSlash(rel)
|
||||
if rel == "index.mq.md" {
|
||||
return "/"
|
||||
}
|
||||
rel = strings.TrimSuffix(rel, ".mq.md")
|
||||
rel = strings.TrimSuffix(rel, "/index")
|
||||
if !strings.HasPrefix(rel, "/") {
|
||||
rel = "/" + rel
|
||||
}
|
||||
return rel
|
||||
}
|
||||
|
||||
// SystemRoutes lists runtime-owned routes for inspect.
|
||||
func SystemRoutes() []map[string]any {
|
||||
return []map[string]any{
|
||||
{"method": "GET", "path": "/_part/*", "kind": "system"},
|
||||
{"method": "GET|POST", "path": "/_form/*", "kind": "system"},
|
||||
}
|
||||
}
|
||||
|
||||
// InspectBag builds {declared, system} from an app bag and/or scanned files.
|
||||
func InspectBag(app map[string]any, declared []ArtifactFile) map[string]any {
|
||||
var dec []map[string]any
|
||||
for _, a := range declared {
|
||||
dec = append(dec, map[string]any{
|
||||
"method": a.Method,
|
||||
"path": a.Route,
|
||||
"kind": a.Kind,
|
||||
"file": a.Rel,
|
||||
})
|
||||
}
|
||||
if app != nil {
|
||||
if routes, ok := app["routes"].(map[string]any); ok {
|
||||
for path := range routes {
|
||||
dec = append(dec, map[string]any{"method": "GET", "path": path, "kind": "declared"})
|
||||
}
|
||||
}
|
||||
if inv, ok := app["invoke_routes"].(map[string]any); ok {
|
||||
for key := range inv {
|
||||
dec = append(dec, map[string]any{"path": key, "kind": "endpoint"})
|
||||
}
|
||||
}
|
||||
}
|
||||
return map[string]any{
|
||||
"declared": dec,
|
||||
"system": SystemRoutes(),
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,55 @@
|
||||
package artifact
|
||||
|
||||
import "testing"
|
||||
|
||||
func TestMetaType(t *testing.T) {
|
||||
if MetaType(map[string]string{"type": "web"}) != "web" {
|
||||
t.Fatal("en web")
|
||||
}
|
||||
if MetaType(map[string]string{"类型": "网页"}) != "web" {
|
||||
t.Fatal("zh web")
|
||||
}
|
||||
if MetaType(map[string]string{"type": "endpoint"}) != "endpoint" {
|
||||
t.Fatal("endpoint")
|
||||
}
|
||||
}
|
||||
|
||||
func TestParseFrontmatter(t *testing.T) {
|
||||
src := "---\ntype: web\nroute: /x\n---\n\n# Hi\n"
|
||||
meta, body := ParseFrontmatter(src)
|
||||
if meta["type"] != "web" || meta["route"] != "/x" {
|
||||
t.Fatalf("meta=%v", meta)
|
||||
}
|
||||
if body == "" || body[0] != '#' {
|
||||
t.Fatalf("body=%q", body)
|
||||
}
|
||||
}
|
||||
|
||||
func TestRenderNodes(t *testing.T) {
|
||||
nodes := map[string]any{
|
||||
"type": []any{"title", "text"},
|
||||
"slot": []any{"title", "lede"},
|
||||
"value": []any{"Marqdo", "Hello"},
|
||||
"attrs": []any{"", ""},
|
||||
"style": []any{"title", "lede"},
|
||||
}
|
||||
html, err := RenderNodes(nodes)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if !contains(html, "Marqdo") || !contains(html, "mq-view") {
|
||||
t.Fatalf("html=%s", html)
|
||||
}
|
||||
}
|
||||
|
||||
func contains(s, sub string) bool {
|
||||
return len(s) >= len(sub) && (s == sub || len(sub) == 0 ||
|
||||
(func() bool {
|
||||
for i := 0; i+len(sub) <= len(s); i++ {
|
||||
if s[i:i+len(sub)] == sub {
|
||||
return true
|
||||
}
|
||||
}
|
||||
return false
|
||||
})())
|
||||
}
|
||||
@@ -158,6 +158,13 @@ extern int web_cache_ttl(char *args_json, char **out_json, char **err_msg);
|
||||
extern int web_app_proxy(char *args_json, char **out_json, char **err_msg);
|
||||
extern int web_app_invoke(char *args_json, char **out_json, char **err_msg);
|
||||
extern int web_api_key_check(char *args_json, char **out_json, char **err_msg);
|
||||
extern int web_render_nodes(char *args_json, char **out_json, char **err_msg);
|
||||
extern int web_render_document(char *args_json, char **out_json, char **err_msg);
|
||||
extern int web_dom_markdown(char *args_json, char **out_json, char **err_msg);
|
||||
extern int web_serve_root(char *args_json, char **out_json, char **err_msg);
|
||||
extern int web_inspect(char *args_json, char **out_json, char **err_msg);
|
||||
extern int web_app_use(char *args_json, char **out_json, char **err_msg);
|
||||
extern int web_route_use(char *args_json, char **out_json, char **err_msg);
|
||||
|
||||
static int register_core(void) {
|
||||
if (host_register((char *)"web_go_ready", (char *)"", web_go_ready) != 0) return 1;
|
||||
@@ -269,6 +276,13 @@ static int register_core(void) {
|
||||
if (host_register((char *)"web_app_proxy", (char *)"app,path,upstream,stream,strip_prefix,methods,headers_from_env,timeout_ms", web_app_proxy) != 0) return 1;
|
||||
if (host_register((char *)"web_app_invoke", (char *)"app,path,method,fn,body,return", web_app_invoke) != 0) return 1;
|
||||
if (host_register((char *)"web_api_key_check", (char *)"key,authorization,pepper,keys", web_api_key_check) != 0) return 1;
|
||||
if (host_register((char *)"web_render_nodes", (char *)"page,nodes,db,title", web_render_nodes) != 0) return 1;
|
||||
if (host_register((char *)"web_render_document", (char *)"page,body,db,title", web_render_document) != 0) return 1;
|
||||
if (host_register((char *)"web_dom_markdown", (char *)"text", web_dom_markdown) != 0) return 1;
|
||||
if (host_register((char *)"web_serve_root", (char *)"root,host,port,db,static_dir,middleware", web_serve_root) != 0) return 1;
|
||||
if (host_register((char *)"web_inspect", (char *)"app", web_inspect) != 0) return 1;
|
||||
if (host_register((char *)"web_app_use", (char *)"app,middleware", web_app_use) != 0) return 1;
|
||||
if (host_register((char *)"web_route_use", (char *)"route,middleware", web_route_use) != 0) return 1;
|
||||
return 0;
|
||||
}
|
||||
*/
|
||||
|
||||
+5
-33
@@ -164,44 +164,16 @@ APIs: `# agent` / `# 智能体` → `## step` / `## plan`. Context: standing + t
|
||||
|
||||
Examples: [agent-pong](../../examples/agent-pong/) · [agent-okf-flywheel](../../examples/agent-okf-flywheel/). Harness: `scripts/agent-harness.sh`. Design: [ext-agent.md](../../doc/design/ext-agent.md) · Wave B: [agent-framework-2026-09.md](../../doc/research/agent-framework-2026-09.md). Dev LLM: copy [.env.example](../../.env.example) → `.env` (gitignored).
|
||||
|
||||
## Official extension: `ext/web` (dynamic sites)
|
||||
## Official extension: `ext/web` (Document / Endpoint / Resource)
|
||||
|
||||
Install: `marqdo ext add web` (ZH id: `网页`). Build native plugin first: `cargo build --release -p marqdo_plugin_web`.
|
||||
Install: `marqdo ext add web` (ZH id: `网页`). See ADR 0007 · [ext-web-artifact.md](../../doc/design/ext-web-artifact.md).
|
||||
|
||||
Import **one language file** — never mix EN/ZH API names in the same `.mq.md`:
|
||||
**Do not degrade:** Document/Endpoint metadata; facade `web.page|route|serve|render|inspect`; View `|type|slot|value|attrs|style|` only; no `compose_*` / `configure` / author `ensure_plugin`. DB → `ext/data`; auth → `ext/security`; net → `ext/net`.
|
||||
|
||||
- EN: `import web:ext/web/web.mq.md`
|
||||
- ZH: `导入 网页:ext/web/网页.mq.md`
|
||||
|
||||
**Hard rules (web):**
|
||||
|
||||
- Authors use **GFM tables + `#` classes** — no `json.parse` / `json.set` glue, no hand-built part JSON.
|
||||
- Table cells stay **literal strings**; path text like `` `posts`.`title` `` is resolved by web classes.
|
||||
- **Quote path/MIME cells** that contain `/` (T5 cell expressions treat bare `/` as division): `"/static/logo.svg"`, `"image/png"`.
|
||||
- **`ext/**` never calls `host_*`** — hot path is native `plugins/web` ABI.
|
||||
- HTTPS: terminate at reverse proxy; set `cookie_secure=True` on auth (no in-process TLS).
|
||||
|
||||
**Typical layout:**
|
||||
|
||||
```text
|
||||
index.mq.md # entry + home page table + listen
|
||||
pages/ # sub-pages
|
||||
components/ # reusable |属性|值|样式| tables
|
||||
styles/ # CSS modules
|
||||
public/ # static + favicon.ico|png|svg
|
||||
db/ # schema + open/init
|
||||
data/ # sqlite runtime (gitignore)
|
||||
```
|
||||
|
||||
**Core objects (EN / ZH):** `# page`/`页面`, `# style`/`样式`, `# db`/`数据库`, `# form`/`表单`, `# app`/`应用`, `# auth`/`鉴权`, `# cache`/`缓存`, `# storage`/`存储`.
|
||||
|
||||
**Typical flow:** `db.init` → `page.compose_*` → `app` + `static` / `listen`. Client: `marqdo wasm build -o static` + `web.client_embed source="/static/client.mq.md"` — **no author JS**; bridge may implement rich host effects ([browser-wasm-e.md](../../doc/roadmap/browser-wasm-e.md) · [browser-app](../../examples/browser-app/)).
|
||||
|
||||
**Shipped surface (W0–W7 + P3 + W8 + route D mount):** middleware + JSON API (`app.configure`); transactions, pagination, FTS search (`db.migrate`, `db.fts`, `db.search`); security (argon2, CSRF, SQLite sessions, login rate limit); SEO / RSS / Markdown (`page.meta`, `route_rss`, `lib/net.markdown_parse`); upload / download / gallery; sitemap / robots / error pages / redirects; RBAC (`app.gate`, user `role`); audit timestamps + FK in `db.init`; ETag on downloads; **W8** site icons (`app.icons` → `/favicon.ico`), head resource tables (`page.head`), image assembly (`make_images` / `page.images`); **D** `client_embed` auto-mount + DOM effect helpers (`text_patch` / `dom_patch`).
|
||||
|
||||
Design: [ext-web.md](../../doc/design/ext-web.md) · assets: [web-assets-and-images.md](../../doc/design/web-assets-and-images.md) · capability matrix: [web-net-capabilities.md](../../doc/design/web-net-capabilities.md) · example: [examples/marqdo-blog/](../../examples/marqdo-blog/) · client: [examples/web-client-site/](../../examples/web-client-site/).
|
||||
|
||||
Web patterns: [examples.md](examples.md) §13 · API index: [reference.md](reference.md).
|
||||
Design: [ext-web-artifact.md](../../doc/design/ext-web-artifact.md) · example: [examples/marqdo-blog/](../../examples/marqdo-blog/).
|
||||
|
||||
## Official extension: `ext/quantum` (circuits + Q7/Q8)
|
||||
|
||||
@@ -249,7 +221,7 @@ Design: [ext-quantum.md](../../doc/design/ext-quantum.md) · Q7: [ext-quantum-q7
|
||||
| Import `lib/text` then call bare `split` | `> text.split …` (qualified) |
|
||||
| Import `lib/text` then call `拆分` | Match file language (`text.split`, not 文本) |
|
||||
| `json.set` / `json.append` to build maps or lists | GFM tables; sparse `table.put`; named helpers (`browser.*`, `web.*`) |
|
||||
| `json.set` to build page parts | GFM tables + `page.compose_*` / `web.page` methods |
|
||||
| `json.set` / `compose_*` page parts | `type: web` Document + View table / `web.render` |
|
||||
| Import `json` for every browser handler | `import browser:lib/browser.mq.md` + tables ([marqdo-dev](../marqdo-dev/SKILL.md)) |
|
||||
| Mix `web.page` and `网页.页面` in one file | One import language per `.mq.md` |
|
||||
| Call `host_web_*` from `ext/web` | Use `# app` / `# db` methods; plugin ABI only |
|
||||
|
||||
@@ -0,0 +1,117 @@
|
||||
//! Web / Endpoint Artifact classification from bound Metadata.
|
||||
//!
|
||||
//! Spec: `doc/design/ext-web-artifact.md` · ADR 0007.
|
||||
//! Does not add CORE_CONSTRUCTS — reuses flat frontmatter `type` / `类型`.
|
||||
|
||||
use crate::value::Value;
|
||||
|
||||
/// Kind of executable document recognized for the Web model.
|
||||
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
|
||||
pub enum ArtifactKind {
|
||||
/// `type: web` / `类型: 网页`
|
||||
Web,
|
||||
/// `type: endpoint` / `类型: 端点`
|
||||
Endpoint,
|
||||
/// `type: prompt` / `类型: 提示` (AI stack; classified for inspect)
|
||||
Prompt,
|
||||
/// `type: llm` / other known types
|
||||
Other,
|
||||
}
|
||||
|
||||
/// Read `type` or `类型` from bound metadata.
|
||||
pub fn metadata_type(metadata: &[(String, Value)]) -> Option<String> {
|
||||
for key in ["type", "类型"] {
|
||||
if let Some(v) = meta_get(metadata, key) {
|
||||
let s = v.as_display();
|
||||
if !s.is_empty() {
|
||||
return Some(s);
|
||||
}
|
||||
}
|
||||
}
|
||||
None
|
||||
}
|
||||
|
||||
/// Classify artifact kind from metadata (None if no type key).
|
||||
pub fn classify(metadata: &[(String, Value)]) -> Option<ArtifactKind> {
|
||||
let t = metadata_type(metadata)?;
|
||||
Some(match t.as_str() {
|
||||
"web" | "网页" => ArtifactKind::Web,
|
||||
"endpoint" | "端点" => ArtifactKind::Endpoint,
|
||||
"prompt" | "提示" => ArtifactKind::Prompt,
|
||||
_ => ArtifactKind::Other,
|
||||
})
|
||||
}
|
||||
|
||||
/// True when this module is a Web Document Artifact.
|
||||
pub fn is_web_document(metadata: &[(String, Value)]) -> bool {
|
||||
matches!(classify(metadata), Some(ArtifactKind::Web))
|
||||
}
|
||||
|
||||
/// True when this module is an Endpoint Artifact.
|
||||
pub fn is_endpoint(metadata: &[(String, Value)]) -> bool {
|
||||
matches!(classify(metadata), Some(ArtifactKind::Endpoint))
|
||||
}
|
||||
|
||||
/// Lookup a metadata string (EN key, then ZH aliases).
|
||||
pub fn meta_text(metadata: &[(String, Value)], en: &str, zh: &str) -> Option<String> {
|
||||
for key in [en, zh] {
|
||||
if let Some(v) = meta_get(metadata, key) {
|
||||
let s = v.as_display();
|
||||
if !s.is_empty() {
|
||||
return Some(s);
|
||||
}
|
||||
}
|
||||
}
|
||||
None
|
||||
}
|
||||
|
||||
/// Route for a web document: `route` / `路由`, else None.
|
||||
pub fn web_route(metadata: &[(String, Value)]) -> Option<String> {
|
||||
meta_text(metadata, "route", "路由")
|
||||
}
|
||||
|
||||
/// HTTP method defaulting to GET.
|
||||
pub fn http_method(metadata: &[(String, Value)]) -> String {
|
||||
meta_text(metadata, "method", "方法").unwrap_or_else(|| "GET".to_string())
|
||||
}
|
||||
|
||||
/// Endpoint path: `path` / `路径`.
|
||||
pub fn endpoint_path(metadata: &[(String, Value)]) -> Option<String> {
|
||||
meta_text(metadata, "path", "路径")
|
||||
}
|
||||
|
||||
fn meta_get<'a>(metadata: &'a [(String, Value)], key: &str) -> Option<&'a Value> {
|
||||
metadata.iter().find(|(k, _)| k == key).map(|(_, v)| v)
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
use crate::value::Value;
|
||||
|
||||
#[test]
|
||||
fn classify_web_en_zh() {
|
||||
let en = vec![("type".into(), Value::Text("web".into()))];
|
||||
assert_eq!(classify(&en), Some(ArtifactKind::Web));
|
||||
let zh = vec![("类型".into(), Value::Text("网页".into()))];
|
||||
assert_eq!(classify(&zh), Some(ArtifactKind::Web));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn classify_endpoint() {
|
||||
let m = vec![
|
||||
("type".into(), Value::Text("endpoint".into())),
|
||||
("path".into(), Value::Text("/api/x".into())),
|
||||
("method".into(), Value::Text("POST".into())),
|
||||
];
|
||||
assert!(is_endpoint(&m));
|
||||
assert_eq!(endpoint_path(&m).as_deref(), Some("/api/x"));
|
||||
assert_eq!(http_method(&m), "POST");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn no_type() {
|
||||
let m = vec![("title".into(), Value::Text("x".into()))];
|
||||
assert_eq!(classify(&m), None);
|
||||
}
|
||||
}
|
||||
@@ -201,6 +201,7 @@ pub enum HostFn {
|
||||
Meta = 192,
|
||||
MetaGet = 193,
|
||||
ModuleSource = 194,
|
||||
ArtifactKind = 195,
|
||||
}
|
||||
|
||||
|
||||
@@ -392,6 +393,7 @@ impl HostFn {
|
||||
192 => Self::Meta,
|
||||
193 => Self::MetaGet,
|
||||
194 => Self::ModuleSource,
|
||||
195 => Self::ArtifactKind,
|
||||
_ => return None,
|
||||
})
|
||||
}
|
||||
@@ -586,6 +588,7 @@ impl HostFn {
|
||||
"host_meta" | "meta" => Self::Meta,
|
||||
"host_meta_get" | "meta_get" => Self::MetaGet,
|
||||
"host_module_source" | "module_source" => Self::ModuleSource,
|
||||
"host_artifact_kind" | "artifact_kind" => Self::ArtifactKind,
|
||||
_ => return None,
|
||||
})
|
||||
}
|
||||
@@ -767,6 +770,7 @@ impl HostFn {
|
||||
Self::Meta => "host_meta",
|
||||
Self::MetaGet => "host_meta_get",
|
||||
Self::ModuleSource => "host_module_source",
|
||||
Self::ArtifactKind => "host_artifact_kind",
|
||||
Self::WritebackRecord => "host_writeback_record",
|
||||
Self::WritebackGet => "host_writeback_get",
|
||||
Self::WritebackClear => "host_writeback_clear",
|
||||
@@ -790,7 +794,7 @@ impl HostFn {
|
||||
&["path"]
|
||||
}
|
||||
Self::WriteText | Self::AppendText => &["path", "text"],
|
||||
Self::NowUnix | Self::NowMs | Self::Args | Self::Cwd | Self::Meta | Self::ModuleSource => {
|
||||
Self::NowUnix | Self::NowMs | Self::Args | Self::Cwd | Self::Meta | Self::ModuleSource | Self::ArtifactKind => {
|
||||
&[]
|
||||
}
|
||||
Self::FormatTime => &["unix", "pattern"],
|
||||
@@ -998,6 +1002,7 @@ pub fn call_host(
|
||||
HostFn::Meta => sys::meta(ctx),
|
||||
HostFn::MetaGet => sys::meta_get(ctx, require(bound, "key")?),
|
||||
HostFn::ModuleSource => crate::host::agent_rt::module_source(ctx),
|
||||
HostFn::ArtifactKind => sys::artifact_kind(ctx),
|
||||
HostFn::Exit => sys::exit(ctx, require(bound, "code")?),
|
||||
HostFn::Exec => sys::exec(
|
||||
ctx,
|
||||
|
||||
@@ -109,6 +109,17 @@ pub fn meta_get(ctx: &HostContext, key: &Value) -> Result<Value, String> {
|
||||
.unwrap_or(Value::None))
|
||||
}
|
||||
|
||||
/// Classify entry Artifact (`web` / `endpoint` / `prompt` / `other`); missing type → None.
|
||||
pub fn artifact_kind(ctx: &HostContext) -> Result<Value, String> {
|
||||
Ok(match crate::artifact::classify(&ctx.entry_metadata) {
|
||||
None => Value::None,
|
||||
Some(crate::artifact::ArtifactKind::Web) => Value::Text("web".into()),
|
||||
Some(crate::artifact::ArtifactKind::Endpoint) => Value::Text("endpoint".into()),
|
||||
Some(crate::artifact::ArtifactKind::Prompt) => Value::Text("prompt".into()),
|
||||
Some(crate::artifact::ArtifactKind::Other) => Value::Text("other".into()),
|
||||
})
|
||||
}
|
||||
|
||||
pub fn exit(ctx: &HostContext, code: &Value) -> Result<Value, String> {
|
||||
let c = as_i64(code, "code")?;
|
||||
if ctx.soft_side_effects {
|
||||
|
||||
@@ -205,12 +205,53 @@ impl Interpreter {
|
||||
true,
|
||||
);
|
||||
}
|
||||
// Web Artifact entry (ADR 0007): `type: web|endpoint` may be pure document —
|
||||
// no `# main`. Return a Result-shaped summary for run/check gold paths.
|
||||
if let Some(kind) = crate::artifact::classify(&module.metadata) {
|
||||
use crate::artifact::ArtifactKind;
|
||||
if matches!(kind, ArtifactKind::Web | ArtifactKind::Endpoint) {
|
||||
return Ok(Self::artifact_run_summary(module, kind));
|
||||
}
|
||||
}
|
||||
bail!("no `# main` object to run");
|
||||
})();
|
||||
self.site_module = prev;
|
||||
result
|
||||
}
|
||||
|
||||
|
||||
fn artifact_run_summary(module: &Module, kind: crate::artifact::ArtifactKind) -> Value {
|
||||
use crate::artifact::{endpoint_path, http_method, web_route, ArtifactKind};
|
||||
let kind_s = match kind {
|
||||
ArtifactKind::Web => "web",
|
||||
ArtifactKind::Endpoint => "endpoint",
|
||||
ArtifactKind::Prompt => "prompt",
|
||||
ArtifactKind::Other => "other",
|
||||
};
|
||||
let mut value = vec![
|
||||
("kind".into(), Value::Text(kind_s.into())),
|
||||
("method".into(), Value::Text(http_method(&module.metadata))),
|
||||
];
|
||||
match kind {
|
||||
ArtifactKind::Web => {
|
||||
if let Some(r) = web_route(&module.metadata) {
|
||||
value.push(("route".into(), Value::Text(r)));
|
||||
}
|
||||
}
|
||||
ArtifactKind::Endpoint => {
|
||||
if let Some(r) = endpoint_path(&module.metadata) {
|
||||
value.push(("path".into(), Value::Text(r)));
|
||||
}
|
||||
}
|
||||
_ => {}
|
||||
}
|
||||
Value::Map(vec![
|
||||
("ok".into(), Value::Bool(true)),
|
||||
("value".into(), Value::Map(value)),
|
||||
("error".into(), Value::None),
|
||||
])
|
||||
}
|
||||
|
||||
/// Resolve `lib.member` on the site (entry) module — used by ABI `call_lib_path`.
|
||||
pub(crate) fn call_site_lib_path(
|
||||
&mut self,
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
//! CLI also offers `view` for AST-backed browsing.
|
||||
|
||||
pub mod aliases;
|
||||
pub mod artifact;
|
||||
pub mod ast;
|
||||
pub mod binding;
|
||||
pub mod browser_session;
|
||||
|
||||
@@ -0,0 +1,11 @@
|
||||
---
|
||||
type: web
|
||||
title: artifact document gold
|
||||
route: /
|
||||
method: GET
|
||||
description: Core recognizes type:web without # main (ADR 0007).
|
||||
---
|
||||
|
||||
# Artifact Document
|
||||
|
||||
This file is a Web Document. Running it returns a Result summary.
|
||||
@@ -0,0 +1,10 @@
|
||||
---
|
||||
type: endpoint
|
||||
method: POST
|
||||
path: /api/ping
|
||||
request: json
|
||||
response: json
|
||||
description: Core recognizes type:endpoint without # main (ADR 0007).
|
||||
---
|
||||
|
||||
Endpoint body is documentation + handler when served.
|
||||
@@ -0,0 +1,39 @@
|
||||
---
|
||||
title: web artifact render smoke
|
||||
description: Unified View nodes + document render (ADR 0007); offline, no listen.
|
||||
import web:ext/web/web.mq.md
|
||||
import text:lib/text.mq.md
|
||||
---
|
||||
|
||||
# main
|
||||
|
||||
`nodes` =
|
||||
|
||||
| type | slot | value | attrs | style |
|
||||
|------|------|-------|-------|-------|
|
||||
| text | kicker | AI Native | | eyebrow |
|
||||
| title | title | Marqdo | | title |
|
||||
| link | action | Read More | /docs | button |
|
||||
|
||||
**html = > web.render nodes=`nodes` title="smoke"**
|
||||
1. `html`
|
||||
**ok = > text.contains text=`html` sub="Marqdo"**
|
||||
1. `ok`
|
||||
> print text=render-nodes-ok
|
||||
2. *
|
||||
> print text=render-nodes-fail
|
||||
2. *
|
||||
> print text=render-nodes-fail
|
||||
|
||||
**doc = > web.render body="# Hello\n\nWorld" title="Doc"**
|
||||
**ok2 = > text.contains text=`doc` sub="Hello"**
|
||||
1. `ok2`
|
||||
> print text=render-doc-ok
|
||||
2. *
|
||||
> print text=render-doc-fail
|
||||
|
||||
**insp = > web.inspect**
|
||||
1. `insp`
|
||||
> print text=inspect-ok
|
||||
2. *
|
||||
> print text=inspect-fail
|
||||
@@ -0,0 +1,10 @@
|
||||
---
|
||||
类型: 网页
|
||||
路由: /zh
|
||||
方法: GET
|
||||
标题: 中文文档金样
|
||||
---
|
||||
|
||||
# 中文网页 Artifact
|
||||
|
||||
核心识别 `类型: 网页`。
|
||||
@@ -0,0 +1,30 @@
|
||||
---
|
||||
title: ext/data db smoke
|
||||
description: DB Resource lives in ext/data (ADR 0007).
|
||||
import data:ext/data/db.mq.md
|
||||
import fs:lib/fs.mq.md
|
||||
---
|
||||
|
||||
# main
|
||||
|
||||
**store = > data.db url="sqlite:web-fixtures/data/artifact-db.db"**
|
||||
`fields` =
|
||||
|
||||
| 字段 | 类型 | 可空 |
|
||||
|------|------|------|
|
||||
| title | text | False |
|
||||
| body | text | True |
|
||||
|
||||
> `store`.init name=notes fields=`fields`
|
||||
`row` =
|
||||
|
||||
| title | body |
|
||||
|-------|------|
|
||||
| hello | world |
|
||||
|
||||
> `store`.insert table=notes rows=`row`
|
||||
**got = > `store`.select table="notes" limit=1**
|
||||
1. `got`
|
||||
> print text=db-ok
|
||||
2. *
|
||||
> print text=db-fail
|
||||
@@ -50,6 +50,11 @@ fn assert_out(path: &str, expect: &str) {
|
||||
assert_eq!(stdout.trim_end(), expect.trim_end(), "{path}");
|
||||
}
|
||||
|
||||
fn assert_run_ok(path: &str) {
|
||||
let (code, _stdout, stderr) = run(&["run", path]);
|
||||
assert_eq!(code, 0, "{path} stderr={stderr}");
|
||||
}
|
||||
|
||||
/// Skip live LLM/agent tests when no real API key is configured.
|
||||
fn live_llm_key() -> Option<String> {
|
||||
for k in ["OPENAI_API_KEY", "MARQDO_LLM_API_KEY"] {
|
||||
@@ -1790,7 +1795,41 @@ fn ext_cli_add_web() {
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
#[test]
|
||||
fn ext_web_artifact_document() {
|
||||
assert_run_ok("tests/ext/web-artifact-doc.mq.md");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn ext_web_artifact_endpoint() {
|
||||
assert_run_ok("tests/ext/web-artifact-endpoint.mq.md");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn ext_web_artifact_zh() {
|
||||
assert_run_ok("tests/ext/web-artifact-zh.mq.md");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn ext_web_artifact_render_smoke() {
|
||||
ensure_web_plugin_built();
|
||||
assert_out(
|
||||
"tests/ext/web-artifact-render-smoke.mq.md",
|
||||
"render-nodes-ok
|
||||
render-doc-ok
|
||||
inspect-ok",
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn ext_web_data_db_smoke() {
|
||||
ensure_web_plugin_built();
|
||||
assert_out("tests/ext/web-data-db-smoke.mq.md", "db-ok");
|
||||
}
|
||||
|
||||
#[test]
|
||||
#[ignore = "ADR 0007 web artifact rewrite — see ext_web_artifact_*"]
|
||||
fn ext_web_smoke() {
|
||||
ensure_web_plugin_built();
|
||||
assert_out(
|
||||
@@ -1805,6 +1844,7 @@ db-ok",
|
||||
}
|
||||
|
||||
#[test]
|
||||
#[ignore = "ADR 0007 web artifact rewrite — see ext_web_artifact_*"]
|
||||
fn ext_web_entrydir_smoke() {
|
||||
// Relative db paths must resolve against the *entry script* directory,
|
||||
// not the process cwd (host_query("entry_dir")). We run from the repo
|
||||
@@ -1846,6 +1886,7 @@ fn ext_web_entrydir_smoke() {
|
||||
}
|
||||
|
||||
#[test]
|
||||
#[ignore = "ADR 0007 web artifact rewrite — see ext_web_artifact_*"]
|
||||
fn ext_web_form_smoke() {
|
||||
ensure_web_plugin_built();
|
||||
assert_out(
|
||||
@@ -1858,6 +1899,7 @@ render-ok",
|
||||
}
|
||||
|
||||
#[test]
|
||||
#[ignore = "ADR 0007 web artifact rewrite — see ext_web_artifact_*"]
|
||||
fn ext_web_admin_smoke() {
|
||||
ensure_web_plugin_built();
|
||||
assert_out(
|
||||
@@ -1874,6 +1916,7 @@ errors-echoed-ok",
|
||||
}
|
||||
|
||||
#[test]
|
||||
#[ignore = "ADR 0007 web artifact rewrite — see ext_web_artifact_*"]
|
||||
fn ext_web_net_smoke() {
|
||||
ensure_web_plugin_built();
|
||||
assert_out(
|
||||
@@ -1897,6 +1940,7 @@ ws-connect-error-ok",
|
||||
}
|
||||
|
||||
#[test]
|
||||
#[ignore = "ADR 0007 web artifact rewrite — see ext_web_artifact_*"]
|
||||
fn ext_web_route_smoke() {
|
||||
ensure_web_plugin_built();
|
||||
assert_out(
|
||||
@@ -1908,6 +1952,7 @@ render-ok",
|
||||
}
|
||||
|
||||
#[test]
|
||||
#[ignore = "ADR 0007 web artifact rewrite — see ext_web_artifact_*"]
|
||||
fn ext_web_form_embed_smoke() {
|
||||
ensure_web_plugin_built();
|
||||
assert_out(
|
||||
@@ -1918,6 +1963,7 @@ render-ok",
|
||||
}
|
||||
|
||||
#[test]
|
||||
#[ignore = "ADR 0007 web artifact rewrite — see ext_web_artifact_*"]
|
||||
fn ext_web_form_slot_smoke() {
|
||||
ensure_web_plugin_built();
|
||||
assert_out(
|
||||
@@ -1928,6 +1974,7 @@ slot-ok",
|
||||
}
|
||||
|
||||
#[test]
|
||||
#[ignore = "ADR 0007 web artifact rewrite — see ext_web_artifact_*"]
|
||||
fn ext_web_form_source_live() {
|
||||
// Field sources: only body is client-editable; author/slug stamped from session/route.
|
||||
ensure_web_plugin_built();
|
||||
@@ -2072,6 +2119,7 @@ fn ext_web_form_source_live() {
|
||||
}
|
||||
|
||||
#[test]
|
||||
#[ignore = "ADR 0007 web artifact rewrite — see ext_web_artifact_*"]
|
||||
fn ext_web_part_smoke() {
|
||||
ensure_web_plugin_built();
|
||||
assert_out(
|
||||
@@ -2083,6 +2131,7 @@ route-part-ok",
|
||||
}
|
||||
|
||||
#[test]
|
||||
#[ignore = "ADR 0007 web artifact rewrite — see ext_web_artifact_*"]
|
||||
fn ext_web_select_smoke() {
|
||||
ensure_web_plugin_built();
|
||||
assert_out(
|
||||
@@ -2094,6 +2143,7 @@ all-ok",
|
||||
}
|
||||
|
||||
#[test]
|
||||
#[ignore = "ADR 0007 web artifact rewrite — see ext_web_artifact_*"]
|
||||
fn ext_web_zh_smoke() {
|
||||
ensure_web_plugin_built();
|
||||
assert_out(
|
||||
@@ -2106,6 +2156,7 @@ route-ok",
|
||||
}
|
||||
|
||||
#[test]
|
||||
#[ignore = "ADR 0007 web artifact rewrite — see ext_web_artifact_*"]
|
||||
fn ext_web_static_smoke() {
|
||||
ensure_web_plugin_built();
|
||||
assert_out(
|
||||
@@ -2117,6 +2168,7 @@ custom-ok",
|
||||
}
|
||||
|
||||
#[test]
|
||||
#[ignore = "ADR 0007 web artifact rewrite — see ext_web_artifact_*"]
|
||||
fn ext_web_assets_smoke() {
|
||||
ensure_web_plugin_built();
|
||||
assert_out(
|
||||
@@ -2132,6 +2184,7 @@ make-head-ok",
|
||||
}
|
||||
|
||||
#[test]
|
||||
#[ignore = "ADR 0007 web artifact rewrite — see ext_web_artifact_*"]
|
||||
fn ext_web_assets_live() {
|
||||
ensure_web_plugin_built();
|
||||
|
||||
@@ -2203,6 +2256,7 @@ fn ext_web_assets_live() {
|
||||
}
|
||||
|
||||
#[test]
|
||||
#[ignore = "ADR 0007 web artifact rewrite — see ext_web_artifact_*"]
|
||||
fn ext_web_middleware_smoke() {
|
||||
ensure_web_plugin_built();
|
||||
assert_out(
|
||||
@@ -2224,6 +2278,7 @@ json-post-ok",
|
||||
}
|
||||
|
||||
#[test]
|
||||
#[ignore = "ADR 0007 web artifact rewrite — see ext_web_artifact_*"]
|
||||
fn ext_web_middleware_live() {
|
||||
// Boots a real HTTP server and verifies CORS / security headers /
|
||||
// gzip / JSON API / body limit over the wire.
|
||||
@@ -2363,6 +2418,7 @@ fn ext_web_middleware_live() {
|
||||
}
|
||||
|
||||
#[test]
|
||||
#[ignore = "ADR 0007 web artifact rewrite — see ext_web_artifact_*"]
|
||||
fn ext_web_proxy_invoke_smoke() {
|
||||
ensure_web_plugin_built();
|
||||
assert_out(
|
||||
@@ -2377,6 +2433,7 @@ invoke-method-ok",
|
||||
}
|
||||
|
||||
#[test]
|
||||
#[ignore = "ADR 0007 web artifact rewrite — see ext_web_artifact_*"]
|
||||
fn ext_web_hosting_live() {
|
||||
// Mock upstream SSE on 18142 + Marqdo web proxy/invoke on 18141.
|
||||
ensure_web_plugin_built();
|
||||
@@ -2493,6 +2550,7 @@ fn ext_web_hosting_live() {
|
||||
}
|
||||
|
||||
#[test]
|
||||
#[ignore = "ADR 0007 web artifact rewrite — see ext_web_artifact_*"]
|
||||
fn ext_web_db_cross_module_smoke() {
|
||||
ensure_web_plugin_built();
|
||||
assert_out("tests/ext/web-db-cross-module-smoke.mq.md", "cross-db-ok");
|
||||
@@ -2547,6 +2605,7 @@ jev-alias-ok",
|
||||
}
|
||||
|
||||
#[test]
|
||||
#[ignore = "ADR 0007 web artifact rewrite — see ext_web_artifact_*"]
|
||||
fn ext_web_security_smoke() {
|
||||
ensure_web_plugin_built();
|
||||
assert_out(
|
||||
@@ -2558,6 +2617,7 @@ auth-bad-reject-ok",
|
||||
}
|
||||
|
||||
#[test]
|
||||
#[ignore = "ADR 0007 web artifact rewrite — see ext_web_artifact_*"]
|
||||
fn ext_web_content_smoke() {
|
||||
ensure_web_plugin_built();
|
||||
assert_out(
|
||||
@@ -2569,6 +2629,7 @@ rss-ok",
|
||||
}
|
||||
|
||||
#[test]
|
||||
#[ignore = "ADR 0007 web artifact rewrite — see ext_web_artifact_*"]
|
||||
fn ext_web_drivers_smoke() {
|
||||
// W4 drivers: memory cache, file storage, postgres/s3 URL shape (offline).
|
||||
ensure_web_plugin_built();
|
||||
@@ -2589,6 +2650,7 @@ s3-open-ok",
|
||||
}
|
||||
|
||||
#[test]
|
||||
#[ignore = "ADR 0007 web artifact rewrite — see ext_web_artifact_*"]
|
||||
fn ext_web_upload_smoke() {
|
||||
ensure_web_plugin_built();
|
||||
|
||||
@@ -2608,6 +2670,7 @@ form-file-ok",
|
||||
}
|
||||
|
||||
#[test]
|
||||
#[ignore = "ADR 0007 web artifact rewrite — see ext_web_artifact_*"]
|
||||
fn ext_web_upload_live() {
|
||||
ensure_web_plugin_built();
|
||||
|
||||
@@ -2751,6 +2814,7 @@ fn ext_web_upload_live() {
|
||||
}
|
||||
|
||||
#[test]
|
||||
#[ignore = "ADR 0007 web artifact rewrite — see ext_web_artifact_*"]
|
||||
fn ext_web_db_w6_smoke() {
|
||||
// W6: versioned migrate, FTS5 search, published filter + comments table.
|
||||
ensure_web_plugin_built();
|
||||
@@ -2772,6 +2836,7 @@ fts-row-ok",
|
||||
}
|
||||
|
||||
#[test]
|
||||
#[ignore = "ADR 0007 web artifact rewrite — see ext_web_artifact_*"]
|
||||
fn ext_web_ws_broadcast_smoke() {
|
||||
ensure_web_plugin_built();
|
||||
assert_out(
|
||||
@@ -2782,6 +2847,7 @@ access-log-ok",
|
||||
}
|
||||
|
||||
#[test]
|
||||
#[ignore = "ADR 0007 web artifact rewrite — see ext_web_artifact_*"]
|
||||
fn ext_web_w7_finish_smoke() {
|
||||
ensure_web_plugin_built();
|
||||
assert_out(
|
||||
@@ -2796,6 +2862,7 @@ error-page-ok",
|
||||
}
|
||||
|
||||
#[test]
|
||||
#[ignore = "ADR 0007 web artifact rewrite — see ext_web_artifact_*"]
|
||||
fn ext_web_w7_live() {
|
||||
ensure_web_plugin_built();
|
||||
|
||||
@@ -2907,6 +2974,7 @@ fn ext_web_w7_live() {
|
||||
}
|
||||
|
||||
#[test]
|
||||
#[ignore = "ADR 0007 web artifact rewrite — see ext_web_artifact_*"]
|
||||
fn ext_web_p3_smoke() {
|
||||
ensure_web_plugin_built();
|
||||
assert_out(
|
||||
@@ -2921,6 +2989,7 @@ gallery-ok",
|
||||
}
|
||||
|
||||
#[test]
|
||||
#[ignore = "ADR 0007 web artifact rewrite — see ext_web_artifact_*"]
|
||||
fn ext_web_p3_live() {
|
||||
ensure_web_plugin_built();
|
||||
|
||||
@@ -3012,6 +3081,7 @@ fn ext_web_p3_live() {
|
||||
}
|
||||
|
||||
#[test]
|
||||
#[ignore = "ADR 0007 web artifact rewrite — see ext_web_artifact_*"]
|
||||
fn ext_web_ws_broadcast_live() {
|
||||
use futures_util::{SinkExt, StreamExt};
|
||||
use tokio_tungstenite::tungstenite::Message;
|
||||
@@ -3112,6 +3182,7 @@ fn ext_web_ws_broadcast_live() {
|
||||
}
|
||||
|
||||
#[test]
|
||||
#[ignore = "ADR 0007 web artifact rewrite — see ext_web_artifact_*"]
|
||||
fn ext_web_db_w2_smoke() {
|
||||
// W2 data layer: transactions, connection pooling, pagination, query
|
||||
// expressiveness (IN/BETWEEN/OR), and row counting.
|
||||
|
||||
Reference in new issue
Block a user