Compare commits

..
19 Commits
Author SHA1 Message Date
cflmyandCursor 27991a7822 docs(release): fold unbound-table fix into v1.0.3 notes
Co-authored-by: Cursor <cursoragent@cursor.com>
2026-09-17 10:31:41 +08:00
cflmyandCursor d1e2f0ced0 fix(parse): allow unbound GFM tables as discarded values
Bare tables in a function body evaluate as collections without requiring
a name bind; restores welcome-page install tables.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-09-17 10:29:13 +08:00
cflmyandCursor e848306187 fix(public): drop bare GFM tables from welcome # main
Tables are collections in Marqdo; bare rows aborted pages CI.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-09-17 10:26:12 +08:00
cflmyandCursor 2ee9d7e66d release: v1.0.3 — PPA, ext CDN, synced CLI+ext packs
Co-authored-by: Cursor <cursoragent@cursor.com>
2026-09-17 10:20:37 +08:00
cflmyandCursor e31585842d fix(ppa): bundle Rust toolchain for noble Cargo.lock v4 builds
Document install channels (PPA/GitHub/CDN); release skill supports
full/cli/ext modes with R2+GitHub ext uploads and manual PPA commands.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-09-17 10:18:50 +08:00
cflmyandCursor f068b4ab75 fix(packaging): skip cp when orig tarball already in build-area
Same-inode copy aborted ppa-build under set -e before dput.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-09-17 10:05:23 +08:00
cflmyandCursor 26e29409a9 docs(changelog): mention ppa-ship one-shot script
Co-authored-by: Cursor <cursoragent@cursor.com>
2026-09-17 10:01:33 +08:00
cflmyandCursor 4923129d10 feat(packaging): add ppa-ship.sh one-shot build and dput
Installs apt deps with sudo, then builds/signs/uploads as the real user.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-09-17 10:01:22 +08:00
cflmyandCursor 8ab55e2193 docs(changelog): note Ubuntu PPA packaging scaffold
Co-authored-by: Cursor <cursoragent@cursor.com>
2026-09-17 09:58:12 +08:00
cflmyandCursor 9bc7ef3b5a feat(packaging): scaffold Ubuntu PPA debian/ for marqdo CLI
Add control/rules/changelog and ppa-build-source.sh (cargo vendor + debuild -S).

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-09-17 09:57:11 +08:00
cflmyandCursor 9431ad835c docs: link ext-cdn in doc/README
Co-authored-by: Cursor <cursoragent@cursor.com>
2026-09-17 09:31:06 +08:00
cflmyandCursor 2984d7d4f8 feat(ext): prefer Cloudflare R2 CDN and allow separate ext pack versions
Download order is CDN (ext.marqdo.com) → GitHub → proxy; pack SemVer from
ext/VERSION / CDN latest; add upload-ext-r2.py and release-skill notes.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-09-17 09:28:28 +08:00
cflmyandCursor 6324036e41 fix(ext): mirror fallback for Release downloads and default ~/.marqdo/ext
Try proxy.cflmy.top when github.com fails; honor MARQDO_EXT_DOWNLOAD_BASE;
resolve ext imports from the ext-add install root without exporting MARQDO_EXT.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-09-17 08:57:24 +08:00
cflmyandCursor 3287799959 docs(skill): note table-bound page.compose_intro for v1.0.2
Co-authored-by: Cursor <cursoragent@cursor.com>
2026-09-16 21:06:30 +08:00
cflmyandCursor f95e5d3339 release: v1.0.2 — table-bound page intro (compose_intro)
Ship web_compose_intro / 引言装配 and web-site demo polish; bump Cargo and docs.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-09-16 21:05:49 +08:00
cflmyandCursor 52b4bae423 feat(web-site): harden sample desk, auth login, and form layout
Align nav/side/foot slots and shell CSS with table-driven admin desk;
add session login/logout mount and widen form fields for usable create UX.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-09-16 19:44:12 +08:00
cflmyandCursor 037592087c feat(web): table-bound intro and demo-grade web-site sample
Add compose_intro (属性/值/样式) so page heroes are not HTML strings, and polish examples/web-site for WWW Demo: literary shell, card→detail routes, richer seeds, particle atmosphere without author JS.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-09-16 17:34:49 +08:00
cflmyandCursor 3eb8e732ea release: v1.0.1 — fix Go libweb dynamic-route query, Markdown, CSS false positives
Co-authored-by: Cursor <cursoragent@cursor.com>
2026-09-15 14:48:47 +08:00
cflmyandCursor 761b92afce docs(public): keep narrative emphasis from executing as v0.3 code
Unbold code-shaped prose and give log.fields a map so pages and
`view output` stay green under markup v0.3.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-09-14 16:15:47 +08:00
75 changed files with 4161 additions and 334 deletions

No files matched your search

+136 -111
View File
@@ -1,16 +1,14 @@
---
name: marqdo-release
description: >-
Run a full Marqdo product release: detect latest version and ask the user for
the next tag, update CHANGELOG/README/skills/public docs, bump Cargo versions,
sync VS Code extension on branch vscode-extension when needed, build or
trigger install assets (Windows CLI + **required Linux native/CLI zips**,
stdlib, ext, public zip, VSIX), push via origin or
https://proxy.cflmy.top/github.com/cflmy/marqdo.git, publish GitHub Release
with detailed notes, and recover from network failures via that proxy or HK
SSH jump (scripts/push-via-hk-jump.py). Use when the user asks to release,
cut a version, publish vX.Y.Z, ship a GitHub release, 发版, 发布新版本, or tag
marqdo.
Run a Marqdo product release: detect latest version and ask the user for the
next tag (or confirm mode), update CHANGELOG/README/skills/public docs, bump
Cargo and/or ext/VERSION, sync VS Code extension when needed, publish GitHub
Release assets, upload extension packs to Cloudflare R2 (ext.marqdo.com) and
GitHub, ship Ubuntu CLI via PPA (scripts/ppa-ship.sh), and print manual
commands when sudo/GPG/network steps need the user. Use when the user asks to
release, cut a version, publish vX.Y.Z, ext-only pack, PPA, 发版, 发布新版本,
or tag marqdo.
---
# Marqdo release
@@ -19,166 +17,193 @@ Canonical release playbook for **cflmy/marqdo**. Read this skill **before** tagg
## Hard rules
1. **Never invent the next version.** Detect current versions → **stop and ask the user** for the next SemVer (`X.Y.Z`). Do not proceed until they confirm.
1. **Never invent the next version.** Detect current versions → **stop and ask the user** for the next SemVer (`X.Y.Z`) and **release mode** if unclear. Do not proceed until they confirm (unless they already stated both in the same message).
2. **Never force-push** `main` / tags. **Never** `--no-verify` unless the user explicitly orders it.
3. **Never commit `vscode-extension/` on `main`** (gitignored). Extension source lives only on branch **`vscode-extension`**. See `doc/design/vscode-extension-commit.md`.
4. **Do not release from a dirty tree** (except intentional release commits you create in this flow).
5. **Tag format** is always `vX.Y.Z` matching root `Cargo.toml` `version = "X.Y.Z"`.
6. Prefer **tag push → GitHub Actions** (`.github/workflows/release.yml`) for **both** Windows and **Linux** install assets. Local packaging is fallback / verification.
7. After network errors: apply [reference.md § Proxy](reference.md). **First try** `https://proxy.cflmy.top/github.com/cflmy/marqdo.git` (this clone’s usual `origin`). Retry; do not silently skip uploads. If the reverse-proxy still drops long pushes, use **HK jump** (`hk.cflmy.de`) via `scripts/push-via-hk-jump.py` — see reference § **Proxy** / **HK SSH jump**.
8. **Do not ship a GitHub Release without the Linux extension/native zip.** Job `linux` must attach `marqdo-VER-native-x86_64-unknown-linux-gnu.zip` (and the Linux CLI bundle). Missing Linux packages = release incomplete.
5. **Tag format:** CLI/full → `vX.Y.Z` matching root `Cargo.toml`. Ext-only → `ext-vX.Y.Z` matching `ext/VERSION` (Cargo may stay unchanged).
6. Prefer **tag push → GitHub Actions** (`.github/workflows/release.yml`) for Windows/Linux install assets. Local packaging is fallback / verification.
7. After network errors: apply [reference.md § Proxy](reference.md). **First try** `https://proxy.cflmy.top/github.com/cflmy/marqdo.git`. Retry; do not silently skip uploads. If needed: **HK jump** (`scripts/push-via-hk-jump.py`).
8. **Do not ship a full GitHub Release without the Linux extension/native zip** when the mode includes ext packs. Missing Linux packages = incomplete for that mode.
9. **Extension packs always publish to both** Cloudflare R2 (`https://ext.marqdo.com` via `scripts/upload-ext-r2.py`) **and** GitHub (Release assets / `ext-v*` tag). Credentials only in `~/.marqdo/r2.env` / CI — **never** commit. See [ext-cdn.md](../../../doc/design/ext-cdn.md).
10. **CLI Ubuntu package = PPA** (`ppa:cflmy/marqdo`) via `./scripts/ppa-ship.sh` / `ppa-build-source.sh`. GitHub zips remain for Windows and non-apt Linux.
11. **When a step needs the user** (sudo password, GPG passphrase, Launchpad UI, interactive `dput`): **stop, state what failed, and give the exact commands** to run in their terminal. Do not pretend the step succeeded.
## Defaults (after version is confirmed)
## Release modes
Unless the user overrides, apply these automatically — **do not re-ask**:
Ask (or take from user message) which mode:
| Mode | Bumps | Git tag | GitHub assets | R2 CDN | Ubuntu PPA |
|------|-------|---------|---------------|--------|------------|
| **full** (default) | `Cargo.toml` + `ext/VERSION` (same SemVer) | `vX.Y.Z` | CLI + ext + native + VSIX + … | yes | yes |
| **cli** | `Cargo.toml` only | `vX.Y.Z` | CLI (+ optional attach prior ext) | no (unless user asks) | yes |
| **ext** | `ext/VERSION` only | `ext-vX.Y.Z` (or attach to latest CLI release) | ext.zip + native-*.zip | **required** | no |
Defaults after version+mode confirmed — **do not re-ask**:
| Setting | Default |
|---------|---------|
| Sync / bump `vscode-extension` to same `VER` | **yes** |
| Push `main`, create annotated tag, push tag immediately (trigger CI) | **yes** |
| Release notes language | **中英双语** (Chinese first, then English section, or paired ZH/EN under each heading) |
| Skip VSIX | **no** |
| Docs-only release | **no** (full asset pipeline via CI) |
| Sync / bump `vscode-extension` to same `VER` | **yes** for full/cli; **no** for ext-only |
| Push `main`, create annotated tag, push tag (trigger CI) | **yes** for full/cli |
| Ext packs → R2 **and** GitHub | **yes** whenever ext ships |
| Ubuntu PPA upload after CLI tag | **yes** for full/cli |
| Release notes language | **中英双语** |
| Deploy gh-pages after release | **no** (only if user asks) |
Phase 0 asks **only** for the next version (and optional overrides). Example ask:
Phase 0 ask example:
> 当前最新是 **vA.B.C**。请指定下一个版本号(如 `0.3.2`)。其余按默认:同步扩展、立刻打 tag 发布、中英双语说明。
> 当前最新 CLI **vA.B.C**,扩展包 **E.F.G**。请指定下一个版本号与模式(`full` / `cli` / `ext`,如 `1.0.3 full`)。
## Phase 0 — Detect versions (mandatory stop)
Run in repo root (parallel OK):
```bash
python3 .cursor/skills/marqdo-release/scripts/detect_version.py
# or: rg / git tag / gh release list — see reference.md
```
Report briefly, then **ask only for the next SemVer** (defaults above). Wait for confirmation. Normalize to `VER=X.Y.Z` and `TAG=vX.Y.Z`.
Report briefly, then **ask for SemVer + mode** (unless already given). Normalize `VER` / `TAG`.
## Phase 1 — Preflight
Copy and track:
```
Release progress:
- [ ] Phase 0: version confirmed by user (TAG=…)
- [ ] Phase 0: version + mode confirmed
- [ ] Phase 1: preflight green
- [ ] Phase 2: docs + version bumps committed
- [ ] Phase 3: extension branch (if needed)
- [ ] Phase 3: extension branch (full/cli)
- [ ] Phase 4: main pushed; tag created & pushed
- [ ] Phase 5: CI / assets / release notes verified
- [ ] Phase 6: post-release checks
- [ ] Phase 5: CI / GitHub assets / notes
- [ ] Phase 6: R2 upload (if ext ships)
- [ ] Phase 7: Ubuntu PPA (full/cli)
- [ ] Phase 8: post-release checks
```
Checks:
1. `git status` clean or only release WIP you control.
2. `git checkout main && git pull --ff-only origin main`.
3. Quick gate: `cargo test --test gold structure_hello` (and any release-critical tests the user named). Full gold suite if time allows.
4. `CHANGELOG.md` has meaningful **Unreleased** notes; if empty, draft from `git log vLAST..HEAD --oneline` and confirm with user.
5. Confirm no secrets in the commit (`*.env`, credentials).
Checks: clean tree; `main` ff-only; smoke tests; CHANGELOG Unreleased; no secrets.
## Phase 2 — Docs & version bumps (main)
Bump **in lockstep**:
| File | Change |
|------|--------|
| `Cargo.toml` | `version = "VER"` |
| `crates/marqdo-wasm/Cargo.toml` | same `VER` |
| `CHANGELOG.md` | Move `## Unreleased` → `## vVER — YYYY-MM-DD`; leave fresh empty `## Unreleased` |
| `README.md` | 「现状 / 如何使用最新」version strings, checkout tag, release URL |
| `.cursor/skills/marqdo/SKILL.md` | Version-sensitive bullets if any (WASM/web status); keep rules accurate |
| `public/**` | User-facing tutorials if features shipped (welcome, features/*, extensions). Prefer small factual updates over rewrites |
| `doc/roadmap/*.md` | Mark shipped waves done if this release closes them |
| `.github/workflows/release.yml` | Update **Highlights** body template to this release (CI still uses hardcoded blurb—keep in sync) |
Public HTML: regenerate before packaging / pages deploy:
| File | full | cli | ext |
|------|------|-----|-----|
| `Cargo.toml` + `crates/marqdo-wasm/Cargo.toml` | bump | bump | — |
| `ext/VERSION` | bump | — | bump |
| `CHANGELOG.md` | `## vVER` | `## vVER` | `## Ext pack vVER` |
| `README.md` / `public/**` install + download table | update | update | update ext notes |
| `.cursor/skills/marqdo/SKILL.md` | if surface changed | same | rare |
| `.github/workflows/release.yml` Highlights stub | yes | yes | — |
```bash
./scripts/build-public.sh
# outputs under public/ (gitignored HTML); used by release zip / gh-pages
./scripts/build-public.sh # when public/ sources changed
```
Commit on `main` (HEREDOC message), e.g.:
```text
release: vVER — <one-line highlight>
EOF
```
Push `main` (this repo’s `origin` is usually the reverse proxy):
Commit + push `main` (proxy origin). On push failure → reference § Proxy; if still blocked, **print** for the user:
```bash
# origin typically: https://proxy.cflmy.top/github.com/cflmy/marqdo.git
git push origin main
# one-shot if origin still points at github.com:
git push https://proxy.cflmy.top/github.com/cflmy/marqdo.git HEAD:main
# or: python3 scripts/push-via-hk-jump.py
```
If that times out: [reference § HK SSH jump](reference.md).
## Phase 3 — VS Code / Cursor extension (full/cli only)
## Phase 3 — VS Code / Cursor extension
Default: bump `vscode-extension` package.json to `VER`, compile, push branch `vscode-extension`, return to `main`.
**Default: always** bump extension to `VER` on branch `vscode-extension` (skip only if user said so).
1. `git fetch origin vscode-extension`
2. Work on `vscode-extension` branch (not main):
- Bump `vscode-extension/package.json` `version` to `VER`.
- Update `engines` / CLI version hints in extension README if present.
- `npm ci && npm run compile`
3. Commit & `git push origin vscode-extension`.
4. Return to `main`. **Do not** add `vscode-extension/` to main.
## Phase 4 — Tag & trigger CI
## Phase 4 — Tag & trigger CI (full/cli)
```bash
git tag -a "TAG" -m "TAG"
git push origin "TAG"
git tag -a "vVER" -m "vVER"
git push origin "vVER"
```
This runs `.github/workflows/release.yml`:
Ext-only:
- **windows** — CLI exe/zip, stdlib zip, ext zip, source zip, public zip, VSIX, Windows native zip
- **linux** (`needs: windows`) — **required** Linux native plugins zip + Linux CLI bundle (`ext/` + `native/*.so`)
```bash
git tag -a "ext-vVER" -m "ext-vVER"
git push origin "ext-vVER"
```
If tag push fails: [reference.md § Proxy](reference.md) (`proxy.cflmy.top` first), retry once; then HK jump.
(or build zips locally / via workflow and `gh release upload`).
## Phase 5 — Release notes & assets
If tag push needs the user:
1. Wait for Actions success: `gh run list --workflow=Release --limit 3` / open the run URL. **Both** `windows` and `linux` jobs must be green.
2. Ensure GitHub Release for `TAG` exists with assets (workflow uses `softprops/action-gh-release`).
3. Confirm Linux assets exist: `marqdo-VER-native-x86_64-unknown-linux-gnu.zip` and `marqdo-VER-x86_64-unknown-linux-gnu.zip`. If missing, do **not** call the release done — re-run / upload.
4. **Rewrite release body** (workflow body is a stub) with **中英双语** — see [reference.md § Notes template](reference.md). `gh release edit TAG --notes-file …`.
4. Include: Highlights, Breaking, Install (`ext add`, plugins build), Downloads table, WASM (`marqdo wasm build`), links to CHANGELOG/README, extension branch note.
5. Optional Linux local extras (not required if CI green): `marqdo wasm build` smoke; document in notes that wasm is built from source via CLI.
```bash
git push https://proxy.cflmy.top/github.com/cflmy/marqdo.git vVER
```
Local Windows fallback: `scripts/release-full.ps1 -Tag TAG -Upload` (see script header).
## Phase 5 — GitHub Release notes & assets
## Phase 6 — Post-release
1. Wait for Actions (full/cli): both `windows` and `linux` green when ext natives required.
2. Rewrite release body 中英双语 — [reference.md § Notes](reference.md).
3. Confirm Linux `marqdo-VER-native-x86_64-unknown-linux-gnu.zip` when mode ships ext.
1. `gh release view TAG` — confirm assets + notes.
2. `git status` clean; `main` synced.
3. Tell user: release URL `https://github.com/cflmy/marqdo/releases/tag/TAG`.
4. Optional: `./scripts/deploy-public.ps1` / pages workflow if user wants user-site refresh.
5. Open fresh `## Unreleased` already done in Phase 2.
## Phase 6 — Extension CDN (R2) — required when ext ships
```bash
# credentials: ~/.marqdo/r2.env (never commit)
python3 scripts/upload-ext-r2.py --version VER --from-dir dist/
curl -fsS https://ext.marqdo.com/latest/VERSION
```
Also ensure the **same** zips are on GitHub (`vVER` or `ext-vVER`). If R2 credentials missing, **tell the user**:
```bash
# put keys in ~/.marqdo/r2.env then:
python3 scripts/upload-ext-r2.py --version VER --from-dir dist/
```
## Phase 7 — Ubuntu PPA (full/cli)
Linux CLI for apt users. After `Cargo.toml` is at `VER` and `debian/changelog` has a matching `VER-1ppaN` stanza:
```bash
./scripts/ppa-ship.sh noble
```
Packaging notes / noble Cargo.lock v4: [ubuntu-ppa.md](../../../doc/design/ubuntu-ppa.md).
**If the agent cannot sudo / sign / dput**, print exactly:
```bash
cd ~/work/marqdo
./scripts/ppa-ship.sh noble
# or build then upload:
./scripts/ppa-build-source.sh noble
dput ppa:cflmy/marqdo ../build-area/marqdo_*~noble_source.changes
```
Watch: https://launchpad.net/~cflmy/+archive/ubuntu/marqdo/+builds
On Launchpad failure: read the build log, fix `debian/` or bundle script, bump `1ppaN`, re-upload. Tell the user the new `dput` command.
## Phase 8 — Post-release
1. `gh release view TAG` — assets + notes.
2. CDN `https://ext.marqdo.com/vVER/` (if ext shipped).
3. PPA build green (if cli shipped).
4. Tell user URLs: GitHub release, CDN, PPA install one-liner.
5. Optional gh-pages only if asked.
## Extension-only release (mode=ext)
1. User confirms **ext** SemVer (may differ from CLI).
2. Bump `ext/VERSION`; CHANGELOG → `## Ext pack vVER`.
3. Build/package `marqdo-VER-ext.zip` + `marqdo-VER-native-*.zip` (CI or local).
4. Upload to **R2 and GitHub** (required both).
5. Do **not** retag CLI / do **not** PPA unless user also asked for cli.
## Failure matrix (short)
| Failure | Action |
|---------|--------|
| `gh` / git TLS or Clash `7890` refused | Unset bad proxy; `required_permissions: ["all"]`; see [reference § Proxy](reference.md) |
| GitHub blocked | **`origin` via proxy.cflmy.top** (see below), then HK jump |
| Tag exists | Stop; ask user to bump or delete tag (no force on shared tags without explicit order) |
| CI red | Fix on main, move tag only if user explicitly allows delete+re-push tag |
| VSIX missing | Fetch `vscode-extension`, build locally, `gh release upload TAG dist/*.vsix` |
| Linux native/CLI zip missing | Incomplete release — fix `linux` job or `gh release upload`; do not skip |
| `gh` / git TLS or Clash `7890` refused | Unset bad proxy; see [reference § Proxy](reference.md) |
| GitHub blocked | proxy.cflmy.top, then HK jump; **print commands** if agent cannot push |
| Tag exists | Stop; ask user |
| CI red | Fix on main; retag only if user allows |
| R2 upload fails | Print `upload-ext-r2.py` command; do not skip silently |
| PPA / sudo / GPG | Print `./scripts/ppa-ship.sh noble` (or `dput …`); do not skip silently |
| Launchpad `Cargo.lock` v4 / old cargo | Ensure bundled `third_party/rust` via current `ppa-build-source.sh`; bump `1ppaN` |
| Linux native zip missing (full/ext) | Incomplete — fix linux job or upload |
## Do not
- Ship without user-confirmed version.
- Hardcode release highlights only in Actions YAML and forget CHANGELOG.
- Commit `target/`, `dist/`, `*.wasm`, or `public/**/*.html` unless project policy changes.
- Ship without user-confirmed version (and mode when ambiguous).
- Ship ext packs to only one of R2 / GitHub.
- Call a full/cli release done without attempting PPA **or** giving the user the PPA commands.
- Commit `target/`, `dist/`, `*.wasm`, `third_party/rust/`, or `public/**/*.html` unless policy changes.
- Merge extension tree into `main`.
+2 -2
View File
@@ -19,7 +19,7 @@ Canonical design (repo): [`markdown-mapping-v0.3.md`](../../doc/design/markdown-
**Authoring / library craft** (GFM-first, no json glue, how to develop Marqdo): use **[marqdo-dev](../marqdo-dev/SKILL.md)** whenever writing or refactoring `.mq.md`, `lib/*`, or `ext/*`.
**Product release** (tag, CHANGELOG, README, public docs, VSIX, GitHub assets): use [marqdo-release](../marqdo-release/SKILL.md) — detect latest version, **ask the user for the next SemVer**, then follow that playbook. Do not invent a version number.
**Product release** (tag, CHANGELOG, README, public docs, VSIX, GitHub assets, **ext → R2+GitHub**, **CLI → Ubuntu PPA**): use [marqdo-release](../marqdo-release/SKILL.md) — detect versions, **ask for SemVer + mode (`full` / `cli` / `ext`)**, then follow that playbook. Ext-only releases are allowed. If sudo/GPG/PPA steps need the user, print the exact commands.
## Hard rules (do not violate)
@@ -199,7 +199,7 @@ data/ # sqlite runtime (gitignore)
**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`).
**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`).
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/).
+9
View File
@@ -0,0 +1,9 @@
# Ext CDN / R2 (Cloudflare) — copy to ~/.marqdo/r2.env and chmod 600
# Never commit real keys. Public downloads: https://ext.marqdo.com
R2_ACCOUNT_ID=
R2_BUCKET=marqdo
R2_ENDPOINT=https://<accountid>.r2.cloudflarestorage.com
R2_ACCESS_KEY_ID=
R2_SECRET_ACCESS_KEY=
R2_PUBLIC_BASE=https://ext.marqdo.com
+3 -2
View File
@@ -124,8 +124,9 @@ jobs:
## Marqdo ${{ github.ref_name }}
### 亮点 / Highlights
- **v1.0.0**:Markdown 语法映射 v0.3 为唯一运行时(`**` 代码 / `*` 返回 / 叙述 `` `名` ``)
- **v1.0.0**: markup mapping v0.3 is the sole runtime (`**` code / `*` return / prose decls)
- **v1.0.3**:Ubuntu PPA + 扩展 CDN(ext.marqdo.com);CLI/扩展可分发;noble 捆绑 Rust 工具链
- **v1.0.3**: Ubuntu PPA + extension CDN; independent CLI/ext packs; bundled Rust for noble
- **v1.0.1**:修复 Go `libweb` 动态路由 `{param}` 查询代入、详情 Markdown、CSS 数字误报
- **Linux 包必出**:`*-native-x86_64-unknown-linux-gnu.zip` + Linux CLI bundle
- Details: [CHANGELOG](https://github.com/cflmy/marqdo/blob/main/CHANGELOG.md) · [mapping v0.3](https://github.com/cflmy/marqdo/blob/main/doc/design/markdown-mapping-v0.3.md)
+6 -1
View File
@@ -24,7 +24,8 @@
.marqdo/
**/.marqdo/
.marqdo-ext/
.env
/vendor/
/.cargo/config.toml
# Generated HTML beside tracked public/*.mq.md (sources stay in git)
/public/index.html
@@ -77,5 +78,9 @@ plugins/*/tmp/
# Go web plugin c-shared build output (./scripts/build-web-plugin.sh)
/plugins/web/build/
# PPA build: bundled Rust toolchain (packed into .orig by ppa-build-source.sh only)
/third_party/rust/
/third_party/
# ephemeral sqlite / test artifacts
tests/ext/:memory:
+80
View File
@@ -8,6 +8,86 @@
### Changed
## v1.0.3 — 2026-09-17
### Highlights
**分发渠道齐备**:Ubuntu PPA 装 CLI;扩展包走 CDN(`ext.marqdo.com`)与 GitHub;CLI 与扩展可分开发版。本版 CLI 与扩展包 **同步为 1.0.3**。
**语法**:未绑定的 GFM 表格是可丢弃的集合值,不再报 `unrecognized statement`(文档页可直接写安装表)。
```bash
# Ubuntu
sudo add-apt-repository ppa:cflmy/marqdo
sudo apt update && sudo apt install marqdo
marqdo ext add web
# 或源码 / Releases
git checkout v1.0.3 && cargo build --release
```
### Added
- Ubuntu PPA packaging: `debian/` + `scripts/ppa-ship.sh` (一键装工具/打包/dput) + `ppa-build-source.sh` + [ubuntu-ppa.md](doc/design/ubuntu-ppa.md).
- **Extension CDN** (`https://ext.marqdo.com` / Cloudflare R2):`ext add` 下载顺序改为 CDN → GitHub → proxy;独立包版本见 `ext/VERSION` 与 CDN `latest/VERSION`;上传脚本 `scripts/upload-ext-r2.py`(凭据 `~/.marqdo/r2.env`)。设计见 [ext-cdn.md](doc/design/ext-cdn.md)。
- `ext add` 下载:GitHub 失败后自动回退 `https://proxy.cflmy.top/github.com/…`;可用 `MARQDO_EXT_DOWNLOAD_BASE` 指定首选镜像;加长读写超时。
- 用户文档(README / `public/00-欢迎` / `features/05-扩展`)标明安装渠道:Ubuntu PPA、GitHub Releases、源码;扩展走 CDN。
### Fixed
- `ext/` 导入默认搜索 `~/.marqdo/ext`(与 `marqdo ext add` 安装根一致),无需再手动 `export MARQDO_EXT`。
- PPA/noble:捆绑 `third_party/rust`(现代 cargo)以构建 Cargo.lock v4;修复首次 Launchpad 构建失败(distro cargo 1.75)。
- 未绑定的 GFM 表格不再报 `unrecognized statement`:作为集合值求值后丢弃(文档中可写表)。
### Changed
- 允许 **CLI 与扩展包分开发版**:扩展包 SemVer 可与 `Cargo.toml` 不同(`MARQDO_EXT_VERSION` / `ext/VERSION` / CDN latest)。
- 发版 skill:支持 `full` / `cli` / `ext`;扩展必传 R2+GitHub;CLI 走 PPA;需用户操作时打印确切命令。
## v1.0.2 — 2026-09-16
### Highlights
**表驱动页面引言(`compose_intro` / `引言装配`)**:英雄区用 GFM「属性 / 值 / 样式」表声明,不再手写 HTML 字符串;WWW Demo 样站与后台门禁一并加固。
```bash
git checkout v1.0.2
cargo build --release
bash ./scripts/build-web-plugin.sh
# 或:解压 Release 的 marqdo-1.0.2-*-native-*.zip / Linux CLI zip
marqdo run examples/web-site-zh/index.mq.md
```
### Added
- Go `libweb`:`web_compose_intro` — 将引言表装配为 `.main-intro` HTML;中英 API `页面.引言装配` / `page.compose_intro`(`ext/web`)。
- 验收样例:`tests/ext/web-intro-compose.mq.md`;`examples/web-site` / `web-site-zh` 升级为表驱动引言 + 文学风壳层 + 卡片→详情路由。
### Fixed
- 后台样站:导航/侧栏/页脚槽位与门禁登录挂载对齐;表单字段加宽便于创建。
### Changed
- Demo 叙述与种子数据面向 WWW Industry / 可复现演示;作者仍零业务 JS、零手写 `.css`。
## v1.0.1 — 2026-09-15
### Highlights
**ext/web(Go libweb)回归修复**:动态路由查询条件恢复 `{param}` 代入;详情 SSR + Markdown;样式表数字不再误报。
```bash
git checkout v1.0.1
cargo build --release
bash ./scripts/build-web-plugin.sh
# 或:解压 Release 的 marqdo-1.0.1-*-native-*.zip / Linux CLI zip
marqdo run examples/marqdo-blog/index.mq.md
```
### Added
- Go web plugin:详情页正文 Markdown(goldmark GFM),对齐 Rust `pulldown-cmark` 路径。
### Fixed
- **动态路由 `{param}` 未代入查询条件**(`ext/web` Go):`selectPageData` 递归展开 `query` 全部字符串叶子;`data-slot-src` / `_route` 同步替换。`examples/marqdo-blog` `/post/{slug}` 详情 SSR 恢复。
- **样式表数字单元格误报「可疑 `/` 除法」**:`cssValueSuspicious` 不再把合法 `z-index`/`opacity` 等 number 当警告。
- Go 1.22+ ServeMux:`/static/` 与 `/static/favicon.svg` 的 GET/HEAD 注册冲突导致博客启动 panic。
- Rust archive 同步:`resolve_placeholders` 递归 + CSS number 误报收窄(非默认构建路径)。
## v1.0.0 — 2026-09-14
### Highlights
Generated
+2 -2
View File
@@ -572,7 +572,7 @@ checksum = "0ceec5bc11778974d1bcb055b18002eba7f4b3518b6a0081b3af5f21666da9ad"
[[package]]
name = "marqdo"
version = "1.0.0"
version = "1.0.3"
dependencies = [
"anyhow",
"assert_cmd",
@@ -603,7 +603,7 @@ dependencies = [
[[package]]
name = "marqdo-wasm"
version = "1.0.0"
version = "1.0.3"
dependencies = [
"marqdo",
"serde_json",
+1 -1
View File
@@ -1,6 +1,6 @@
[package]
name = "marqdo"
version = "1.0.0"
version = "1.0.3"
edition = "2021"
license = "Apache-2.0"
description = "Marqdo — Markdown markers as an interpreted programming language"
+18 -7
View File
@@ -98,7 +98,7 @@ marqdo catalog public -o .marqdo
---
## 现状(v1.0.0)
## 现状(v1.0.3)
- 映射与解释器:**v0.3 语法宪法**(`**` 代码 / `*` 返回 / 叙述声明);Phase I 树遍历 + 字节码后端;金样例在 `tests/` 与 `tests/markup-v03/`
- **对象**:`#` = 类型/构造,`##`+ = 函数/方法;见 [objects.md](doc/design/objects.md)
@@ -108,7 +108,7 @@ marqdo catalog public -o .marqdo
- **`marqdo version --check`**:与 GitHub 最新 release 对比
- 标准库:**内置于二进制**(v0.1.2+);磁盘 `lib/` 或 `MARQDO_LIB` 可覆盖。模块含文本、表、**浏览器效应**、文件、系统、时间、JSON、网络、数学、外联、插件、**自写回**、**子任务**;**中层 Mid M1–M6** + **Mid2 M7–M10**(datetime/url/toml/html/fs++/stats/log.fields 等,见 [stdlib-mid.md](doc/design/stdlib-mid.md) · [stdlib-mid2.md](doc/design/stdlib-mid2.md))
- **官方扩展库 `ext/`**(**非** stdlib,本版收口):
- **`web`**:W0–W7 + P3 + **W8**;**定制 C0–C4**;**宿主 H1–H2**(`proxy`/`invoke`,见 [ext-hosting.md](doc/roadmap/ext-hosting.md));原生层默认 **Go `libweb`**([ADR 0004](doc/adr/0004-web-plugin-go.md),`scripts/build-web-plugin.sh`);示例 [marqdo-blog](examples/marqdo-blog/) · [anlian-mq](examples/anlian-mq/);生产路径见 [web-asgi-servers-and-marqdo.md](doc/design/web-asgi-servers-and-marqdo.md)
- **`web`**:W0–W7 + P3 + **W8**;**定制 C0–C4**;**宿主 H1–H2**(`proxy`/`invoke`,见 [ext-hosting.md](doc/roadmap/ext-hosting.md));**表驱动引言**(`compose_intro` / `引言装配`);原生层默认 **Go `libweb`**([ADR 0004](doc/adr/0004-web-plugin-go.md),`scripts/build-web-plugin.sh`);示例 [web-site](examples/web-site/) · [web-site-zh](examples/web-site-zh/) · [marqdo-blog](examples/marqdo-blog/) · [anlian-mq](examples/anlian-mq/);生产路径见 [web-asgi-servers-and-marqdo.md](doc/design/web-asgi-servers-and-marqdo.md)
- **`quantum`**:Q0–Q7 + Q8a/b 主题 SVG;示例 [quantum-entanglement](examples/quantum-entanglement/)
- **`linalg`**:L0–L6 + 公式文档面(中缀 / `declare` / 展示化简);示例 [linalg-transpose](examples/linalg-transpose/) · [linalg-svd](examples/linalg-svd/) · [linalg-least-squares](examples/linalg-least-squares/)
- **`agent`**:A1–A4 + **MCP Server stdio**(`mcp_server`);宿主缺口见 [ext-hosting.md](doc/roadmap/ext-hosting.md) · [agent-framework-gaps-after-a4.md](doc/research/agent-framework-gaps-after-a4.md)
@@ -120,12 +120,22 @@ marqdo catalog public -o .marqdo
- **浏览器 Marqdo(WASM)**:`marqdo wasm build` + 官方 bridge 自启(作者零业务 JS;桥内可含列表/路由/storage/ws/文件/Canvas/音频/Observer/拖放);`lib/browser` + GFM;`web.client_embed`;示例 [browser-hello](examples/browser-hello/) · [browser-app](examples/browser-app/) · [browser-media](examples/browser-media/) · [web-client-site](examples/web-client-site/)([ADR 0002](doc/adr/0002-browser-marqdo-wasm.md) · [D](doc/roadmap/browser-wasm-d.md) · [E](doc/roadmap/browser-wasm-e.md) · [F](doc/roadmap/browser-wasm-f.md))
- 选型:[ADR 0001 — Rust](doc/adr/0001-implementation-language.md) · [ADR 0002 — 浏览器 WASM](doc/adr/0002-browser-marqdo-wasm.md)(C0–C5 完结,见 [roadmap/browser-wasm.md](doc/roadmap/browser-wasm.md))· [ADR 0003 — 异步效应](doc/adr/0003-browser-async-effects.md)
### 如何使用最新 Marqdo(v1.0.0)
### 如何使用最新 Marqdo(v1.0.3)
**安装解释器(任选其一)**
| 方式 | 适用 | 命令 / 链接 |
|------|------|-------------|
| **Ubuntu PPA** | Ubuntu 24.04+(`noble` 等) | `sudo add-apt-repository ppa:cflmy/marqdo && sudo apt update && sudo apt install marqdo` |
| **GitHub Releases** | Windows / Linux 预编译 zip | https://github.com/cflmy/marqdo/releases |
| **源码** | 需本机 Rust | 见下方 `git clone` + `cargo build --release` |
**安装官方扩展**(与 CLI 可分开发版):`marqdo ext add …` 默认下载顺序为 **CDN** [`https://ext.marqdo.com`](https://ext.marqdo.com) → GitHub Releases → [`proxy.cflmy.top`](https://proxy.cflmy.top) 镜像。
```bash
# 1) 源码安装(跟 tag 或 main)
git clone https://github.com/cflmy/marqdo.git && cd marqdo
git checkout v1.0.0 # 或留在 main
git checkout v1.0.3 # 或留在 main
cargo build --release
export PATH="$PWD/target/release:$PATH"
marqdo version
@@ -138,7 +148,7 @@ marqdo view public --no-open
marqdo debug public --no-open
marqdo catalog public -o .marqdo
# 3) 安装官方扩展(Release 用户:无需本机 Rust/Go)
# 3) 安装官方扩展(Release / CDN 用户:无需本机 Rust/Go)
marqdo ext add web # 或:网页 — 自动下载 L1 + 预编译 native(Go libweb)
marqdo ext add agent # 或:智能体
marqdo ext add quantum # 或:量子
@@ -149,6 +159,7 @@ marqdo ext add llm # 或:大模型(纯 .mq.md)
# 离线:解压 Windows zip(已含 ext/native)或手动放下 native zip;MARQDO_EXT_NO_DOWNLOAD=1
# 4) 动态站示例(扩展装好后)
marqdo run examples/web-site-zh/index.mq.md # 表驱动引言 Demo
marqdo run examples/marqdo-blog/index.mq.md
marqdo run examples/anlian-mq/index.mq.md # W-G14 验收站
# 浏览器打开终端打印的 listen 地址;/favicon.ico 与 logo 装配见 W8
@@ -158,7 +169,7 @@ marqdo wasm build
# → dist/wasm/ … 见 examples/browser-hello/
# 6) Releases:Windows exe/zip/vsix;Linux CLI zip + native `.so` zip
# https://github.com/cflmy/marqdo/releases/tag/v1.0.0
# https://github.com/cflmy/marqdo/releases/tag/v1.0.3
```
开发期也可用 `cargo run -- …` 代替已安装的 `marqdo`:
@@ -170,7 +181,7 @@ cargo run -- view output public -o public
powershell -File ./scripts/build-public.ps1
```
**发布包(GitHub Releases)**:单独二进制 **已内置**官方 `lib/`(`import …:lib/…` 可直接导入)。仍提供带 `lib/` 的 zip 便于覆盖或离线分发。**扩展库**用 `marqdo ext add …` 安装(见 [CHANGELOG](CHANGELOG.md) 与 [ext-cli.md](doc/design/ext-cli.md));原生 `.so`/`.dll` 需本地编译或从带 `native/` 的安装目录解析。
**发布包**:GitHub Releases 的单独二进制 **已内置**官方 `lib/`。Ubuntu 用户优先 **PPA** 装 CLI。**扩展库**用 `marqdo ext add …`(CDN → GitHub);设计见 [ext-cdn.md](doc/design/ext-cdn.md) · [ubuntu-ppa.md](doc/design/ubuntu-ppa.md) · [ext-cli.md](doc/design/ext-cli.md)。
文档:用户站 [public/](public/) · 设计 [doc/](doc/) · OKF / catalog [catalog-cli.md](doc/design/catalog-cli.md) · 调试 [view-debug.md](doc/design/view-debug.md) · 变更 [CHANGELOG.md](CHANGELOG.md)
---
+1 -1
View File
@@ -1,6 +1,6 @@
[package]
name = "marqdo-wasm"
version = "1.0.0"
version = "1.0.3"
edition = "2021"
license = "Apache-2.0"
description = "Marqdo interpreter as WebAssembly (browser host bridge)"
+22
View File
@@ -0,0 +1,22 @@
Marqdo for Ubuntu (PPA)
=======================
This package installs the marqdo CLI (/usr/bin/marqdo).
Official language extensions are not bundled. After install:
marqdo ext add web
marqdo ext add quantum
Extension packs download from https://ext.marqdo.com (then GitHub / proxy).
Install this package from:
sudo add-apt-repository ppa:cflmy/marqdo
sudo apt update
sudo apt install marqdo
Also available: GitHub Releases (Windows/Linux zips) and building from source.
Documentation: https://github.com/cflmy/marqdo
PPA notes: doc/design/ubuntu-ppa.md in the upstream repository.
+20
View File
@@ -0,0 +1,20 @@
marqdo (1.0.3-1ppa1) noble; urgency=medium
* Marqdo 1.0.3: PPA + ext CDN; unbound GFM tables; bundled Rust for noble.
-- cflmy <pingan@cflmy.cn> Thu, 17 Sep 2026 10:35:00 +0800
marqdo (1.0.2-1ppa2) noble; urgency=medium
* Bundle Rust toolchain in orig (third_party/rust) so noble can build
Cargo.lock v4 offline; drop distro cargo/rustc Build-Depends.
* Architecture: amd64 (bundled toolchain is x86_64).
-- cflmy <pingan@cflmy.cn> Thu, 17 Sep 2026 10:20:00 +0800
marqdo (1.0.2-1ppa1) noble; urgency=medium
* Initial Ubuntu PPA packaging for Marqdo 1.0.2.
* CLI only; extensions via "marqdo ext add" / ext.marqdo.com.
-- cflmy <pingan@cflmy.cn> Thu, 17 Sep 2026 09:55:00 +0800
+29
View File
@@ -0,0 +1,29 @@
Source: marqdo
Section: devel
Priority: optional
Maintainer: cflmy <pingan@cflmy.cn>
Build-Depends:
debhelper-compat (= 13),
build-essential,
pkg-config,
libssl-dev,
ca-certificates
Standards-Version: 4.7.0
Homepage: https://github.com/cflmy/marqdo
Vcs-Git: https://github.com/cflmy/marqdo.git
Vcs-Browser: https://github.com/cflmy/marqdo
Rules-Requires-Root: no
Package: marqdo
Architecture: amd64
Depends: ${shlibs:Depends}, ${misc:Depends}, ca-certificates
Description: Markdown markers as an interpreted programming language
Marqdo treats Markdown markers as executable syntax (code / return /
control flow). This package installs the marqdo CLI.
.
Official extensions (web, quantum, …) are installed separately via
"marqdo ext add" and download from https://ext.marqdo.com .
.
Launchpad builds use a bundled Rust toolchain under third_party/rust
(Ubuntu noble cargo is too old for Cargo.lock v4). Rebuilds on newer
series may use distro rustc if cargo ≥ 1.78.
+24
View File
@@ -0,0 +1,24 @@
Format: https://www.debian.org/doc/packaging-manuals/copyright-format/1.0/
Upstream-Name: marqdo
Upstream-Contact: cflmy <pingan@cflmy.cn>
Source: https://github.com/cflmy/marqdo
Files: *
Copyright: 2024-2026 cflmy
License: Apache-2.0
License: Apache-2.0
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
.
http://www.apache.org/licenses/LICENSE-2.0
.
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
.
On Debian systems, the complete text of the Apache License version 2
can be found in "/usr/share/common-licenses/Apache-2.0".
Vendored Executable
+53
View File
@@ -0,0 +1,53 @@
#!/usr/bin/make -f
export DH_VERBOSE = 1
# Offline builds on Launchpad: vendored crates + optional bundled Rust toolchain.
export CARGO_HOME = $(CURDIR)/debian/cargo_home
export CARGO_NET_OFFLINE = true
# Noble (and older) distro cargo cannot read Cargo.lock v4 / modern crates.
# Prefer third_party/rust from the orig tarball when present (see ppa-build-source.sh).
BUNDLED_RUST = $(CURDIR)/third_party/rust
ifneq ($(wildcard $(BUNDLED_RUST)/bin/cargo),)
export PATH := $(BUNDLED_RUST)/bin:$(PATH)
endif
%:
dh $@
override_dh_auto_configure:
mkdir -p debian/cargo_home
@if [ -x "$(BUNDLED_RUST)/bin/cargo" ]; then \
echo "Using bundled Rust: $$($(BUNDLED_RUST)/bin/rustc --version)"; \
else \
echo "Using system Rust: $$(rustc --version 2>/dev/null || echo missing)"; \
fi
@if [ -f "$(CURDIR)/.cargo/config.toml" ] || [ -d "$(CURDIR)/vendor" ]; then \
echo "Using vendored Cargo dependencies"; \
else \
echo "WARNING: no vendor/ — online cargo fetch required (not for Launchpad)"; \
fi
override_dh_auto_build:
mkdir -p debian/cargo_home
@command -v cargo >/dev/null || { echo "error: cargo not found (bundle third_party/rust or install rustc/cargo)" >&2; exit 1; }
if [ -d "$(CURDIR)/vendor" ]; then \
CARGO_NET_OFFLINE=true cargo build --release --locked --offline \
-p marqdo; \
else \
cargo build --release --locked -p marqdo; \
fi
override_dh_auto_test:
@echo "Skipping full test suite on package build (run cargo test in CI)."
override_dh_auto_install:
install -d $(CURDIR)/debian/marqdo/usr/bin
install -m 0755 $(CURDIR)/target/release/marqdo \
$(CURDIR)/debian/marqdo/usr/bin/marqdo
override_dh_auto_clean:
dh_auto_clean
rm -rf debian/cargo_home
# keep vendor/ and third_party/rust (part of source package)
-cargo clean
+1
View File
@@ -0,0 +1 @@
3.0 (quilt)
+2
View File
@@ -0,0 +1,2 @@
# Ignore temporary files while editing patches
extend-diff-ignore = "^vendor/"
+2
View File
@@ -53,6 +53,8 @@
| [design/ext-agent.md](design/ext-agent.md) | **官方扩展 `ext/agent`(文档驱动:单步 / 多步工作簿 + 自写回;废弃 thin TOOL 循环)** |
| [design/ext-agent-plan.md](design/ext-agent-plan.md) | **`## 多步` / `## plan` 锁定设计**(工作簿文件、subtask 执行、修订循环、`step` 默认写回) |
| [design/ext-cli.md](design/ext-cli.md) | **`marqdo ext list/add/remove` 官方扩展安装器** |
| [design/ext-cdn.md](design/ext-cdn.md) | **扩展 CDN(R2 / ext.marqdo.com)与分开发版** |
| [design/ubuntu-ppa.md](design/ubuntu-ppa.md) | **Ubuntu PPA 打包与上传** |
| [design/ext-web.md](design/ext-web.md) | **官方扩展 `ext/web`(页面/库表/绑定/后台;ABI + CLI;设计锁定)** |
| [design/ext-web-go-rewrite.md](design/ext-web-go-rewrite.md) | **`plugins/web` Go 全量重写**(多语言 ABI · 网页制备完备 · anlian 验收) |
| [adr/0004-web-plugin-go.md](adr/0004-web-plugin-go.md) | **Accepted:web 原生插件实现语言为 Go** |
+66
View File
@@ -0,0 +1,66 @@
# Extension CDN (Cloudflare R2 → https://ext.marqdo.com)
| | |
|---|---|
| Status | **Accepted** — download prefer CDN; upload via `scripts/upload-ext-r2.py` |
| Date | 2026-09-17 |
| Related | [ext-cli.md](ext-cli.md) · [marqdo-release](../../.cursor/skills/marqdo-release/SKILL.md) |
## Why
CLI (语法解释器) and official **extension packs** (`ext/` L1 + native plugins) update on different cadences. Users behind unstable GitHub links should get packs from a stable object store first.
## Public URL layout
Bucket: `marqdo` · Custom domain: **https://ext.marqdo.com**
| Key | Meaning |
|-----|---------|
| `v{VER}/marqdo-{VER}-ext.zip` | L1 sources |
| `v{VER}/marqdo-{VER}-native-{triple}.zip` | Prebuilt plugins |
| `v{VER}/VERSION` | Pack SemVer echo |
| `latest/VERSION` | Recommended pack SemVer (plain text) |
| `latest/marqdo-…zip` | Same assets mirrored for convenience |
`{VER}` is the **extension pack** version (`ext/VERSION`), which **may differ** from CLI `Cargo.toml` version.
## Client download order (`marqdo ext add`)
1. `MARQDO_EXT_DOWNLOAD_BASE` (optional override)
2. **CDN** `https://ext.marqdo.com/v{VER}/…` (override host with `MARQDO_EXT_CDN`)
3. GitHub Releases
4. `https://proxy.cflmy.top/github.com/…`
Pack SemVer resolution (`release_version()`):
1. `MARQDO_EXT_VERSION`
2. CDN `GET …/latest/VERSION` (short timeout)
3. Embedded `ext/VERSION` at build time
4. CLI `CARGO_PKG_VERSION`
## Separate ext release (no CLI bump)
1. Bump `ext/VERSION` (e.g. `1.0.3`) — leave root `Cargo.toml` alone if CLI unchanged.
2. Build native zips (CI Linux/Windows jobs or local `scripts/build-web-plugin.sh` + cargo plugins).
3. Package `marqdo-{VER}-ext.zip` and `marqdo-{VER}-native-*.zip`.
4. Upload **both**:
- R2: `python3 scripts/upload-ext-r2.py --version VER --from-dir dist/`
- GitHub: attach to a GitHub Release (tag `ext-vVER` **or** reuse latest CLI release assets)
5. Confirm `https://ext.marqdo.com/latest/VERSION` and a sample zip URL return 200.
## Full product release (CLI + ext)
Keep `ext/VERSION` equal to (or compatible with) CLI SemVer unless documenting a deliberate skew. CI still publishes GitHub assets; **after** CI green, run `upload-ext-r2.py` so CDN is populated (or add a CI step with R2 secrets).
## Credentials
| Where | What |
|-------|------|
| Local | `~/.marqdo/r2.env` (`chmod 600`) — see `.env.r2.example` |
| CI (optional) | GitHub Actions secrets: `R2_ACCESS_KEY_ID`, `R2_SECRET_ACCESS_KEY`, `R2_ENDPOINT`, `R2_BUCKET` |
**Never** commit Account API tokens or S3 secret keys. If a token was pasted into chat, **rotate** it in the Cloudflare dashboard.
## Object ACL
Custom domain public reads require the bucket/objects to be publicly readable (R2 public bucket / r2.dev / custom domain). Uploads use S3 API credentials; downloads by `ext add` are anonymous HTTPS GETs.
+7 -1
View File
@@ -51,10 +51,16 @@ L1 sources:
| Variable | Meaning |
|----------|---------|
| `MARQDO_EXT_VERSION` | Override SemVer used for Release asset names (default: CLI `CARGO_PKG_VERSION`) |
| `MARQDO_EXT_VERSION` | Override **extension pack** SemVer (default: CDN `latest/VERSION` → embedded `ext/VERSION` → CLI version) |
| `MARQDO_EXT_CDN` | Public CDN base (default `https://ext.marqdo.com`) |
| `MARQDO_EXT_NO_DOWNLOAD=1` | Never hit the network (CI / air-gap); local/cargo only |
| `MARQDO_EXT_DOWNLOAD_BASE` | Optional extra base tried **before** CDN |
| `MARQDO_WEB_PLUGIN` / `MARQDO_AGENT_PLUGIN` / `MARQDO_QUANTUM_PLUGIN` | Explicit native path |
Download order for each Release asset: `MARQDO_EXT_DOWNLOAD_BASE` → **CDN `ext.marqdo.com`** → `github.com` → **`proxy.cflmy.top`**. Connect timeout 20s; read timeout 10min.
See [ext-cdn.md](ext-cdn.md) for R2 layout, separate ext releases, and `scripts/upload-ext-r2.py`.
Windows Release **zip** also ships `ext/` + `ext/native/*.dll` next to `marqdo.exe` so a portable unzip works offline after one download.
## Source for `add` (developers)
+1 -1
View File
@@ -211,7 +211,7 @@ v0.3:
| 体内 `1.` `2.` … | 分支 |
| 体内 `-` | 循环 |
| `N. *` | else 臂(此处 `*` 仍是「空条件」标记,**不是**返回值;见 §7.3) |
| GFM 表格 | 集合(不变) |
| GFM 表格 | 集合;`` `名` = `` 后绑定,或**未绑定**时求值后丢弃(文档中可写表) |
| 表达式 `[键](集合)` | **取元**(与 foreach 同形;见 [collection-access-link.md](collection-access-link.md)) |
| `修饰… [函数名] 实参…` | **方括号标记调用**(前置修饰 → `名=True`;见 [bracket-call-modifiers.md](bracket-call-modifiers.md)) |
| `` 集合[^键] `` | **过渡**:旧脚注取元(仍可用) |
+83
View File
@@ -0,0 +1,83 @@
# Ubuntu PPA packaging (Marqdo)
| | |
|---|---|
| Status | **Active** — `ppa:cflmy/marqdo`; noble builds need bundled Rust (Cargo.lock v4) |
| Maintainer | cflmy \<pingan@cflmy.cn\> |
| GPG | `505943294D04C803` (fingerprint `52A1…C803`) |
| PPA | `ppa:cflmy/marqdo` |
## Goal
Users install with:
```bash
sudo add-apt-repository ppa:cflmy/marqdo
sudo apt update
sudo apt install marqdo
```
CLI and extension packs stay independent: the `.deb` ships the **interpreter**; `marqdo ext add …` still pulls from **https://ext.marqdo.com** (then GitHub / proxy).
## Why bundled Rust?
Ubuntu **noble** ships cargo/rustc **1.75**, which cannot parse **Cargo.lock version 4** (`lock file version 4 requires -Znext-lockfile-bump`). Launchpad builders also have **no network**, so `ppa-build-source.sh` vendors crates **and** installs a modern toolchain into `third_party/rust` inside the `.orig.tar.xz`. `debian/rules` prefers that toolchain over distro cargo.
## One-time Launchpad setup
1. Create PPA: https://launchpad.net/~cflmy/+activate-ppa → name e.g. `marqdo`
2. OpenPGP key already on Launchpad (done)
3. Sign Ubuntu Code of Conduct if Launchpad asks
4. Enable the Ubuntu **series** you upload for (e.g. noble) under PPA → Change details
5. On the build machine:
```bash
sudo apt install build-essential debhelper devscripts dput lintian \
dpkg-dev quilt cargo rustc pkg-config curl xz-utils
```
## Package layout
| File | Role |
|------|------|
| `debian/control` | Metadata (amd64; no distro cargo BD) |
| `debian/changelog` | Upload revisions (`1ppaN`) |
| `debian/rules` | `dh` + bundled/system cargo build |
| `scripts/ppa-build-source.sh` | Vendor + bundle Rust + `debuild -S` |
| `scripts/ppa-ship.sh` | apt deps + build + `dput` |
## Versioning
- Upstream SemVer: `Cargo.toml` / git tag `vX.Y.Z`
- Debian revision: `X.Y.Z-1ppaN~SERIES` (SERIES = `noble`, …) — bump `1ppaN` on packaging-only reuploads
- **Ext pack** SemVer (`ext/VERSION`) is **not** the deb version
## One-shot (recommended)
```bash
cd ~/work/marqdo
./scripts/ppa-ship.sh noble # tools → debuild -S → dput
./scripts/ppa-ship.sh noble -n # build only
```
If automation cannot enter sudo/GPG, tell the user these commands (do not invent alternatives):
```bash
./scripts/ppa-build-source.sh noble
dput ppa:cflmy/marqdo ../build-area/marqdo_*~noble_source.changes
```
Watch: https://launchpad.net/~cflmy/+archive/ubuntu/marqdo/+builds
## Failure notes
| Symptom | Fix |
|---------|-----|
| `lock file version 4 requires -Znext-lockfile-bump` | Rebuild with current `ppa-build-source.sh` (bundles Rust); bump `1ppaN` |
| Same version rejected by Launchpad | Bump `debian/changelog` (`1ppa2`, …) |
| Wrong series | Enable series on PPA; rebuild with that series name |
## Out of scope (v1 deb)
- Shipping `ext/native/*.so` inside the deb (use CDN `ext add`)
- WASM / VSIX / non-amd64
+3 -4
View File
@@ -1,10 +1,9 @@
# examples/web-site-zh
中文作者面示例:只导入 `ext/web/网页.mq.md`(不用英文 `web.mq.md`)。
与 [`examples/web-site`](../web-site/) 对等(`ext/web/网页.mq.md`)。
```bash
cargo build -p marqdo_plugin_web
cargo run -- examples/web-site-zh/index.mq.md
marqdo run examples/web-site-zh/index.mq.md
```
打开 http://127.0.0.1:18082/ — `/about`、`/new`、`/admin`、`/static/site.css`。
http://127.0.0.1:18082/ — 演示脚本见英文样站 [DEMO.md](../web-site/DEMO.md)。
@@ -0,0 +1,29 @@
---
title: components/desk
description: 管理台壳 — 顶栏品牌为「后台」,无前台侧栏。
---
## nav
`nav` =
| 属性 | 值 | 样式 | 媒体 | 当 |
|------|-----|------|------|-----|
| 后台 | /admin | | | |
| 站点 | / | | | |
| 写文章 | /new | | | |
| 退出 | /admin/logout | | | auth |
*`nav`*
## foot
`foot` =
| 属性 | 值 | 样式 |
|------|-----|------|
| 站点 | / | |
| 后台 | /admin | |
| 退出 | /admin/logout | |
*`foot`*
+3 -1
View File
@@ -4,6 +4,8 @@
| 属性 | 值 | 样式 |
|------|-----|------|
| Marqdo | https://github.com | |
| Marqdo | https://www.marqdo.com/ | |
| Source | https://github.com/cflmy/marqdo | |
*`foot`*
+10 -6
View File
@@ -1,12 +1,16 @@
## nav
顶栏:**登录**(访客)/ **后台** + **退出**(已登录)。
`nav` =
| 属性 | 值 | 样式 |
|------|-----|------|
| 首页 | / | |
| 关于 | /about | |
| 写文章 | /new | |
| 后台 | /admin | |
| 属性 | 值 | 样式 | 媒体 | 当 |
|------|-----|------|------|-----|
| Marqdo | / | | | |
| 关于 | /about | | | |
| 写文章 | /new | | | |
| 登录 | /login | | | guest |
| 后台 | /admin | | | auth |
| 退出 | /admin/logout | | | auth |
*`nav`*
+7 -4
View File
@@ -2,9 +2,12 @@
`side` =
| 属性 | 值 | 样式 |
|------|-----|------|
| 笔记 | / | |
| 文档 | https://github.com | |
| 属性 | 值 | 样式 | 媒体 | 当 |
|------|-----|------|------|-----|
| 1. 首页 | / | | | |
| 2. 写文章 | /new | | | |
| 3. 登录 | /login | | | guest |
| 3. 后台 | /admin | | | auth |
| 关于 | /about | | | |
*`side`*
+14 -4
View File
@@ -6,17 +6,27 @@
|------|------|------|
| id | integer | false |
| title | text | false |
| slug | text | false |
| summary | text | true |
| body | text | true |
*`fields`*
## seed
卡片显示 summary;/post/{slug} 显示完整 body(Markdown)。
`rows` =
| id | title | body |
|----|-------|------|
| 1 | 你好 Marqdo | 第一篇来自 GFM 表格。 |
| 2 | 代码即文档 | 页面表就是程序。 |
| id | title | slug | summary | body |
|----|-------|------|---------|------|
| 1 | 你好 Marqdo | hello-marqdo | 一份可执行 Markdown 既是站点说明,也是上线制品——路由、表单与样式都用表声明。 | "Marqdo 把 .mq.md 当作可执行文档。编辑器里读到的叙述,就是服务器跑起来的同一份制品:GFM 表变成 schema、表单、导航与 CSS。本 Demo 走完这条契约——打开「写文章」、触发规则表校验,再发布一行,首页与后台同时出现,全程无需作者业务 JavaScript。" |
| 2 | 表即全栈 | tables-full-stack | Schema、表单、路由、后台与主题令牌共用一套表方言,而不是 JS/CSS 分家。 | "常见技术栈把关切拆进多种语言:数据用 SQL/ORM,输入用表单库,URL 用路由,外观用手写样式。Marqdo 把这些表面收成作者本来就会写的 GFM 表。字段表、规则表、绑定表、样式表不是比喻,而是运行时。结果是一份既能当散文扫读、又能当程序执行的站点。" |
| 3 | 零作者 JS 与 CSS | zero-author-js-css | 业务留在 Markdown;外观是样式表加宿主壳——无作者业务 JS、无作者 .css。 | "作者业务 JavaScript 从构造上为零:校验来自服务端规则表,列表/详情由绑定表交给宿主渲染。主题令牌写在属性/值表里,经样式装配变成 CSS,作者也不必维护 .css 文件。本 Demo 关闭壳样式,只让声明过的样式上色——方便会议观众当场核对主张。" |
| 4 | 一表打通卡片与详情 | card-to-detail | 列表把 href 绑到 slug;/post/{slug} 加详情=真即可打开全文。 | "点击首页任意卡片。列表绑定用 articles.slug 作为 href,链接前缀补上 /post/。详情页复用同一张表,查询条件 slug = {slug},再页面.详情,首行就渲染成完整文章(标题 + Markdown 正文),而不是卡片网格。这与求道量子等更大的 Marqdo 站同一套路。" |
| 5 | 样式表不是样式文件 | style-tables | 具名样式表(kicker、intro_title、card_title)通过绑定表第三列挂上。 | "引言、卡片与壳层都用属性/值/样式绑定。样式列指向 styles/shell.mq.md 里的具名属性表。引言装配或主体装配时,这些表变成页面上的 CSS 类。改 Demo 外观不必打开 .css——改可读的 Markdown 表,文案与样式仍挨在一起。" |
| 6 | 表单来自字段表与规则表 | forms-from-tables | 「写文章」空标题会因规则表失败;合法提交写入与后台共享的一行。 | "写文章与后台挂载同一表单对象:字段表声明标签与类型,规则表声明 required、max 与提示文案。空标题提交时错误来自服务端,不是客户端脚本。填好标题与 slug 再提交,卡片网格与后台列表都会出现——一张 schema、两个表面、零作者 JS。" |
| 7 | 种子数据就是文档 | seed-is-docs | 这些段落写在 GFM 种子表里——Demo 正文也是程序的一部分。 | "种子行与 schema 同在 db/articles.mq.md。首次启动若表为空,宿主会插入它们。于是 Demo 叙述与代码同版本:卡片用稍长摘要,详情用更长正文,slug 保证深链稳定。审稿人打开种子表,就能看到会场站点将展示的内容。" |
| 8 | 为什么要做这个 Demo | why-demo-matters | WWW Demo 需要审稿人几分钟内能跑、能点、能对照源码的制品。 | "Demo 轨道要的是可运行系统,不是只靠幻灯片。本样站刻意很小:一张 SQLite 表、几条路由、一套文学风壳层——却覆盖论文主张(表即全栈),并配三步操作脚本。克隆仓库,运行样站,点开卡片,弄坏一次表单,再把 index.mq.md 与浏览器对照。这个闭环就是投稿本身。" |
*`rows`*
+146 -8
View File
@@ -1,37 +1,113 @@
---
title: 中文站点示例
description: Home + /about + /new(表单嵌入)+ 后台;只用 ext/web/网页.mq.md。
description: >-
与 examples/web-site 对等的 WWW Demo 样站:表驱动全站;作者业务 JS=0;作者 .css=0。
导入 网页:ext/web/网页.mq.md
import shell:styles/shell.mq.md
import nav:components/nav.mq.md
import side:components/side.mq.md
import foot:components/foot.mq.md
import desk:components/desk.mq.md
import articles:db/articles.mq.md
import db:db/index.mq.md
---
# main
本文件既是站点说明,也是可运行应用。
`home` =
| 组件 | 样式 |
|------|------|
| nav.`nav` | shell.`topnav` |
| side.`side` | shell.`side_panel` |
| foot.`foot` | |
| foot.`foot` | shell.`footer` |
后台壳:去掉前台侧栏,顶栏品牌改为「后台」。
`desk_shell` =
| 组件 | 样式 |
|------|------|
| desk.`nav` | shell.`topnav` |
| desk.`foot` | shell.`footer` |
`index` =
| 属性 | 值 | 样式 |
|------|-----|------|
| title | articles.`articles`.title | shell.`card_title` |
| body | articles.`articles`.body | shell.`card_body` |
| body | articles.`articles`.summary | shell.`card_body` |
| href | articles.`articles`.slug | |
`detail` =
| 属性 | 值 | 样式 |
|------|-----|------|
| title | articles.`articles`.title | shell.`card_title` |
| body | articles.`articles`.body | |
`by_slug` =
| 字段 | 操作 | 值 |
|------|------|-----|
| slug | = | {slug} |
`首页引言` =
| 属性 | 值 | 样式 |
|------|-----|------|
| 眉题 | WWW Demo · 表即全栈 | shell.`kicker` |
| 标题 | Marqdo | shell.`intro_title` |
| 导语 | "一份可执行 Markdown 声明路由、表单、后台与样式——作者零业务 JavaScript、零手写 .css。点击卡片打开全文,再按下列三步动手试。" | shell.`lede` |
| 标签 | 0 作者 JS | shell.`claim` |
| 标签 | 0 作者 .css | shell.`claim` |
| 标签 | GFM 表 | shell.`claim` |
| 步骤 | "点击任意卡片 — /post/{slug} 用同一张 articles 表打开详情。" | shell.`step` |
| 步骤 | "打开 [写文章](/new),空标题提交(规则表校验)。" | shell.`step` |
| 步骤 | "点顶栏 **登录**(admin / demo),再进 **后台** — 门禁管理台:创建表单 + 列表。" | shell.`step` |
`关于引言` =
| 属性 | 值 | 样式 |
|------|-----|------|
| 眉题 | 关于 | shell.`kicker` |
| 标题 | 关于 | shell.`intro_title` |
| 导语 | "文档与站点同一 .mq.md 制品。版式与主题是 styles/shell.mq.md 里的 GFM 样式表——无需手写 CSS 或业务 JavaScript。" | shell.`lede` |
`写文章引言` =
| 属性 | 值 | 样式 |
|------|-----|------|
| 眉题 | 表单 · 试校验 | shell.`kicker` |
| 标题 | 写文章 | shell.`intro_title` |
| 导语 | 空标题提交应失败(规则表,非客户端 JS);填写标题、slug 与摘要后与后台、卡片网格共享一行。 | shell.`lede` |
`后台引言` =
| 属性 | 值 | 样式 |
|------|-----|------|
| 眉题 | 管理台 · 已进入后台 | shell.`kicker` |
| 标题 | 后台 | shell.`intro_title` |
| 导语 | "这就是管理台(需登录):与前台共用 articles schema,装配成列表 + 创建表单——不是另写一套 SPA。顶栏「站点」回前台,「退出」结束会话。" | shell.`lede` |
| 标签 | 登录门禁 | shell.`claim` |
| 标签 | 表声明 | shell.`claim` |
| 标签 | "创建 + 列表" | shell.`claim` |
`文章引言` =
| 属性 | 值 | 样式 |
|------|-----|------|
| 眉题 | 文章 · 表绑定详情 | shell.`kicker` |
`article_fields` =
| 字段 | 标签 | 类型 | 必填 | 默认 |
|------|------|------|------|------|
| title | 标题 | text | true | |
| slug | slug | text | true | |
| summary | 摘要 | textarea | false | |
| body | 正文 | textarea | false | |
`article_rules` =
@@ -40,26 +116,88 @@ import db:db/index.mq.md
|------|------|------|
| title | required | 标题不能为空 |
| title | max:120 | 标题太长 |
| slug | required | slug 不能为空 |
| slug | max:80 | slug 太长 |
| summary | max:500 | 摘要太长 |
| body | max:8000 | 正文太长 |
`home_meta` =
| key | value |
|-----|-------|
| description | 表即全栈 — Marqdo 网页示例;作者零业务 JavaScript。 |
| og:type | website |
| og:title | Marqdo 中文站 |
`fonts` =
| 关系 | 地址 | 跨域 |
|------|------|------|
| preconnect | https://fonts.googleapis.com | |
| preconnect | https://fonts.gstatic.com | anonymous |
| stylesheet | https://fonts.googleapis.com/css2?family=Great+Vibes&family=Noto+Sans+SC:wght@300;400;500;700&family=Noto+Serif+SC:wght@400;600&display=swap | |
**store = > db.open**
**page = > 网页.页面 标题="Marqdo 中文站" 引言="<h1>中文站</h1><p>表格 + 类方法。</p>"**
**site_css = > shell.css**
**page = > 网页.页面 标题="Marqdo 中文站" 壳样式="off"**
**page = > page.引言装配 引言=`首页引言`**
**page = > page.元数据 元数据=home_meta**
**page = > page.头装配 表=fonts**
**page = > page.样式 样式=site_css**
**page = > page.组件装配 组件=home**
**page = > page.主体装配 主体=index**
**page = > page.链接前缀 前缀="/post/"**
**about = > 网页.页面 标题="关于" 引言="<h1>关于</h1><p>导入网页.mq.md 即用中文 API。</p>"**
**about = > 网页.页面 标题="关于 · Marqdo 中文站" 壳样式="off"**
**about = > about.引言装配 引言=`关于引言`**
**about = > about.头装配 表=fonts**
**about = > about.样式 样式=site_css**
**about = > about.组件装配 组件=home**
**article_form = > 网页.表单 表="articles" 动作="插入"**
**article_form = > article_form.字段 字段=article_fields**
**article_form = > article_form.规则 规则=article_rules**
**new = > 网页.页面 标题="写文章" 引言="<h1>写文章</h1><p>表单嵌在主区。</p>"**
**new = > 网页.页面 标题="写文章 · Marqdo 中文站" 壳样式="off"**
**new = > new.引言装配 引言=`写文章引言`**
**new = > new.头装配 表=fonts**
**new = > new.样式 样式=site_css**
**new = > new.组件装配 组件=home**
**new = > new.表单装配 id="article" 表单=article_form**
**app = > 网页.应用 页面=page 数据库=store 后台=True 主机="127.0.0.1" 端口=18082**
**desk = > 网页.页面 标题="后台 · Marqdo 中文站" 壳样式="off"**
**desk = > desk.壳HTML 体类="is-desk"**
**desk = > desk.引言装配 引言=`后台引言`**
**desk = > desk.头装配 表=fonts**
**desk = > desk.样式 样式=site_css**
**desk = > desk.组件装配 组件=desk_shell**
**desk = > desk.表单装配 id="article" 表单=article_form**
**desk = > desk.主体装配 主体=index**
**desk = > desk.链接前缀 前缀="/post/"**
**post = > 网页.页面 标题="文章 · Marqdo 中文站" 壳样式="off"**
**post = > post.引言装配 引言=`文章引言`**
**post = > post.头装配 表=fonts**
**post = > post.样式 样式=site_css**
**post = > post.组件装配 组件=home**
**post = > post.主体装配 主体=detail**
**post = > post.查询条件 条件=by_slug**
**post = > post.详情 详情=True**
演示账号(用户表声明;宿主会话鉴权,无作者 JS)。
`管理员` =
| 用户名 | 密码 | 角色 |
|--------|------|------|
| admin | demo | admin |
**app = > 网页.应用 页面=page 数据库=store 后台=False 主机="127.0.0.1" 端口=18082 壳样式="off" 登录回跳="/admin" 登出回跳="/"**
**app = > app.路由 路径="/about" 页面=about**
**app = > app.路由 路径="/new" 页面=new**
**app = > app.静态 目录="public" 挂载="/static"**
**app = > app.路由 路径="/admin" 页面=desk**
**app = > app.路由 路径="/post/{slug}" 页面=post**
**app = > app.鉴权 用户表=`管理员` 会话时长=3600 登录路径="/login" 登录回跳="/admin" 登出回跳="/"**
**app = > app.门禁 路径="/admin" 角色="admin" 匹配="prefix" 拒绝="redirect" 排除="/login"**
> `app`.监听
-5
View File
@@ -1,5 +0,0 @@
/* 可选站点样式 — /static/site.css */
body.site-hint::before {
content: "static ok";
display: none;
}
+640 -7
View File
@@ -1,11 +1,233 @@
---
title: styles/shell
description: >-
Literary dark theme for examples/web-site — ink / wine / gold after the
anlian.cyou Zhang Ailing topic. GFM tables only; no author .css.
import web:ext/web/web.mq.md
import text:lib/text.mq.md
---
Authors style the site with **GFM tables** only. App pages use `shell_css=off`
so host defaults do not fight this theme. Palette mirrors
[海上花开](https://www.anlian.cyou/topics/author-zhangailing/): night ink,
wine, cold gold, serif display.
## vars
`vars` =
| 选择器 | 属性 | 值 |
|--------|------|-----|
| :root | --ink | #0a0809 |
| :root | --ink-lift | #141012 |
| :root | --wine | #6b1e3a |
| :root | --wine-soft | rgba(107,30,58,0.35) |
| :root | --gold | #d4af37 |
| :root | --gold-dim | rgba(212,175,55,0.45) |
| :root | --gold-soft | rgba(212,175,55,0.12) |
| :root | --paper | rgba(255,248,240,0.92) |
| :root | --paper-dim | rgba(255,248,240,0.72) |
| :root | --paper-faint | rgba(255,248,240,0.48) |
| :root | --glass | rgba(20,12,18,0.72) |
| :root | --glass-strong | rgba(20,12,18,0.88) |
| :root | --border | rgba(212,175,55,0.22) |
| :root | --border-soft | rgba(212,175,55,0.12) |
| :root | --danger | #e8a0a8 |
| :root | --radius | 4px |
| :root | --radius-sm | 2px |
| :root | --space-2 | 8px |
| :root | --space-3 | 12px |
| :root | --space-4 | 16px |
| :root | --space-5 | 20px |
| :root | --space-6 | 24px |
| :root | --space-8 | 32px |
| :root | --text | 16px |
| :root | --leading | "1.75" |
| :root | --shadow | "0 24px 80px rgba(0,0,0,.55), inset 0 1px 0 rgba(255,255,255,.06)" |
| :root | --shadow-card | "0 12px 40px rgba(107,30,58,.35)" |
| :root | --ring | "0 0 0 2px rgba(212,175,55,.35)" |
| :root | --serif | "'Noto Serif SC', 'Source Serif 4', Georgia, serif" |
| :root | --sans | "'Noto Sans SC', 'IBM Plex Sans', system-ui, sans-serif" |
| :root | --display | "'Great Vibes', 'Allura', cursive" |
| :root | --mono | "ui-monospace, SFMono-Regular, Menlo, Consolas, monospace" |
| ::selection | background | rgba(212,175,55,0.35) |
| ::selection | color | var(--paper) |
*`vars`*
## motion
`motion` =
| 选择器 | 属性 | 值 |
|--------|------|-----|
| @keyframes rise 0% | opacity | "0" |
| @keyframes rise 0% | transform | translateY(14px) |
| @keyframes rise 100% | opacity | "1" |
| @keyframes rise 100% | transform | translateY(0) |
| @keyframes float 0% | transform | translateY(0) |
| @keyframes float 0% | opacity | "0.7" |
| @keyframes float 50% | transform | translateY(6px) |
| @keyframes float 50% | opacity | "1" |
| @keyframes float 100% | transform | translateY(0) |
| @keyframes float 100% | opacity | "0.7" |
| @keyframes goldPulse 0% | text-shadow | "0 0 24px rgba(212,175,55,.2)" |
| @keyframes goldPulse 50% | text-shadow | "0 0 48px rgba(212,175,55,.45)" |
| @keyframes goldPulse 100% | text-shadow | "0 0 24px rgba(212,175,55,.2)" |
| @keyframes particleDrift 0% | transform | translate3d(0,0,0) |
| @keyframes particleDrift 50% | transform | translate3d(-2.5vw, 1.5vh, 0) |
| @keyframes particleDrift 100% | transform | translate3d(0,0,0) |
| @keyframes particleDrift2 0% | transform | translate3d(0,0,0) |
| @keyframes particleDrift2 50% | transform | translate3d(2vw, -2vh, 0) |
| @keyframes particleDrift2 100% | transform | translate3d(0,0,0) |
| @keyframes nebulaPulse 0% | opacity | "0.55" |
| @keyframes nebulaPulse 50% | opacity | "0.9" |
| @keyframes nebulaPulse 100% | opacity | "0.55" |
*`motion`*
## layout
`layout` =
| 选择器 | 属性 | 值 |
|--------|------|-----|
| * | box-sizing | border-box |
| html | scroll-behavior | smooth |
| html | -webkit-text-size-adjust | 100% |
| body | margin | "0" |
| body | min-height | 100vh |
| body | font-family | var(--sans) |
| body | font-weight | "400" |
| body | font-size | var(--text) |
| body | line-height | var(--leading) |
| body | color | var(--paper) |
| body | background | var(--ink) |
| body | background-image | "radial-gradient(ellipse 90% 55% at 50% -15%, rgba(107,30,58,.5), transparent 58%), radial-gradient(ellipse 55% 45% at 92% 75%, rgba(212,175,55,.14), transparent 55%), radial-gradient(ellipse 40% 35% at 8% 70%, rgba(107,30,58,.22), transparent 60%), linear-gradient(180deg, #0a0809 0%, #120c10 45%, #0a0809 100%)" |
| body | background-attachment | fixed |
| body | display | grid |
| body | grid-template-rows | "auto 1fr auto" |
| body | -webkit-font-smoothing | antialiased |
| body | position | relative |
| body | overflow-x | hidden |
| body::before | content | '""' |
| body::before | position | fixed |
| body::before | inset | "0" |
| body::before | z-index | "1" |
| body::before | pointer-events | none |
| body::before | opacity | "0.1" |
| body::before | background-image | "url(\"data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E\")" |
| html::before | content | '""' |
| html::before | position | fixed |
| html::before | inset | "0" |
| html::before | z-index | "0" |
| html::before | pointer-events | none |
| html::before | background-image | "radial-gradient(ellipse 50% 40% at 15% 30%, rgba(107,30,58,.35), transparent 70%), radial-gradient(ellipse 45% 35% at 85% 60%, rgba(212,175,55,.12), transparent 65%), radial-gradient(ellipse 40% 30% at 50% 90%, rgba(107,30,58,.25), transparent 70%)" |
| html::before | animation | "nebulaPulse 12s ease-in-out infinite" |
| body::after | content | '""' |
| body::after | position | fixed |
| body::after | top | "0" |
| body::after | left | "0" |
| body::after | width | "2px" |
| body::after | height | "2px" |
| body::after | z-index | "2" |
| body::after | pointer-events | none |
| body::after | border-radius | 50% |
| body::after | background | transparent |
| body::after | box-shadow | "82vw 15vh 0px 0px rgba(212,175,55,0.55),29vw 18vh 0px 1px rgba(212,175,55,0.25),95vw 70vh 1px 0px rgba(212,175,55,0.55),4vw 12vh 0px 1px rgba(212,175,55,0.35),78vw 4vh 0px 1px rgba(245,230,200,0.5),84vw 90vh 1px 0px rgba(245,230,200,0.5),58vw 76vh 0px 0px rgba(255,248,240,0.4),90vw 55vh 0px 0px rgba(255,248,240,0.4),28vw 98vh 0px 0px rgba(255,248,240,0.4),49vw 13vh 0px 1px rgba(255,248,240,0.4),34vw 6vh 1px 1px rgba(212,175,55,0.25),16vw 49vh 0px 1px rgba(212,175,55,0.55),80vw 47vh 0px 1px rgba(245,230,200,0.5),9vw 6vh 0px 0px rgba(212,175,55,0.25),11vw 30vh 1px 0px rgba(212,175,55,0.55),59vw 82vh 0px 0px rgba(255,248,240,0.4),46vw 27vh 0px 1px rgba(212,175,55,0.25),88vw 83vh 0px 1px rgba(212,175,55,0.55),94vw 32vh 1px 0px rgba(212,175,55,0.35),35vw 82vh 0px 1px rgba(212,175,55,0.25),42vw 99vh 0px 0px rgba(212,175,55,0.55),41vw 52vh 0px 0px rgba(255,248,240,0.4),73vw 92vh 0px 1px rgba(255,248,240,0.4),64vw 51vh 1px 0px rgba(212,175,55,0.25),34vw 18vh 0px 1px rgba(212,175,55,0.35),75vw 55vh 1px 0px rgba(245,230,200,0.5),29vw 18vh 1px 0px rgba(245,230,200,0.5),97vw 7vh 0px 1px rgba(212,175,55,0.55),21vw 88vh 0px 0px rgba(107,30,58,0.45),49vw 77vh 0px 1px rgba(107,30,58,0.45),2vw 88vh 0px 1px rgba(212,175,55,0.25),69vw 97vh 0px 0px rgba(255,248,240,0.4),38vw 56vh 1px 0px rgba(212,175,55,0.35),93vw 93vh 0px 1px rgba(255,248,240,0.4),14vw 81vh 0px 0px rgba(255,248,240,0.4),48vw 98vh 0px 1px rgba(212,175,55,0.35),42vw 63vh 0px 0px rgba(212,175,55,0.55),40vw 31vh 0px 1px rgba(212,175,55,0.55),11vw 11vh 1px 0px rgba(212,175,55,0.25),98vw 69vh 0px 1px rgba(212,175,55,0.35),61vw 71vh 0px 1px rgba(212,175,55,0.35),78vw 55vh 0px 1px rgba(212,175,55,0.35),40vw 52vh 0px 0px rgba(212,175,55,0.25),67vw 58vh 0px 0px rgba(212,175,55,0.55),9vw 44vh 0px 1px rgba(212,175,55,0.55),29vw 1vh 0px 0px rgba(212,175,55,0.55),9vw 5vh 0px 1px rgba(255,248,240,0.4),31vw 36vh 1px 0px rgba(212,175,55,0.25),70vw 17vh 1px 0px rgba(212,175,55,0.25),61vw 53vh 0px 0px rgba(212,175,55,0.35),85vw 56vh 1px 0px rgba(255,248,240,0.4),60vw 94vh 0px 0px rgba(212,175,55,0.55),52vw 94vh 0px 0px rgba(255,248,240,0.4),25vw 25vh 1px 0px rgba(245,230,200,0.5),55vw 24vh 1px 0px rgba(255,248,240,0.4),10vw 57vh 0px 0px rgba(245,230,200,0.5),84vw 70vh 0px 0px rgba(212,175,55,0.55),22vw 53vh 1px 0px rgba(107,30,58,0.45),52vw 8vh 1px 0px rgba(212,175,55,0.35),50vw 34vh 0px 0px rgba(107,30,58,0.45),90vw 94vh 1px 0px rgba(245,230,200,0.5),25vw 38vh 0px 1px rgba(212,175,55,0.35),95vw 70vh 0px 0px rgba(212,175,55,0.55),7vw 75vh 0px 0px rgba(107,30,58,0.45),66vw 11vh 0px 1px rgba(212,175,55,0.35),9vw 87vh 1px 0px rgba(212,175,55,0.35),73vw 32vh 0px 1px rgba(245,230,200,0.5),11vw 54vh 0px 0px rgba(212,175,55,0.25),27vw 86vh 0px 0px rgba(212,175,55,0.25),34vw 51vh 0px 0px rgba(212,175,55,0.35),41vw 97vh 0px 0px rgba(212,175,55,0.55),80vw 73vh 0px 1px rgba(212,175,55,0.55)" |
| body::after | animation | "particleDrift 48s ease-in-out infinite" |
| html::after | content | '""' |
| html::after | position | fixed |
| html::after | top | "0" |
| html::after | left | "0" |
| html::after | width | "1px" |
| html::after | height | "1px" |
| html::after | z-index | "2" |
| html::after | pointer-events | none |
| html::after | border-radius | 50% |
| html::after | background | transparent |
| html::after | box-shadow | "28vw 65vh 0 0 rgba(255,248,240,0.25),17vw 45vh 0 0 rgba(212,175,55,0.3),32vw 48vh 0 0 rgba(255,248,240,0.25),21vw 57vh 0 0 rgba(107,30,58,0.3),91vw 39vh 0 0 rgba(107,30,58,0.3),84vw 68vh 0 0 rgba(212,175,55,0.3),86vw 71vh 0 0 rgba(255,248,240,0.25),85vw 14vh 0 0 rgba(212,175,55,0.3),34vw 15vh 0 0 rgba(212,175,55,0.3),96vw 71vh 0 0 rgba(212,175,55,0.3),35vw 37vh 0 0 rgba(107,30,58,0.3),27vw 92vh 0 0 rgba(255,248,240,0.25),27vw 88vh 0 0 rgba(107,30,58,0.3),34vw 65vh 0 0 rgba(255,248,240,0.25),33vw 7vh 0 0 rgba(212,175,55,0.3),82vw 55vh 0 0 rgba(255,248,240,0.25),6vw 1vh 0 0 rgba(255,248,240,0.25),99vw 17vh 0 0 rgba(107,30,58,0.3),34vw 21vh 0 0 rgba(107,30,58,0.3),57vw 71vh 0 0 rgba(107,30,58,0.3),55vw 72vh 0 0 rgba(212,175,55,0.3),15vw 10vh 0 0 rgba(107,30,58,0.3),20vw 70vh 0 0 rgba(212,175,55,0.3),48vw 75vh 0 0 rgba(107,30,58,0.3),19vw 56vh 0 0 rgba(212,175,55,0.3),6vw 40vh 0 0 rgba(255,248,240,0.25),6vw 46vh 0 0 rgba(212,175,55,0.3),88vw 32vh 0 0 rgba(107,30,58,0.3),14vw 46vh 0 0 rgba(107,30,58,0.3),53vw 80vh 0 0 rgba(107,30,58,0.3),20vw 31vh 0 0 rgba(212,175,55,0.3),23vw 53vh 0 0 rgba(212,175,55,0.3),23vw 95vh 0 0 rgba(255,248,240,0.25),53vw 86vh 0 0 rgba(107,30,58,0.3),32vw 35vh 0 0 rgba(212,175,55,0.3),90vw 14vh 0 0 rgba(255,248,240,0.25),5vw 61vh 0 0 rgba(212,175,55,0.3),26vw 59vh 0 0 rgba(255,248,240,0.25),40vw 30vh 0 0 rgba(212,175,55,0.3),4vw 85vh 0 0 rgba(212,175,55,0.3),52vw 43vh 0 0 rgba(255,248,240,0.25),9vw 99vh 0 0 rgba(255,248,240,0.25),45vw 83vh 0 0 rgba(107,30,58,0.3),52vw 87vh 0 0 rgba(107,30,58,0.3),43vw 4vh 0 0 rgba(212,175,55,0.3),34vw 23vh 0 0 rgba(107,30,58,0.3),34vw 5vh 0 0 rgba(212,175,55,0.3),77vw 56vh 0 0 rgba(255,248,240,0.25)" |
| html::after | animation | "particleDrift2 64s ease-in-out infinite" |
| body.has-sidebar | grid-template-columns | "14rem minmax(0, 1fr)" |
| body.has-sidebar | grid-template-areas | '"top top" "side main" "foot foot"' |
| body.no-sidebar | grid-template-areas | '"top" "main" "foot"' |
| body.layout-stacked | grid-template-areas | '"top" "main" "foot"' |
| body.is-desk | grid-template-areas | '"top" "main" "foot"' |
| header.topnav | grid-area | top |
| aside.side | grid-area | side |
| main.main | grid-area | main |
| footer.foot | grid-area | foot |
| header.topnav | position | relative |
| header.topnav | z-index | "20" |
| aside.side | position | relative |
| aside.side | z-index | "10" |
| main.main | position | relative |
| main.main | z-index | "10" |
| footer.foot | position | relative |
| footer.foot | z-index | "10" |
| main.main | width | "100%" |
| main.main | max-width | "min(78rem, 100%)" |
| main.main | padding | "var(--space-8) var(--space-6) 4rem" |
| main.main | animation | "rise .8s cubic-bezier(.22,1,.36,1) both" |
| a | color | var(--gold) |
| a | text-decoration | none |
| a | transition | color 0.25s ease |
| a:hover | color | #f5e6c8 |
| code | font-family | var(--mono) |
| code | font-size | "0.82em" |
| code | font-weight | "400" |
| code | background | rgba(0,0,0,0.35) |
| code | border | 1px solid var(--border-soft) |
| code | padding | "0.12em 0.45em" |
| code | border-radius | var(--radius-sm) |
| code | color | var(--gold) |
*`layout`*
## responsive
`responsive` =
| 媒体 | 选择器 | 属性 | 值 |
|------|--------|------|-----|
| (max-width: 860px) | body.has-sidebar | grid-template-columns | 1fr |
| (max-width: 860px) | body.has-sidebar | grid-template-areas | '"top" "main" "side" "foot"' |
| (max-width: 860px) | aside.side | border-right | "0" |
| (max-width: 860px) | aside.side | border-top | 1px solid var(--border-soft) |
| (max-width: 860px) | main.main | padding | "var(--space-6) var(--space-4) var(--space-8)" |
| (max-width: 860px) | .content.cards | grid-template-columns | 1fr |
| (max-width: 860px) | .site-form form | grid-template-columns | 1fr |
| (max-width: 860px) | .site-form label:nth-child(1) | grid-column | "1 / -1" |
| (max-width: 860px) | .site-form label:nth-child(2) | grid-column | "1 / -1" |
| (max-width: 860px) | header.topnav | padding | "0.85rem var(--space-4)" |
| (max-width: 860px) | .intro_title | font-size | "2.4rem" |
| (prefers-reduced-motion: reduce) | main.main | animation | none |
| (prefers-reduced-motion: reduce) | .kicker | animation | none |
| (prefers-reduced-motion: reduce) | article.card | transition | none |
| (prefers-reduced-motion: reduce) | body::after | animation | none |
| (prefers-reduced-motion: reduce) | html::after | animation | none |
| (prefers-reduced-motion: reduce) | html::before | animation | none |
*`responsive`*
## topnav
`topnav` =
| 属性 | 值 |
|------|-----|
| background | #ffffff |
| border-bottom | 1px solid #e7e5e4 |
| position | sticky |
| top | "0" |
| z-index | "40" |
| display | flex |
| align-items | center |
| justify-content | flex-start |
| gap | var(--space-4) |
| padding | "1rem var(--space-6)" |
| background | "linear-gradient(180deg, rgba(10,8,9,.92) 0%, rgba(10,8,9,.55) 70%, transparent 100%)" |
| backdrop-filter | blur(10px) |
| -webkit-backdrop-filter | blur(10px) |
| border-bottom | 1px solid var(--border-soft) |
*`topnav`*
@@ -15,18 +237,40 @@
| 属性 | 值 |
|------|-----|
| background | #f5f5f4 |
| background | "rgba(10,8,9,.55)" |
| padding | "var(--space-6) var(--space-4)" |
| border-right | 1px solid var(--border-soft) |
*`side_panel`*
## footer
`footer` =
| 属性 | 值 |
|------|-----|
| color | var(--paper-faint) |
| font-size | "0.8rem" |
| letter-spacing | "0.08em" |
| padding | "var(--space-5) var(--space-6)" |
| border-top | 1px solid var(--border-soft) |
| background | "rgba(10,8,9,.75)" |
*`footer`*
## card_title
`card_title` =
| 属性 | 值 |
|------|-----|
| font-size | 1.15rem |
| margin | 0 0 0.35rem |
| font-family | var(--serif) |
| font-size | "1.15rem" |
| font-weight | "600" |
| margin | "0 0 var(--space-2)" |
| color | var(--gold) |
| letter-spacing | "0.02em" |
| line-height | "1.35" |
*`card_title`*
@@ -36,7 +280,396 @@
| 属性 | 值 |
|------|-----|
| color | #57534e |
| margin | 0 |
| color | var(--paper-dim) |
| margin | "0" |
| line-height | "1.65" |
| font-size | "0.9rem" |
| font-weight | "400" |
| display | "-webkit-box" |
| -webkit-box-orient | vertical |
| -webkit-line-clamp | "3" |
| overflow | hidden |
*`card_body`*
## chrome
Panel + claim/steps group layout (field look comes from named bind styles).
`chrome` =
| 选择器 | 属性 | 值 |
|--------|------|-----|
| .main-intro | background | var(--glass) |
| .main-intro | border | 1px solid var(--border) |
| .main-intro | border-radius | var(--radius) |
| .main-intro | padding | "2.25rem 1.75rem 1.85rem" |
| .main-intro | box-shadow | var(--shadow) |
| .main-intro | backdrop-filter | blur(16px) |
| .main-intro | -webkit-backdrop-filter | blur(16px) |
| .main-intro | margin-bottom | var(--space-8) |
| .main-intro > .claim | display | flex |
| .main-intro > .claim | flex-wrap | wrap |
| .main-intro > .claim | gap | var(--space-2) |
| .main-intro > .claim | margin | "0 0 var(--space-6)" |
| .main-intro > .steps | margin | "0" |
| .main-intro > .steps | padding | "var(--space-5) var(--space-5) var(--space-5) 1.5rem" |
| .main-intro > .steps | color | var(--paper-dim) |
| .main-intro > .steps | background | "rgba(0,0,0,.35)" |
| .main-intro > .steps | border | 1px solid var(--border-soft) |
| .main-intro > .steps | border-left | 2px solid var(--gold-dim) |
| .main-intro > .steps | border-radius | var(--radius) |
| .main-intro > .steps | font-size | "0.95rem" |
| .main-intro > .steps | letter-spacing | "0.02em" |
| .main-intro > .steps a | color | var(--gold) |
| .main-intro > .steps a | font-weight | "500" |
| .main-intro > .steps a:hover | color | #f5e6c8 |
| .article | background | var(--glass) |
| .article | border | 1px solid var(--border) |
| .article | border-radius | var(--radius) |
| .article | padding | "2rem 1.75rem" |
| .article | box-shadow | var(--shadow) |
| .article | backdrop-filter | blur(16px) |
| .article | -webkit-backdrop-filter | blur(16px) |
| .article-title | font-family | var(--serif) |
| .article-title | font-size | "clamp(1.75rem, 4vw, 2.35rem)" |
| .article-title | font-weight | "600" |
| .article-title | color | var(--gold) |
| .article-title | letter-spacing | "0.04em" |
| .article-title | margin | "0 0 var(--space-5)" |
| .article-title | line-height | "1.25" |
| .article-body | color | var(--paper-dim) |
| .article-body | font-family | var(--sans) |
| .article-body | font-size | "1.02rem" |
| .article-body | line-height | "1.85" |
| .article-body.md p | margin | "0 0 1.1rem" |
| .article-body.md a | color | var(--gold) |
| article.card | cursor | pointer |
| a.card-link | color | inherit |
| a.card-link | text-decoration | none |
| a.card-link:hover | color | inherit |
*`chrome`*
## kicker
`kicker` =
| 属性 | 值 |
|------|-----|
| letter-spacing | "0.32em" |
| text-transform | uppercase |
| font-size | "0.72rem" |
| color | var(--gold-dim) |
| margin | "0 0 var(--space-4)" |
| font-weight | "400" |
| font-family | var(--sans) |
| animation | "float 2.8s ease-in-out infinite" |
*`kicker`*
## intro_title
`intro_title` =
| 属性 | 值 |
|------|-----|
| font-family | var(--display) |
| font-size | "clamp(3rem, 10vw, 4.8rem)" |
| font-weight | "400" |
| line-height | "1.15" |
| letter-spacing | "0.04em" |
| margin | "0 0 var(--space-4)" |
| color | transparent |
| background | "linear-gradient(135deg, #f5e6c8 0%, var(--gold) 42%, var(--wine) 100%)" |
| -webkit-background-clip | text |
| background-clip | text |
| animation | "goldPulse 4.5s ease-in-out infinite" |
*`intro_title`*
## lede
`lede` =
| 属性 | 值 |
|------|-----|
| color | var(--paper-dim) |
| max-width | "34rem" |
| line-height | "1.85" |
| margin | "0 0 var(--space-5)" |
| font-size | "1.05rem" |
| letter-spacing | "0.02em" |
| font-weight | "400" |
| font-family | var(--sans) |
*`lede`*
## claim
`claim` =
| 属性 | 值 |
|------|-----|
| display | inline-flex |
| align-items | center |
| padding | "0.2rem 0.65rem" |
| border-radius | var(--radius-sm) |
| background | var(--wine-soft) |
| color | #f0c9d4 |
| font-size | "0.68rem" |
| font-weight | "500" |
| letter-spacing | "0.14em" |
| border | 1px solid rgba(107,30,58,0.5) |
*`claim`*
## step
`step` =
| 属性 | 值 |
|------|-----|
| margin | "0.55rem 0" |
*`step`*
## widgets
`widgets` =
| 选择器 | 属性 | 值 |
|--------|------|-----|
| ul.nav | display | flex |
| ul.nav | flex-wrap | wrap |
| ul.nav | align-items | center |
| ul.nav | gap | "0.35rem 1rem" |
| ul.nav | list-style | none |
| ul.nav | margin | "0" |
| ul.nav | padding | "0" |
| ul.nav a | display | inline-flex |
| ul.nav a | align-items | center |
| ul.nav a | text-decoration | none |
| ul.nav a | color | var(--paper-dim) |
| ul.nav a | padding | "0.35rem 0" |
| ul.nav a | border-radius | "0" |
| ul.nav a | font-weight | "400" |
| ul.nav a | font-size | "0.8rem" |
| ul.nav a | letter-spacing | "0.14em" |
| ul.nav a | transition | color 0.25s ease |
| ul.nav a:hover | background | transparent |
| ul.nav a:hover | color | var(--gold) |
| ul.nav a:hover | text-decoration | none |
| ul.nav a[href="/admin"] | color | var(--gold) |
| ul.nav a[href="/admin"] | letter-spacing | "0.18em" |
| ul.nav a[href="/admin"] | border-bottom | 1px solid var(--gold-dim) |
| ul.side-nav a[href="/admin"] | color | var(--gold) |
| body.is-desk header.topnav | border-bottom | 1px solid rgba(107,30,58,0.55) |
| body.is-desk header.topnav | box-shadow | "0 12px 40px rgba(107,30,58,.18)" |
| body.is-desk .main-intro | border-left | 3px solid var(--wine) |
| body.is-desk .site-form | border-color | rgba(107,30,58,0.45) |
| body.is-desk .site-form | box-shadow | "0 0 0 1px rgba(212,175,55,.12), 0 18px 48px rgba(0,0,0,.35)" |
| body.is-desk .content.cards | margin-top | var(--space-6) |
| ul.nav li:first-child a | font-family | var(--display) |
| ul.nav li:first-child a | font-weight | "400" |
| ul.nav li:first-child a | color | var(--gold) |
| ul.nav li:first-child a | font-size | "1.85rem" |
| ul.nav li:first-child a | letter-spacing | "0.06em" |
| ul.nav li:first-child a | padding | "0.1rem 0.2rem 0.1rem 0" |
| ul.nav li:first-child a:hover | background | transparent |
| ul.nav li:first-child a:hover | color | #f5e6c8 |
| .side-label | display | block |
| .side-label | font-size | "0" |
| .side-label | margin | "0 0 var(--space-4)" |
| .side-label::before | content | '"Path"' |
| .side-label::before | display | block |
| .side-label::before | font-size | "0.68rem" |
| .side-label::before | letter-spacing | "0.28em" |
| .side-label::before | text-transform | uppercase |
| .side-label::before | color | var(--gold-dim) |
| .side-label::before | font-weight | "400" |
| ul.side-nav | list-style | none |
| ul.side-nav | margin | "0" |
| ul.side-nav | padding | "0" |
| ul.side-nav | display | grid |
| ul.side-nav | gap | "2px" |
| ul.side-nav | border-left | 1px solid var(--border) |
| ul.side-nav | padding-left | "0.85rem" |
| ul.side-nav | margin-left | "0.25rem" |
| ul.side-nav a | display | block |
| ul.side-nav a | text-decoration | none |
| ul.side-nav a | color | var(--paper-dim) |
| ul.side-nav a | padding | "0.45rem 0.35rem" |
| ul.side-nav a | border-radius | "0" |
| ul.side-nav a | font-weight | "400" |
| ul.side-nav a | font-size | "0.88rem" |
| ul.side-nav a | letter-spacing | "0.06em" |
| ul.side-nav a | border | "0" |
| ul.side-nav a | position | relative |
| ul.side-nav a:hover | background | transparent |
| ul.side-nav a:hover | border-color | transparent |
| ul.side-nav a:hover | color | var(--gold) |
| ul.side-nav a:hover | text-decoration | none |
| ul.side-nav a:hover | box-shadow | none |
| ul.foot-nav | display | flex |
| ul.foot-nav | gap | var(--space-4) |
| ul.foot-nav | list-style | none |
| ul.foot-nav | margin | "0" |
| ul.foot-nav | padding | "0" |
| ul.foot-nav a | color | var(--paper-faint) |
| ul.foot-nav a | font-weight | "400" |
| ul.foot-nav a | letter-spacing | "0.1em" |
| ul.foot-nav a | font-size | "0.78rem" |
| ul.foot-nav a:hover | color | var(--gold) |
| .content.cards | display | grid |
| .content.cards | gap | var(--space-4) |
| .content.cards | margin-top | "0" |
| .content.cards | grid-template-columns | "repeat(auto-fill, minmax(16rem, 1fr))" |
| article.card | background | "rgba(0,0,0,.35)" |
| article.card | border | 1px solid var(--border-soft) |
| article.card | border-radius | var(--radius-sm) |
| article.card | padding | "1.35rem 1.15rem" |
| article.card | box-shadow | none |
| article.card | transition | "border-color .35s ease, box-shadow .35s ease, transform .35s ease" |
| article.card:hover | transform | "translateY(-3px)" |
| article.card:hover | box-shadow | var(--shadow-card) |
| article.card:hover | border-color | var(--gold-dim) |
| .site-form | background | var(--glass) |
| .site-form | border | 1px solid var(--border) |
| .site-form | border-radius | var(--radius) |
| .site-form | padding | "var(--space-6) var(--space-6) var(--space-7, 1.75rem)" |
| .site-form | margin | "0 0 var(--space-6)" |
| .site-form | max-width | "100%" |
| .site-form | width | "100%" |
| .site-form | box-shadow | var(--shadow) |
| .site-form | backdrop-filter | blur(16px) |
| .site-form | -webkit-backdrop-filter | blur(16px) |
| .site-form .meta | display | none |
| .site-form form | display | grid |
| .site-form form | grid-template-columns | "minmax(0, 1fr) minmax(0, 1fr)" |
| .site-form form | column-gap | var(--space-5) |
| .site-form form | row-gap | var(--space-5) |
| .site-form form | gap | var(--space-5) |
| .site-form form | margin | "0" |
| .site-form form | width | "100%" |
| .site-form form | max-width | "100%" |
| .site-form label | display | grid |
| .site-form label | gap | var(--space-2) |
| .site-form label | margin | "0" |
| .site-form label | min-width | "0" |
| .site-form label | font-weight | "400" |
| .site-form label | color | var(--gold) |
| .site-form label | font-size | "0.78rem" |
| .site-form label | letter-spacing | "0.16em" |
| .site-form label | text-transform | uppercase |
| .site-form label:nth-child(1) | grid-column | "1" |
| .site-form label:nth-child(2) | grid-column | "2" |
| .site-form label:nth-child(n+3) | grid-column | "1 / -1" |
| .site-form .actions | grid-column | "1 / -1" |
| .site-form input | -webkit-appearance | none |
| .site-form textarea | -webkit-appearance | none |
| .site-form input | appearance | none |
| .site-form textarea | appearance | none |
| .site-form input | box-sizing | border-box |
| .site-form textarea | box-sizing | border-box |
| .site-form input | display | block |
| .site-form textarea | display | block |
| .site-form input | width | "100%" |
| .site-form textarea | width | "100%" |
| .site-form input | height | "2.75rem" |
| .site-form textarea | min-height | "10rem" |
| .site-form label:nth-child(4) textarea | min-height | "14rem" |
| .site-form textarea | resize | vertical |
| .site-form input | padding | "0 0.9rem" |
| .site-form textarea | padding | "0.75rem 0.9rem" |
| .site-form input | border | 1px solid var(--border) |
| .site-form textarea | border | 1px solid var(--border) |
| .site-form input | border-radius | var(--radius-sm) |
| .site-form textarea | border-radius | var(--radius-sm) |
| .site-form input | background | "rgba(0,0,0,.4)" |
| .site-form textarea | background | "rgba(0,0,0,.4)" |
| .site-form input | color | var(--paper) |
| .site-form textarea | color | var(--paper) |
| .site-form input | font | inherit |
| .site-form textarea | font | inherit |
| .site-form input | font-size | "0.95rem" |
| .site-form textarea | font-size | "0.95rem" |
| .site-form input | line-height | "1.4" |
| .site-form textarea | line-height | "1.65" |
| .site-form input | transition | "border-color .2s ease, box-shadow .2s ease" |
| .site-form textarea | transition | "border-color .2s ease, box-shadow .2s ease" |
| .site-form input:hover | border-color | var(--gold-dim) |
| .site-form textarea:hover | border-color | var(--gold-dim) |
| .site-form input:focus | outline | none |
| .site-form textarea:focus | outline | none |
| .site-form input:focus | border-color | var(--gold) |
| .site-form textarea:focus | border-color | var(--gold) |
| .site-form input:focus | box-shadow | var(--ring) |
| .site-form textarea:focus | box-shadow | var(--ring) |
| .site-form input[readonly] | background | "rgba(0,0,0,.25)" |
| .site-form input[readonly] | color | var(--paper-faint) |
| .site-form .err | color | var(--danger) |
| .site-form .err | font-size | "0.8rem" |
| .site-form .err | font-weight | "500" |
| .site-form .err | letter-spacing | "0.04em" |
| .site-form .actions | display | flex |
| .site-form .actions | align-items | center |
| .site-form .actions | gap | var(--space-4) |
| .site-form .actions | margin-top | var(--space-2) |
| .site-form .actions | flex-wrap | wrap |
| .site-form button | -webkit-appearance | none |
| .site-form button | appearance | none |
| .site-form button | height | "2.75rem" |
| .site-form button | padding | "0 1.35rem" |
| .site-form button | background | "linear-gradient(135deg, #f5e6c8, var(--gold))" |
| .site-form button | color | var(--ink) |
| .site-form button | border | "0" |
| .site-form button | border-radius | 999px |
| .site-form button | font-weight | "600" |
| .site-form button | font-size | "0.85rem" |
| .site-form button | letter-spacing | "0.12em" |
| .site-form button | cursor | pointer |
| .site-form button | box-shadow | "0 8px 28px rgba(212,175,55,.28)" |
| .site-form button | transition | "transform .2s ease, box-shadow .2s ease, filter .2s ease" |
| .site-form button:hover | filter | brightness(1.06) |
| .site-form button:hover | transform | "translateY(-1px)" |
| .site-form button:hover | box-shadow | "0 12px 36px rgba(212,175,55,.4)" |
| .site-form .actions a | color | var(--paper-faint) |
| .site-form .actions a | font-weight | "400" |
| .site-form .actions a | text-decoration | none |
| .site-form .actions a | font-size | "0.85rem" |
| .site-form .actions a | letter-spacing | "0.08em" |
| .site-form .actions a:hover | color | var(--gold) |
| .flash.err | color | var(--danger) |
| .flash.err | font-weight | "500" |
*`widgets`*
## css
**v = > vars**
**m = > motion**
**l = > layout**
**r = > responsive**
**c = > chrome**
**w = > widgets**
**css_v = > web.make_style name="vars" table=v**
**css_m = > web.make_style name="motion" table=m**
**css_l = > web.make_style name="layout" table=l**
**css_r = > web.make_style name="responsive" table=r**
**css_c = > web.make_style name="chrome" table=c**
**css_w = > web.make_style name="widgets" table=w**
`parts` =
| css |
|-----|
| `css_v` |
| `css_m` |
| `css_l` |
| `css_r` |
| `css_c` |
| `css_w` |
**out = > text.str_join xs=`parts` sep=""**
*out*
+40
View File
@@ -0,0 +1,40 @@
# Demo walkthrough (`examples/web-site`)
Aligned with The Web Conference **Demo** expectations: implemented system,
**hands-on** interaction, clear venue script, reproducible from the repo.
## Run
```bash
./scripts/build-web-plugin.sh
marqdo run examples/web-site/index.mq.md
```
Open http://127.0.0.1:18081/
## Venue script (≈3 minutes)
| Step | Action | What reviewers should notice |
|------|--------|------------------------------|
| 1 | Home | Claim badges + steps; **8 seed cards** with summaries |
| 2 | Click a card | `/post/{slug}` detail from the same table (`detail=True`) |
| 3 | Open `index.mq.md` beside the browser | Narrative = program; field/rule/route/intro tables |
| 4 | `/new` empty title → submit | Server validation from **rule table** (no author JS) |
| 5 | `/new` valid title+slug → submit | Row appears on Home and Admin |
| 6 | Top-nav **Login** (`admin` / `demo`) → **Admin** | Session gate; desk shell + create form |
| 7 | Terminal check | `find examples/web-site \( -name '*.js' -o -name '*.css' \)` → **0** |
## Authoring contract
| Surface | Source |
|---------|--------|
| Routes / forms / admin | GFM tables in `index.mq.md` |
| Styles | `styles/shell.mq.md` → `web.make_style` (ink / wine / gold; `shell_css=off`) |
| Intro | `| front | back | style |` → `page.compose_intro` (same bind as main) |
| Fonts | `page.head` table → Google Fonts (Noto Serif SC + Ma Shan Zheng) |
| Author `.js` / `.css` | **None** |
## Video
Same beats as above; English captions preferred. See thesis
`www-2027-demo/VIDEO.md` for length / upload tips.
+20 -3
View File
@@ -1,10 +1,27 @@
# examples/web-site
Canonical English sample for `ext/web` (design §4).
Canonical **English** sample for `ext/web` — WWW Demo walkthrough site.
**Hands-on script:** [DEMO.md](./DEMO.md)
## Authoring rules (checkable)
| Surface | How it is authored |
|---------|-------------------|
| Routes / forms / admin | GFM tables + class methods |
| Look-and-feel | Host shell CSS + **style tables** |
| Author business JavaScript | **none** |
| Author hand-written `.css` | **none** |
```bash
cargo build -p marqdo_plugin_web
cargo run -- examples/web-site/index.mq.md
marqdo run examples/web-site/index.mq.md
```
Then open http://127.0.0.1:18081/ — `/about`, `/new` (form in page slot), `/admin`, `/static/site.css`.
http://127.0.0.1:18081/ — `/about`, `/new` (validation), `/admin` (list + create).
```bash
find examples/web-site \( -name '*.js' -o -name '*.css' \) | wc -l # 0
```
Chinese twin: [`examples/web-site-zh/`](../web-site-zh/).
+29
View File
@@ -0,0 +1,29 @@
---
title: components/desk
description: Admin desk chrome — brand reads Admin; no public side rail.
---
## nav
`nav` =
| front | back | style | media | when |
|-------|------|-------|-------|------|
| Admin | /admin | | | |
| Site | / | | | |
| New | /new | | | |
| Logout | /admin/logout | | | auth |
*`nav`*
## foot
`foot` =
| front | back | style |
|-------|------|-------|
| Site | / | |
| Admin | /admin | |
| Logout | /admin/logout | |
*`foot`*
+5 -3
View File
@@ -2,8 +2,10 @@
`foot` =
| 属性 | 值 | 样式 |
|------|-----|------|
| Marqdo | https://github.com | |
| front | back | style |
|-------|------|-------|
| Marqdo | https://www.marqdo.com/ | |
| Source | https://github.com/cflmy/marqdo | |
*`foot`*
+9 -7
View File
@@ -1,14 +1,16 @@
## nav
Static top links for the shell.
Brand first, then demo routes. Guest sees **Login**; signed-in sees **Admin** + **Logout**.
`nav` =
| 属性 | 值 | 样式 |
|------|-----|------|
| Home | / | |
| About | /about | |
| New | /new | |
| Admin | /admin | |
| front | back | style | media | when |
|-------|------|-------|-------|------|
| Marqdo | / | | | |
| About | /about | | | |
| New | /new | | | |
| Login | /login | | | guest |
| Admin | /admin | | | auth |
| Logout | /admin/logout | | | auth |
*`nav`*
+9 -4
View File
@@ -1,10 +1,15 @@
## side
Hands-on demo checklist (links only — no JS).
`side` =
| 属性 | 值 | 样式 |
|------|-----|------|
| Notes | / | |
| Docs | https://github.com | |
| front | back | style | media | when |
|-------|------|-------|-------|------|
| 1. Home | / | | | |
| 2. New form | /new | | | |
| 3. Login | /login | | | guest |
| 3. Admin | /admin | | | auth |
| About | /about | | | |
*`side`*
+16 -6
View File
@@ -2,21 +2,31 @@
`fields` =
| 字段 | 类型 | 可空 |
|------|------|------|
| name | type | nullable |
|------|------|----------|
| id | integer | false |
| title | text | false |
| slug | text | false |
| summary | text | true |
| body | text | true |
*`fields`*
## seed
Longer demo rows — cards show summary; /post/{slug} shows full body (Markdown).
`rows` =
| id | title | body |
|----|-------|------|
| 1 | Hello Marqdo | First article from a GFM table. |
| 2 | Code as docs | The page table is the program. |
| id | title | slug | summary | body |
|----|-------|------|---------|------|
| 1 | Hello Marqdo | hello-marqdo | A runnable Markdown file is both the site docs and the deployed app — tables declare routes, forms, and styles. | "Marqdo treats an .mq.md file as an executable document. The narrative you read in the editor is the same artifact the server runs: GFM tables become schema, forms, navigation, and CSS. This demo shows that contract end-to-end — open New, trigger a rule-table validation error, then publish a row that appears on Home and Admin without any author JavaScript." |
| 2 | Tables as the full stack | tables-full-stack | Schema, forms, routes, admin pages, and theme tokens share one tabular dialect instead of a JS/CSS split. | "Most stacks split concerns across languages: SQL or an ORM for data, a form library for input, a router for URLs, and a stylesheet for look. Marqdo collapses those surfaces into GFM tables with the same geometry authors already use for documentation. Field tables, rule tables, bind tables, and style tables are not metaphors — they are the runtime. The result is a site you can skim as prose and execute as a program." |
| 3 | Zero author JS and CSS | zero-author-js-css | Business logic stays in Markdown; appearance is style tables plus the host shell — no hand-written business JS or author .css. | "Author business JavaScript is zero by construction: validation runs from rule tables on the server, and list/detail pages are bind tables rendered by the host. Author .css files are also unnecessary when theme tokens live in property/value tables assembled by make_style. The demo turns shell_css=off so only those declared styles paint the page — proving the claim for a conference audience." |
| 4 | Card to detail in one bind | card-to-detail | List cards bind href to slug; a /post/{slug} route plus detail=True opens the full article. | "Click any card on the home page. The list bind exposes href from articles.slug, and link_prefix prefixes /post/. The detail page reuses the same table with a query slug = {slug} and page.detail so the first row renders as a full article — title and Markdown body — instead of a card grid. That is the same pattern used by larger Marqdo sites such as 求道量子." |
| 5 | Style tables not stylesheets | style-tables | Named style tables (kicker, intro_title, card_title) bind through the third column of every layout table. | "Intro, cards, and chrome all use the bind shape front/back/style. The style column points at a named property table in styles/shell.mq.md. When compose_intro or compose_main runs, those tables become CSS classes on the page. Authors never open a .css file to tweak the demo look — they edit readable Markdown tables that stay next to the copy they style." |
| 6 | Forms from field and rule tables | forms-from-tables | Empty title on New fails from the rule table; a valid submit inserts a row shared with Admin. | "The New and Admin pages mount the same form object: a field table declares labels and types, a rule table declares required and max constraints with messages. Submit with an empty title and the error is server-side, not a client script. Fill a title and slug, submit again, and the row shows up in the card grid and under Admin — one schema, two surfaces, zero author JS." |
| 7 | Seed data is documentation | seed-is-docs | These paragraphs were written as a GFM seed table — the demo content is part of the program. | "Seed rows live beside the schema in db/articles.mq.md. On first boot the host inserts them when the articles table is empty. That means the demo narrative is versioned with the code: longer summaries for cards, fuller bodies for detail pages, and slugs that make deep links stable. Reviewers can open the seed table and see exactly what the venue site will show." |
| 8 | Why this Demo matters | why-demo-matters | WWW Demo needs a hands-on artifact reviewers can run, click, and compare to source in minutes. | "A Demo track asks for an implemented system, not a slide-only pitch. This sample is intentionally small: one SQLite table, a handful of routes, and a literary shell — yet it covers the paper claim (tables as the full stack) with a three-step script. Clone the repo, run the web-site sample, click a card, break a form, then open index.mq.md beside the browser. That loop is the publication." |
*`rows`*
+170 -22
View File
@@ -1,73 +1,221 @@
---
title: web-site
description: Home + /about + /new (form in page slot) + admin.
description: >-
WWW Demo sample — GFM tables for shell, schema, forms, styles, and admin.
Author business JavaScript: none. Author hand-written .css: none.
import web:ext/web/web.mq.md
import shell:styles/shell.mq.md
import nav:components/nav.mq.md
import side:components/side.mq.md
import foot:components/foot.mq.md
import desk:components/desk.mq.md
import articles:db/articles.mq.md
import db:db/index.mq.md
---
# main
This Markdown file is both the **site documentation** and the **running app**.
Routes, forms, validation, admin pages, and look-and-feel are **GFM tables** —
no hand-written business JavaScript and no author .css file.
`home` =
| 组件 | 样式 |
|------|------|
| src | style |
|-----|-------|
| nav.`nav` | shell.`topnav` |
| side.`side` | shell.`side_panel` |
| foot.`foot` | |
| foot.`foot` | shell.`footer` |
Main content is not a reusable component, so it is authored here.
Public shell (nav + side + foot). Desk shell drops the public side rail.
`desk_shell` =
| src | style |
|-----|-------|
| desk.`nav` | shell.`topnav` |
| desk.`foot` | shell.`footer` |
List cards: summary + slug link (click through to detail).
`index` =
| 属性 | 值 | 样式 |
|------|-----|------|
| front | back | style |
|-------|------|-------|
| title | articles.`articles`.title | shell.`card_title` |
| body | articles.`articles`.body | shell.`card_body` |
| body | articles.`articles`.summary | shell.`card_body` |
| href | articles.`articles`.slug | |
Article create form (design §5.5): field table + rules table.
Detail bind for /post/{slug} (full Markdown body).
`detail` =
| front | back | style |
|-------|------|-------|
| title | articles.`articles`.title | shell.`card_title` |
| body | articles.`articles`.body | |
`by_slug` =
| field | op | value |
|-------|-----|-------|
| slug | = | {slug} |
Home intro — same bind shape as main (front / back / style).
`home_intro` =
| front | back | style |
|-------|------|-------|
| kicker | WWW demo · tables as the full stack | shell.`kicker` |
| title | Marqdo | shell.`intro_title` |
| lede | "One executable Markdown artifact declares routes, forms, admin pages, and styles — no hand-written business JavaScript, no author .css. Click a card for the full article, then try the three steps below." | shell.`lede` |
| claim | 0 author JS | shell.`claim` |
| claim | 0 author .css | shell.`claim` |
| claim | GFM tables | shell.`claim` |
| step | "Click any card — /post/{slug} opens the detail page from the same articles table." | shell.`step` |
| step | "Open [New](/new) and submit with an empty title (validation from a rule table)." | shell.`step` |
| step | "Open top-nav **Login** (admin / demo), then **Admin** — gated desk with create form + list." | shell.`step` |
`about_intro` =
| front | back | style |
|-------|------|-------|
| kicker | about | shell.`kicker` |
| title | About | shell.`intro_title` |
| lede | "Documentation and the deployed site stay one .mq.md artifact. Layout and theme are GFM style tables in styles/shell.mq.md — structure without hand-written CSS or business JavaScript." | shell.`lede` |
| claim | docs = program | shell.`claim` |
| claim | server-side rules | shell.`claim` |
| claim | hands-on | shell.`claim` |
`new_intro` =
| front | back | style |
|-------|------|-------|
| kicker | form · try validation | shell.`kicker` |
| title | New article | shell.`intro_title` |
| lede | "Leave Title empty and submit — the error comes from the rule table, not client JavaScript. Then fill title, slug, and summary to create a row shared with Admin and the card grid." | shell.`lede` |
`admin_intro` =
| front | back | style |
|-------|------|-------|
| kicker | desk · you are in admin | shell.`kicker` |
| title | Admin | shell.`intro_title` |
| lede | "This is the management desk (login required): same articles schema as the public site, assembled as list + create form — not a separate SPA. Use Site in the topnav to return, or Logout to end the session." | shell.`lede` |
| claim | login-gated | shell.`claim` |
| claim | table-declared | shell.`claim` |
| claim | "create + list" | shell.`claim` |
`post_intro` =
| front | back | style |
|-------|------|-------|
| kicker | article · table-bound detail | shell.`kicker` |
Article create form: field table + rules table (server-side validation).
`article_fields` =
| 字段 | 标签 | 类型 | 必填 | 默认 |
|------|------|------|------|------|
| name | label | type | required | default |
|------|-------|------|----------|---------|
| title | Title | text | true | |
| slug | Slug | text | true | |
| summary | Summary | textarea | false | |
| body | Body | textarea | false | |
`article_rules` =
| 字段 | 规则 | 消息 |
|------|------|------|
| field | rule | message |
|-------|------|---------|
| title | required | Title is required |
| title | max:120 | Title is too long |
| slug | required | Slug is required |
| slug | max:80 | Slug is too long |
| summary | max:500 | Summary is too long |
| body | max:8000 | Body is too long |
SEO / Open Graph for the home page (still a table).
`home_meta` =
| key | value |
|-----|-------|
| description | Tables as the full stack — Marqdo Web demo with zero author business JavaScript. |
| og:type | website |
| og:title | Marqdo Web Site |
Neat CJK sans for body; Great Vibes for English display.
`fonts` =
| rel | href | crossorigin |
|-----|------|-------------|
| preconnect | https://fonts.googleapis.com | |
| preconnect | https://fonts.gstatic.com | anonymous |
| stylesheet | https://fonts.googleapis.com/css2?family=Great+Vibes&family=Noto+Sans+SC:wght@300;400;500;700&family=Noto+Serif+SC:wght@400;600&display=swap | |
**store = > db.open**
**page = > web.page title="Marqdo Web Site" intro="<h1>Web Site</h1><p>Tables + class methods.</p>"**
**site_css = > shell.css**
**page = > web.page title="Marqdo Web Site" shell_css="off"**
**page = > page.compose_intro intro=home_intro**
**page = > page.meta meta=home_meta**
**page = > page.head table=fonts**
**page = > page.css css=site_css**
**page = > page.compose_components components=home**
**page = > page.compose_main main=index**
**page = > page.link_prefix prefix="/post/"**
About page: same shell, different intro (no main bind).
**about = > web.page title="About" intro="<h1>About</h1><p>Marqdo web = tables + class methods.</p>"**
**about = > web.page title="About · Marqdo Web" shell_css="off"**
**about = > about.compose_intro intro=about_intro**
**about = > about.head table=fonts**
**about = > about.css css=site_css**
**about = > about.compose_components components=home**
**article_form = > web.form table="articles" action="insert"**
**article_form = > article_form.fields fields=article_fields**
**article_form = > article_form.rules rules=article_rules**
New article: form embedded in the page main slot (design §5.5.4).
**new = > web.page title="New article" intro="<h1>New article</h1><p>Form lives in the main slot.</p>"**
**new = > web.page title="New article · Marqdo Web" shell_css="off"**
**new = > new.compose_intro intro=new_intro**
**new = > new.head table=fonts**
**new = > new.css css=site_css**
**new = > new.compose_components components=home**
**new = > new.compose_form id="article" form=article_form**
**app = > web.app page=page db=store admin=True host="127.0.0.1" port=18081**
**desk = > web.page title="Admin · Marqdo Web" shell_css="off"**
**desk = > desk.chrome body_class="is-desk"**
**desk = > desk.compose_intro intro=admin_intro**
**desk = > desk.head table=fonts**
**desk = > desk.css css=site_css**
**desk = > desk.compose_components components=desk_shell**
**desk = > desk.compose_form id="article" form=article_form**
**desk = > desk.compose_main main=index**
**desk = > desk.link_prefix prefix="/post/"**
**post = > web.page title="Article · Marqdo Web" shell_css="off"**
**post = > post.compose_intro intro=post_intro**
**post = > post.head table=fonts**
**post = > post.css css=site_css**
**post = > post.compose_components components=home**
**post = > post.compose_main main=detail**
**post = > post.query query=by_slug**
**post = > post.detail detail=True**
Demo credentials (table-declared users — host session auth, no author JS).
`admins` =
| username | password | role |
|----------|----------|------|
| admin | demo | admin |
**app = > web.app page=page db=store admin=False host="127.0.0.1" port=18081 shell_css="off" login_redirect="/admin" logout_redirect="/"**
**app = > app.route path="/about" page=about**
**app = > app.route path="/new" page=new**
**app = > app.static dir="public" mount="/static"**
**app = > app.route path="/admin" page=desk**
**app = > app.route path="/post/{slug}" page=post**
**app = > app.auth users=admins session_ttl=3600 login_path="/login" login_redirect="/admin" logout_redirect="/"**
**app = > app.gate path="/admin" roles="admin" match="prefix" on_deny="redirect" exclude="/login"**
> `app`.listen
-5
View File
@@ -1,5 +0,0 @@
/* Optional site stylesheet — served at /static/site.css */
body.site-hint::before {
content: "static ok";
display: none;
}
+648 -15
View File
@@ -1,11 +1,233 @@
---
title: styles/shell
description: >-
Literary dark theme for examples/web-site — ink / wine / gold after the
anlian.cyou Zhang Ailing topic. GFM tables only; no author .css.
import web:ext/web/web.mq.md
import text:lib/text.mq.md
---
Authors style the site with **GFM tables** only. App pages use `shell_css=off`
so host defaults do not fight this theme. Palette mirrors
[海上花开](https://www.anlian.cyou/topics/author-zhangailing/): night ink,
wine, cold gold, serif display.
## vars
`vars` =
| selector | property | value |
|----------|----------|-------|
| :root | --ink | #0a0809 |
| :root | --ink-lift | #141012 |
| :root | --wine | #6b1e3a |
| :root | --wine-soft | rgba(107,30,58,0.35) |
| :root | --gold | #d4af37 |
| :root | --gold-dim | rgba(212,175,55,0.45) |
| :root | --gold-soft | rgba(212,175,55,0.12) |
| :root | --paper | rgba(255,248,240,0.92) |
| :root | --paper-dim | rgba(255,248,240,0.72) |
| :root | --paper-faint | rgba(255,248,240,0.48) |
| :root | --glass | rgba(20,12,18,0.72) |
| :root | --glass-strong | rgba(20,12,18,0.88) |
| :root | --border | rgba(212,175,55,0.22) |
| :root | --border-soft | rgba(212,175,55,0.12) |
| :root | --danger | #e8a0a8 |
| :root | --radius | 4px |
| :root | --radius-sm | 2px |
| :root | --space-2 | 8px |
| :root | --space-3 | 12px |
| :root | --space-4 | 16px |
| :root | --space-5 | 20px |
| :root | --space-6 | 24px |
| :root | --space-8 | 32px |
| :root | --text | 16px |
| :root | --leading | "1.75" |
| :root | --shadow | "0 24px 80px rgba(0,0,0,.55), inset 0 1px 0 rgba(255,255,255,.06)" |
| :root | --shadow-card | "0 12px 40px rgba(107,30,58,.35)" |
| :root | --ring | "0 0 0 2px rgba(212,175,55,.35)" |
| :root | --serif | "'Noto Serif SC', 'Source Serif 4', Georgia, serif" |
| :root | --sans | "'Noto Sans SC', 'IBM Plex Sans', system-ui, sans-serif" |
| :root | --display | "'Great Vibes', 'Allura', cursive" |
| :root | --mono | "ui-monospace, SFMono-Regular, Menlo, Consolas, monospace" |
| ::selection | background | rgba(212,175,55,0.35) |
| ::selection | color | var(--paper) |
*`vars`*
## motion
`motion` =
| selector | property | value |
|----------|----------|-------|
| @keyframes rise 0% | opacity | "0" |
| @keyframes rise 0% | transform | translateY(14px) |
| @keyframes rise 100% | opacity | "1" |
| @keyframes rise 100% | transform | translateY(0) |
| @keyframes float 0% | transform | translateY(0) |
| @keyframes float 0% | opacity | "0.7" |
| @keyframes float 50% | transform | translateY(6px) |
| @keyframes float 50% | opacity | "1" |
| @keyframes float 100% | transform | translateY(0) |
| @keyframes float 100% | opacity | "0.7" |
| @keyframes goldPulse 0% | text-shadow | "0 0 24px rgba(212,175,55,.2)" |
| @keyframes goldPulse 50% | text-shadow | "0 0 48px rgba(212,175,55,.45)" |
| @keyframes goldPulse 100% | text-shadow | "0 0 24px rgba(212,175,55,.2)" |
| @keyframes particleDrift 0% | transform | translate3d(0,0,0) |
| @keyframes particleDrift 50% | transform | translate3d(-2.5vw, 1.5vh, 0) |
| @keyframes particleDrift 100% | transform | translate3d(0,0,0) |
| @keyframes particleDrift2 0% | transform | translate3d(0,0,0) |
| @keyframes particleDrift2 50% | transform | translate3d(2vw, -2vh, 0) |
| @keyframes particleDrift2 100% | transform | translate3d(0,0,0) |
| @keyframes nebulaPulse 0% | opacity | "0.55" |
| @keyframes nebulaPulse 50% | opacity | "0.9" |
| @keyframes nebulaPulse 100% | opacity | "0.55" |
*`motion`*
## layout
`layout` =
| selector | property | value |
|----------|----------|-------|
| * | box-sizing | border-box |
| html | scroll-behavior | smooth |
| html | -webkit-text-size-adjust | 100% |
| body | margin | "0" |
| body | min-height | 100vh |
| body | font-family | var(--sans) |
| body | font-weight | "400" |
| body | font-size | var(--text) |
| body | line-height | var(--leading) |
| body | color | var(--paper) |
| body | background | var(--ink) |
| body | background-image | "radial-gradient(ellipse 90% 55% at 50% -15%, rgba(107,30,58,.5), transparent 58%), radial-gradient(ellipse 55% 45% at 92% 75%, rgba(212,175,55,.14), transparent 55%), radial-gradient(ellipse 40% 35% at 8% 70%, rgba(107,30,58,.22), transparent 60%), linear-gradient(180deg, #0a0809 0%, #120c10 45%, #0a0809 100%)" |
| body | background-attachment | fixed |
| body | display | grid |
| body | grid-template-rows | "auto 1fr auto" |
| body | -webkit-font-smoothing | antialiased |
| body | position | relative |
| body | overflow-x | hidden |
| body::before | content | '""' |
| body::before | position | fixed |
| body::before | inset | "0" |
| body::before | z-index | "1" |
| body::before | pointer-events | none |
| body::before | opacity | "0.1" |
| body::before | background-image | "url(\"data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E\")" |
| html::before | content | '""' |
| html::before | position | fixed |
| html::before | inset | "0" |
| html::before | z-index | "0" |
| html::before | pointer-events | none |
| html::before | background-image | "radial-gradient(ellipse 50% 40% at 15% 30%, rgba(107,30,58,.35), transparent 70%), radial-gradient(ellipse 45% 35% at 85% 60%, rgba(212,175,55,.12), transparent 65%), radial-gradient(ellipse 40% 30% at 50% 90%, rgba(107,30,58,.25), transparent 70%)" |
| html::before | animation | "nebulaPulse 12s ease-in-out infinite" |
| body::after | content | '""' |
| body::after | position | fixed |
| body::after | top | "0" |
| body::after | left | "0" |
| body::after | width | "2px" |
| body::after | height | "2px" |
| body::after | z-index | "2" |
| body::after | pointer-events | none |
| body::after | border-radius | 50% |
| body::after | background | transparent |
| body::after | box-shadow | "82vw 15vh 0px 0px rgba(212,175,55,0.55),29vw 18vh 0px 1px rgba(212,175,55,0.25),95vw 70vh 1px 0px rgba(212,175,55,0.55),4vw 12vh 0px 1px rgba(212,175,55,0.35),78vw 4vh 0px 1px rgba(245,230,200,0.5),84vw 90vh 1px 0px rgba(245,230,200,0.5),58vw 76vh 0px 0px rgba(255,248,240,0.4),90vw 55vh 0px 0px rgba(255,248,240,0.4),28vw 98vh 0px 0px rgba(255,248,240,0.4),49vw 13vh 0px 1px rgba(255,248,240,0.4),34vw 6vh 1px 1px rgba(212,175,55,0.25),16vw 49vh 0px 1px rgba(212,175,55,0.55),80vw 47vh 0px 1px rgba(245,230,200,0.5),9vw 6vh 0px 0px rgba(212,175,55,0.25),11vw 30vh 1px 0px rgba(212,175,55,0.55),59vw 82vh 0px 0px rgba(255,248,240,0.4),46vw 27vh 0px 1px rgba(212,175,55,0.25),88vw 83vh 0px 1px rgba(212,175,55,0.55),94vw 32vh 1px 0px rgba(212,175,55,0.35),35vw 82vh 0px 1px rgba(212,175,55,0.25),42vw 99vh 0px 0px rgba(212,175,55,0.55),41vw 52vh 0px 0px rgba(255,248,240,0.4),73vw 92vh 0px 1px rgba(255,248,240,0.4),64vw 51vh 1px 0px rgba(212,175,55,0.25),34vw 18vh 0px 1px rgba(212,175,55,0.35),75vw 55vh 1px 0px rgba(245,230,200,0.5),29vw 18vh 1px 0px rgba(245,230,200,0.5),97vw 7vh 0px 1px rgba(212,175,55,0.55),21vw 88vh 0px 0px rgba(107,30,58,0.45),49vw 77vh 0px 1px rgba(107,30,58,0.45),2vw 88vh 0px 1px rgba(212,175,55,0.25),69vw 97vh 0px 0px rgba(255,248,240,0.4),38vw 56vh 1px 0px rgba(212,175,55,0.35),93vw 93vh 0px 1px rgba(255,248,240,0.4),14vw 81vh 0px 0px rgba(255,248,240,0.4),48vw 98vh 0px 1px rgba(212,175,55,0.35),42vw 63vh 0px 0px rgba(212,175,55,0.55),40vw 31vh 0px 1px rgba(212,175,55,0.55),11vw 11vh 1px 0px rgba(212,175,55,0.25),98vw 69vh 0px 1px rgba(212,175,55,0.35),61vw 71vh 0px 1px rgba(212,175,55,0.35),78vw 55vh 0px 1px rgba(212,175,55,0.35),40vw 52vh 0px 0px rgba(212,175,55,0.25),67vw 58vh 0px 0px rgba(212,175,55,0.55),9vw 44vh 0px 1px rgba(212,175,55,0.55),29vw 1vh 0px 0px rgba(212,175,55,0.55),9vw 5vh 0px 1px rgba(255,248,240,0.4),31vw 36vh 1px 0px rgba(212,175,55,0.25),70vw 17vh 1px 0px rgba(212,175,55,0.25),61vw 53vh 0px 0px rgba(212,175,55,0.35),85vw 56vh 1px 0px rgba(255,248,240,0.4),60vw 94vh 0px 0px rgba(212,175,55,0.55),52vw 94vh 0px 0px rgba(255,248,240,0.4),25vw 25vh 1px 0px rgba(245,230,200,0.5),55vw 24vh 1px 0px rgba(255,248,240,0.4),10vw 57vh 0px 0px rgba(245,230,200,0.5),84vw 70vh 0px 0px rgba(212,175,55,0.55),22vw 53vh 1px 0px rgba(107,30,58,0.45),52vw 8vh 1px 0px rgba(212,175,55,0.35),50vw 34vh 0px 0px rgba(107,30,58,0.45),90vw 94vh 1px 0px rgba(245,230,200,0.5),25vw 38vh 0px 1px rgba(212,175,55,0.35),95vw 70vh 0px 0px rgba(212,175,55,0.55),7vw 75vh 0px 0px rgba(107,30,58,0.45),66vw 11vh 0px 1px rgba(212,175,55,0.35),9vw 87vh 1px 0px rgba(212,175,55,0.35),73vw 32vh 0px 1px rgba(245,230,200,0.5),11vw 54vh 0px 0px rgba(212,175,55,0.25),27vw 86vh 0px 0px rgba(212,175,55,0.25),34vw 51vh 0px 0px rgba(212,175,55,0.35),41vw 97vh 0px 0px rgba(212,175,55,0.55),80vw 73vh 0px 1px rgba(212,175,55,0.55)" |
| body::after | animation | "particleDrift 48s ease-in-out infinite" |
| html::after | content | '""' |
| html::after | position | fixed |
| html::after | top | "0" |
| html::after | left | "0" |
| html::after | width | "1px" |
| html::after | height | "1px" |
| html::after | z-index | "2" |
| html::after | pointer-events | none |
| html::after | border-radius | 50% |
| html::after | background | transparent |
| html::after | box-shadow | "28vw 65vh 0 0 rgba(255,248,240,0.25),17vw 45vh 0 0 rgba(212,175,55,0.3),32vw 48vh 0 0 rgba(255,248,240,0.25),21vw 57vh 0 0 rgba(107,30,58,0.3),91vw 39vh 0 0 rgba(107,30,58,0.3),84vw 68vh 0 0 rgba(212,175,55,0.3),86vw 71vh 0 0 rgba(255,248,240,0.25),85vw 14vh 0 0 rgba(212,175,55,0.3),34vw 15vh 0 0 rgba(212,175,55,0.3),96vw 71vh 0 0 rgba(212,175,55,0.3),35vw 37vh 0 0 rgba(107,30,58,0.3),27vw 92vh 0 0 rgba(255,248,240,0.25),27vw 88vh 0 0 rgba(107,30,58,0.3),34vw 65vh 0 0 rgba(255,248,240,0.25),33vw 7vh 0 0 rgba(212,175,55,0.3),82vw 55vh 0 0 rgba(255,248,240,0.25),6vw 1vh 0 0 rgba(255,248,240,0.25),99vw 17vh 0 0 rgba(107,30,58,0.3),34vw 21vh 0 0 rgba(107,30,58,0.3),57vw 71vh 0 0 rgba(107,30,58,0.3),55vw 72vh 0 0 rgba(212,175,55,0.3),15vw 10vh 0 0 rgba(107,30,58,0.3),20vw 70vh 0 0 rgba(212,175,55,0.3),48vw 75vh 0 0 rgba(107,30,58,0.3),19vw 56vh 0 0 rgba(212,175,55,0.3),6vw 40vh 0 0 rgba(255,248,240,0.25),6vw 46vh 0 0 rgba(212,175,55,0.3),88vw 32vh 0 0 rgba(107,30,58,0.3),14vw 46vh 0 0 rgba(107,30,58,0.3),53vw 80vh 0 0 rgba(107,30,58,0.3),20vw 31vh 0 0 rgba(212,175,55,0.3),23vw 53vh 0 0 rgba(212,175,55,0.3),23vw 95vh 0 0 rgba(255,248,240,0.25),53vw 86vh 0 0 rgba(107,30,58,0.3),32vw 35vh 0 0 rgba(212,175,55,0.3),90vw 14vh 0 0 rgba(255,248,240,0.25),5vw 61vh 0 0 rgba(212,175,55,0.3),26vw 59vh 0 0 rgba(255,248,240,0.25),40vw 30vh 0 0 rgba(212,175,55,0.3),4vw 85vh 0 0 rgba(212,175,55,0.3),52vw 43vh 0 0 rgba(255,248,240,0.25),9vw 99vh 0 0 rgba(255,248,240,0.25),45vw 83vh 0 0 rgba(107,30,58,0.3),52vw 87vh 0 0 rgba(107,30,58,0.3),43vw 4vh 0 0 rgba(212,175,55,0.3),34vw 23vh 0 0 rgba(107,30,58,0.3),34vw 5vh 0 0 rgba(212,175,55,0.3),77vw 56vh 0 0 rgba(255,248,240,0.25)" |
| html::after | animation | "particleDrift2 64s ease-in-out infinite" |
| body.has-sidebar | grid-template-columns | "14rem minmax(0, 1fr)" |
| body.has-sidebar | grid-template-areas | '"top top" "side main" "foot foot"' |
| body.no-sidebar | grid-template-areas | '"top" "main" "foot"' |
| body.layout-stacked | grid-template-areas | '"top" "main" "foot"' |
| body.is-desk | grid-template-areas | '"top" "main" "foot"' |
| header.topnav | grid-area | top |
| aside.side | grid-area | side |
| main.main | grid-area | main |
| footer.foot | grid-area | foot |
| header.topnav | position | relative |
| header.topnav | z-index | "20" |
| aside.side | position | relative |
| aside.side | z-index | "10" |
| main.main | position | relative |
| main.main | z-index | "10" |
| footer.foot | position | relative |
| footer.foot | z-index | "10" |
| main.main | width | "100%" |
| main.main | max-width | "min(78rem, 100%)" |
| main.main | padding | "var(--space-8) var(--space-6) 4rem" |
| main.main | animation | "rise .8s cubic-bezier(.22,1,.36,1) both" |
| a | color | var(--gold) |
| a | text-decoration | none |
| a | transition | color 0.25s ease |
| a:hover | color | #f5e6c8 |
| code | font-family | var(--mono) |
| code | font-size | "0.82em" |
| code | font-weight | "400" |
| code | background | rgba(0,0,0,0.35) |
| code | border | 1px solid var(--border-soft) |
| code | padding | "0.12em 0.45em" |
| code | border-radius | var(--radius-sm) |
| code | color | var(--gold) |
*`layout`*
## responsive
`responsive` =
| media | selector | property | value |
|-------|----------|----------|-------|
| (max-width: 860px) | body.has-sidebar | grid-template-columns | 1fr |
| (max-width: 860px) | body.has-sidebar | grid-template-areas | '"top" "main" "side" "foot"' |
| (max-width: 860px) | aside.side | border-right | "0" |
| (max-width: 860px) | aside.side | border-top | 1px solid var(--border-soft) |
| (max-width: 860px) | main.main | padding | "var(--space-6) var(--space-4) var(--space-8)" |
| (max-width: 860px) | .content.cards | grid-template-columns | 1fr |
| (max-width: 860px) | .site-form form | grid-template-columns | 1fr |
| (max-width: 860px) | .site-form label:nth-child(1) | grid-column | "1 / -1" |
| (max-width: 860px) | .site-form label:nth-child(2) | grid-column | "1 / -1" |
| (max-width: 860px) | header.topnav | padding | "0.85rem var(--space-4)" |
| (max-width: 860px) | .intro_title | font-size | "2.4rem" |
| (prefers-reduced-motion: reduce) | main.main | animation | none |
| (prefers-reduced-motion: reduce) | .kicker | animation | none |
| (prefers-reduced-motion: reduce) | article.card | transition | none |
| (prefers-reduced-motion: reduce) | body::after | animation | none |
| (prefers-reduced-motion: reduce) | html::after | animation | none |
| (prefers-reduced-motion: reduce) | html::before | animation | none |
*`responsive`*
## topnav
`topnav` =
| 属性 | 值 |
|------|-----|
| background | #ffffff |
| border-bottom | 1px solid #e7e5e4 |
| property | value |
|----------|-------|
| position | sticky |
| top | "0" |
| z-index | "40" |
| display | flex |
| align-items | center |
| justify-content | flex-start |
| gap | var(--space-4) |
| padding | "1rem var(--space-6)" |
| background | "linear-gradient(180deg, rgba(10,8,9,.92) 0%, rgba(10,8,9,.55) 70%, transparent 100%)" |
| backdrop-filter | blur(10px) |
| -webkit-backdrop-filter | blur(10px) |
| border-bottom | 1px solid var(--border-soft) |
*`topnav`*
@@ -13,20 +235,42 @@
`side_panel` =
| 属性 | 值 |
|------|-----|
| background | #f5f5f4 |
| property | value |
|----------|-------|
| background | "rgba(10,8,9,.55)" |
| padding | "var(--space-6) var(--space-4)" |
| border-right | 1px solid var(--border-soft) |
*`side_panel`*
## footer
`footer` =
| property | value |
|----------|-------|
| color | var(--paper-faint) |
| font-size | "0.8rem" |
| letter-spacing | "0.08em" |
| padding | "var(--space-5) var(--space-6)" |
| border-top | 1px solid var(--border-soft) |
| background | "rgba(10,8,9,.75)" |
*`footer`*
## card_title
`card_title` =
| 属性 | 值 |
|------|-----|
| font-size | 1.15rem |
| margin | 0 0 0.35rem |
| property | value |
|----------|-------|
| font-family | var(--serif) |
| font-size | "1.15rem" |
| font-weight | "600" |
| margin | "0 0 var(--space-2)" |
| color | var(--gold) |
| letter-spacing | "0.02em" |
| line-height | "1.35" |
*`card_title`*
@@ -34,9 +278,398 @@
`card_body` =
| 属性 | 值 |
|------|-----|
| color | #57534e |
| margin | 0 |
| property | value |
|----------|-------|
| color | var(--paper-dim) |
| margin | "0" |
| line-height | "1.65" |
| font-size | "0.9rem" |
| font-weight | "400" |
| display | "-webkit-box" |
| -webkit-box-orient | vertical |
| -webkit-line-clamp | "3" |
| overflow | hidden |
*`card_body`*
## chrome
Panel + claim/steps group layout (field look comes from named bind styles).
`chrome` =
| selector | property | value |
|----------|----------|-------|
| .main-intro | background | var(--glass) |
| .main-intro | border | 1px solid var(--border) |
| .main-intro | border-radius | var(--radius) |
| .main-intro | padding | "2.25rem 1.75rem 1.85rem" |
| .main-intro | box-shadow | var(--shadow) |
| .main-intro | backdrop-filter | blur(16px) |
| .main-intro | -webkit-backdrop-filter | blur(16px) |
| .main-intro | margin-bottom | var(--space-8) |
| .main-intro > .claim | display | flex |
| .main-intro > .claim | flex-wrap | wrap |
| .main-intro > .claim | gap | var(--space-2) |
| .main-intro > .claim | margin | "0 0 var(--space-6)" |
| .main-intro > .steps | margin | "0" |
| .main-intro > .steps | padding | "var(--space-5) var(--space-5) var(--space-5) 1.5rem" |
| .main-intro > .steps | color | var(--paper-dim) |
| .main-intro > .steps | background | "rgba(0,0,0,.35)" |
| .main-intro > .steps | border | 1px solid var(--border-soft) |
| .main-intro > .steps | border-left | 2px solid var(--gold-dim) |
| .main-intro > .steps | border-radius | var(--radius) |
| .main-intro > .steps | font-size | "0.95rem" |
| .main-intro > .steps | letter-spacing | "0.02em" |
| .main-intro > .steps a | color | var(--gold) |
| .main-intro > .steps a | font-weight | "500" |
| .main-intro > .steps a:hover | color | #f5e6c8 |
| .article | background | var(--glass) |
| .article | border | 1px solid var(--border) |
| .article | border-radius | var(--radius) |
| .article | padding | "2rem 1.75rem" |
| .article | box-shadow | var(--shadow) |
| .article | backdrop-filter | blur(16px) |
| .article | -webkit-backdrop-filter | blur(16px) |
| .article-title | font-family | var(--serif) |
| .article-title | font-size | "clamp(1.75rem, 4vw, 2.35rem)" |
| .article-title | font-weight | "600" |
| .article-title | color | var(--gold) |
| .article-title | letter-spacing | "0.04em" |
| .article-title | margin | "0 0 var(--space-5)" |
| .article-title | line-height | "1.25" |
| .article-body | color | var(--paper-dim) |
| .article-body | font-family | var(--sans) |
| .article-body | font-size | "1.02rem" |
| .article-body | line-height | "1.85" |
| .article-body.md p | margin | "0 0 1.1rem" |
| .article-body.md a | color | var(--gold) |
| article.card | cursor | pointer |
| a.card-link | color | inherit |
| a.card-link | text-decoration | none |
| a.card-link:hover | color | inherit |
*`chrome`*
## kicker
`kicker` =
| property | value |
|----------|-------|
| letter-spacing | "0.32em" |
| text-transform | uppercase |
| font-size | "0.72rem" |
| color | var(--gold-dim) |
| margin | "0 0 var(--space-4)" |
| font-weight | "400" |
| font-family | var(--sans) |
| animation | "float 2.8s ease-in-out infinite" |
*`kicker`*
## intro_title
`intro_title` =
| property | value |
|----------|-------|
| font-family | var(--display) |
| font-size | "clamp(3rem, 10vw, 4.8rem)" |
| font-weight | "400" |
| line-height | "1.15" |
| letter-spacing | "0.04em" |
| margin | "0 0 var(--space-4)" |
| color | transparent |
| background | "linear-gradient(135deg, #f5e6c8 0%, var(--gold) 42%, var(--wine) 100%)" |
| -webkit-background-clip | text |
| background-clip | text |
| animation | "goldPulse 4.5s ease-in-out infinite" |
*`intro_title`*
## lede
`lede` =
| property | value |
|----------|-------|
| color | var(--paper-dim) |
| max-width | "34rem" |
| line-height | "1.85" |
| margin | "0 0 var(--space-5)" |
| font-size | "1.05rem" |
| letter-spacing | "0.02em" |
| font-weight | "400" |
| font-family | var(--sans) |
*`lede`*
## claim
`claim` =
| property | value |
|----------|-------|
| display | inline-flex |
| align-items | center |
| padding | "0.2rem 0.65rem" |
| border-radius | var(--radius-sm) |
| background | var(--wine-soft) |
| color | #f0c9d4 |
| font-size | "0.68rem" |
| font-weight | "500" |
| letter-spacing | "0.14em" |
| border | 1px solid rgba(107,30,58,0.5) |
*`claim`*
## step
`step` =
| property | value |
|----------|-------|
| margin | "0.55rem 0" |
*`step`*
## widgets
`widgets` =
| selector | property | value |
|----------|----------|-------|
| ul.nav | display | flex |
| ul.nav | flex-wrap | wrap |
| ul.nav | align-items | center |
| ul.nav | gap | "0.35rem 1rem" |
| ul.nav | list-style | none |
| ul.nav | margin | "0" |
| ul.nav | padding | "0" |
| ul.nav a | display | inline-flex |
| ul.nav a | align-items | center |
| ul.nav a | text-decoration | none |
| ul.nav a | color | var(--paper-dim) |
| ul.nav a | padding | "0.35rem 0" |
| ul.nav a | border-radius | "0" |
| ul.nav a | font-weight | "400" |
| ul.nav a | font-size | "0.8rem" |
| ul.nav a | letter-spacing | "0.14em" |
| ul.nav a | transition | color 0.25s ease |
| ul.nav a:hover | background | transparent |
| ul.nav a:hover | color | var(--gold) |
| ul.nav a:hover | text-decoration | none |
| ul.nav a[href="/admin"] | color | var(--gold) |
| ul.nav a[href="/admin"] | letter-spacing | "0.18em" |
| ul.nav a[href="/admin"] | border-bottom | 1px solid var(--gold-dim) |
| ul.side-nav a[href="/admin"] | color | var(--gold) |
| body.is-desk header.topnav | border-bottom | 1px solid rgba(107,30,58,0.55) |
| body.is-desk header.topnav | box-shadow | "0 12px 40px rgba(107,30,58,.18)" |
| body.is-desk .main-intro | border-left | 3px solid var(--wine) |
| body.is-desk .site-form | border-color | rgba(107,30,58,0.45) |
| body.is-desk .site-form | box-shadow | "0 0 0 1px rgba(212,175,55,.12), 0 18px 48px rgba(0,0,0,.35)" |
| body.is-desk .content.cards | margin-top | var(--space-6) |
| ul.nav li:first-child a | font-family | var(--display) |
| ul.nav li:first-child a | font-weight | "400" |
| ul.nav li:first-child a | color | var(--gold) |
| ul.nav li:first-child a | font-size | "1.85rem" |
| ul.nav li:first-child a | letter-spacing | "0.06em" |
| ul.nav li:first-child a | padding | "0.1rem 0.2rem 0.1rem 0" |
| ul.nav li:first-child a:hover | background | transparent |
| ul.nav li:first-child a:hover | color | #f5e6c8 |
| .side-label | display | block |
| .side-label | font-size | "0" |
| .side-label | margin | "0 0 var(--space-4)" |
| .side-label::before | content | '"Path"' |
| .side-label::before | display | block |
| .side-label::before | font-size | "0.68rem" |
| .side-label::before | letter-spacing | "0.28em" |
| .side-label::before | text-transform | uppercase |
| .side-label::before | color | var(--gold-dim) |
| .side-label::before | font-weight | "400" |
| ul.side-nav | list-style | none |
| ul.side-nav | margin | "0" |
| ul.side-nav | padding | "0" |
| ul.side-nav | display | grid |
| ul.side-nav | gap | "2px" |
| ul.side-nav | border-left | 1px solid var(--border) |
| ul.side-nav | padding-left | "0.85rem" |
| ul.side-nav | margin-left | "0.25rem" |
| ul.side-nav a | display | block |
| ul.side-nav a | text-decoration | none |
| ul.side-nav a | color | var(--paper-dim) |
| ul.side-nav a | padding | "0.45rem 0.35rem" |
| ul.side-nav a | border-radius | "0" |
| ul.side-nav a | font-weight | "400" |
| ul.side-nav a | font-size | "0.88rem" |
| ul.side-nav a | letter-spacing | "0.06em" |
| ul.side-nav a | border | "0" |
| ul.side-nav a | position | relative |
| ul.side-nav a:hover | background | transparent |
| ul.side-nav a:hover | border-color | transparent |
| ul.side-nav a:hover | color | var(--gold) |
| ul.side-nav a:hover | text-decoration | none |
| ul.side-nav a:hover | box-shadow | none |
| ul.foot-nav | display | flex |
| ul.foot-nav | gap | var(--space-4) |
| ul.foot-nav | list-style | none |
| ul.foot-nav | margin | "0" |
| ul.foot-nav | padding | "0" |
| ul.foot-nav a | color | var(--paper-faint) |
| ul.foot-nav a | font-weight | "400" |
| ul.foot-nav a | letter-spacing | "0.1em" |
| ul.foot-nav a | font-size | "0.78rem" |
| ul.foot-nav a:hover | color | var(--gold) |
| .content.cards | display | grid |
| .content.cards | gap | var(--space-4) |
| .content.cards | margin-top | "0" |
| .content.cards | grid-template-columns | "repeat(auto-fill, minmax(16rem, 1fr))" |
| article.card | background | "rgba(0,0,0,.35)" |
| article.card | border | 1px solid var(--border-soft) |
| article.card | border-radius | var(--radius-sm) |
| article.card | padding | "1.35rem 1.15rem" |
| article.card | box-shadow | none |
| article.card | transition | "border-color .35s ease, box-shadow .35s ease, transform .35s ease" |
| article.card:hover | transform | "translateY(-3px)" |
| article.card:hover | box-shadow | var(--shadow-card) |
| article.card:hover | border-color | var(--gold-dim) |
| .site-form | background | var(--glass) |
| .site-form | border | 1px solid var(--border) |
| .site-form | border-radius | var(--radius) |
| .site-form | padding | "var(--space-6) var(--space-6) var(--space-7, 1.75rem)" |
| .site-form | margin | "0 0 var(--space-6)" |
| .site-form | max-width | "100%" |
| .site-form | width | "100%" |
| .site-form | box-shadow | var(--shadow) |
| .site-form | backdrop-filter | blur(16px) |
| .site-form | -webkit-backdrop-filter | blur(16px) |
| .site-form .meta | display | none |
| .site-form form | display | grid |
| .site-form form | grid-template-columns | "minmax(0, 1fr) minmax(0, 1fr)" |
| .site-form form | column-gap | var(--space-5) |
| .site-form form | row-gap | var(--space-5) |
| .site-form form | gap | var(--space-5) |
| .site-form form | margin | "0" |
| .site-form form | width | "100%" |
| .site-form form | max-width | "100%" |
| .site-form label | display | grid |
| .site-form label | gap | var(--space-2) |
| .site-form label | margin | "0" |
| .site-form label | min-width | "0" |
| .site-form label | font-weight | "400" |
| .site-form label | color | var(--gold) |
| .site-form label | font-size | "0.78rem" |
| .site-form label | letter-spacing | "0.16em" |
| .site-form label | text-transform | uppercase |
| .site-form label:nth-child(1) | grid-column | "1" |
| .site-form label:nth-child(2) | grid-column | "2" |
| .site-form label:nth-child(n+3) | grid-column | "1 / -1" |
| .site-form .actions | grid-column | "1 / -1" |
| .site-form input | -webkit-appearance | none |
| .site-form textarea | -webkit-appearance | none |
| .site-form input | appearance | none |
| .site-form textarea | appearance | none |
| .site-form input | box-sizing | border-box |
| .site-form textarea | box-sizing | border-box |
| .site-form input | display | block |
| .site-form textarea | display | block |
| .site-form input | width | "100%" |
| .site-form textarea | width | "100%" |
| .site-form input | height | "2.75rem" |
| .site-form textarea | min-height | "10rem" |
| .site-form label:nth-child(4) textarea | min-height | "14rem" |
| .site-form textarea | resize | vertical |
| .site-form input | padding | "0 0.9rem" |
| .site-form textarea | padding | "0.75rem 0.9rem" |
| .site-form input | border | 1px solid var(--border) |
| .site-form textarea | border | 1px solid var(--border) |
| .site-form input | border-radius | var(--radius-sm) |
| .site-form textarea | border-radius | var(--radius-sm) |
| .site-form input | background | "rgba(0,0,0,.4)" |
| .site-form textarea | background | "rgba(0,0,0,.4)" |
| .site-form input | color | var(--paper) |
| .site-form textarea | color | var(--paper) |
| .site-form input | font | inherit |
| .site-form textarea | font | inherit |
| .site-form input | font-size | "0.95rem" |
| .site-form textarea | font-size | "0.95rem" |
| .site-form input | line-height | "1.4" |
| .site-form textarea | line-height | "1.65" |
| .site-form input | transition | "border-color .2s ease, box-shadow .2s ease" |
| .site-form textarea | transition | "border-color .2s ease, box-shadow .2s ease" |
| .site-form input:hover | border-color | var(--gold-dim) |
| .site-form textarea:hover | border-color | var(--gold-dim) |
| .site-form input:focus | outline | none |
| .site-form textarea:focus | outline | none |
| .site-form input:focus | border-color | var(--gold) |
| .site-form textarea:focus | border-color | var(--gold) |
| .site-form input:focus | box-shadow | var(--ring) |
| .site-form textarea:focus | box-shadow | var(--ring) |
| .site-form input[readonly] | background | "rgba(0,0,0,.25)" |
| .site-form input[readonly] | color | var(--paper-faint) |
| .site-form .err | color | var(--danger) |
| .site-form .err | font-size | "0.8rem" |
| .site-form .err | font-weight | "500" |
| .site-form .err | letter-spacing | "0.04em" |
| .site-form .actions | display | flex |
| .site-form .actions | align-items | center |
| .site-form .actions | gap | var(--space-4) |
| .site-form .actions | margin-top | var(--space-2) |
| .site-form .actions | flex-wrap | wrap |
| .site-form button | -webkit-appearance | none |
| .site-form button | appearance | none |
| .site-form button | height | "2.75rem" |
| .site-form button | padding | "0 1.35rem" |
| .site-form button | background | "linear-gradient(135deg, #f5e6c8, var(--gold))" |
| .site-form button | color | var(--ink) |
| .site-form button | border | "0" |
| .site-form button | border-radius | 999px |
| .site-form button | font-weight | "600" |
| .site-form button | font-size | "0.85rem" |
| .site-form button | letter-spacing | "0.12em" |
| .site-form button | cursor | pointer |
| .site-form button | box-shadow | "0 8px 28px rgba(212,175,55,.28)" |
| .site-form button | transition | "transform .2s ease, box-shadow .2s ease, filter .2s ease" |
| .site-form button:hover | filter | brightness(1.06) |
| .site-form button:hover | transform | "translateY(-1px)" |
| .site-form button:hover | box-shadow | "0 12px 36px rgba(212,175,55,.4)" |
| .site-form .actions a | color | var(--paper-faint) |
| .site-form .actions a | font-weight | "400" |
| .site-form .actions a | text-decoration | none |
| .site-form .actions a | font-size | "0.85rem" |
| .site-form .actions a | letter-spacing | "0.08em" |
| .site-form .actions a:hover | color | var(--gold) |
| .flash.err | color | var(--danger) |
| .flash.err | font-weight | "500" |
*`widgets`*
## css
**v = > vars**
**m = > motion**
**l = > layout**
**r = > responsive**
**c = > chrome**
**w = > widgets**
**css_v = > web.make_style name="vars" table=v**
**css_m = > web.make_style name="motion" table=m**
**css_l = > web.make_style name="layout" table=l**
**css_r = > web.make_style name="responsive" table=r**
**css_c = > web.make_style name="chrome" table=c**
**css_w = > web.make_style name="widgets" table=w**
`parts` =
| css |
|-----|
| `css_v` |
| `css_m` |
| `css_l` |
| `css_r` |
| `css_c` |
| `css_w` |
**out = > text.str_join xs=`parts` sep=""**
*out*
+1
View File
@@ -0,0 +1 @@
1.0.3
+27
View File
@@ -38,6 +38,18 @@ them into CSS — 样式即数据、装配即函数.
> ensure_plugin
*> web_style name=`name` table=`table` strict=`strict`*
## make_intro
+ `table`
Assemble an intro bind table (`|属性|值|样式|` / `|front|back|style|`) into an
HTML fragment for `.main-intro`. Same slot vocabulary as `compose_intro`
(`kicker`/`title`/`lede`/`claim`/`step`, plus ZH aliases). The `样式` column is
treated as a class name only here — prefer `page.compose_intro` when styles
should resolve from `shell.*` tables into `styles_css`.
> ensure_plugin
*> web_intro table=`table`*
## make_images
+ `table`
@@ -230,6 +242,21 @@ Assemble main from a bind table (`|属性|值|样式|` or `|front|back|css|`).
*> web_compose_main page=`self` main=`main`*
## compose_intro
+ `intro`
Assemble page intro from the same bind shape as `compose_main`
(`|属性|值|样式|` / `|front|back|style|`). `值` is literal copy (light
`[label](url)` / `**bold**`); `样式` resolves `shell.*` named
tables into `styles_css` like `card_title`. Consecutive `claim` / `step` rows
group into `.claim` / `.steps`. Slot aliases: `kicker`/`眉题`, `title`/`标题`,
`lede`/`导语`, `claim`/`标签`, `step`/`步骤`, plus `mount`/`插槽` and
`html`/`原文`. Replaces string `intro=` HTML. In `.mq.md` table cells, avoid
inline `` `code` `` — backtick refs are Marqdo variables; quote long prose
and use plain filenames or `[label](url)` links instead.
*> web_compose_intro page=`self` intro=`intro`*
## query
+ `query`
+23
View File
@@ -35,6 +35,16 @@ import table:lib/table.mq.md
> 确保插件
*> web_style name=`名` table=`表` strict=`严格`*
## 引言装配
+ `表`
把引言绑定表(`|属性|值|样式|` / `|front|back|style|`)装配成 `.main-intro` HTML 片段。
槽位与 `页面.引言装配` 相同。此处 `样式` 只当 class 名;要从 `shell.*` 解析进
`styles_css` 请用 `页面.引言装配`。
> 确保插件
*> web_intro table=`表`*
## 图片装配
+ `表`
@@ -217,6 +227,19 @@ import table:lib/table.mq.md
*> web_compose_main page=`self` main=`主体`*
## 引言装配
+ `引言`
与 `主体装配` 同一绑定表形(`|属性|值|样式|`)。`值` 为文案(支持轻量
`[文](url)` / `**粗**`);`样式` 解析 `shell.*` 具名表写入
`styles_css`(同 `card_title`)。连续 `claim`/`标签`、`step`/`步骤` 会分组。
槽位别名:`kicker`/`眉题`、`title`/`标题`、`lede`/`导语`、`claim`/`标签`、
`step`/`步骤`,以及 `mount`/`插槽`、`html`/`原文`。用于替代字符串 `引言=` HTML。
在 `.mq.md` 表单元格里请勿写行内 `` `code` ``(反引号是 Marqdo 变量语法);
长文加引号,文件名用纯文本或 `[文](url)`。
*> web_compose_intro page=`self` intro=`引言`*
## 查询条件
+ `条件`
+27 -15
View File
@@ -462,18 +462,8 @@ fn select_page_data(
offset: i64,
) -> Value {
let mut where_v = args.get("query").cloned();
if let Some(m) = where_v.as_ref().and_then(|v| v.as_object()) {
if m.iter().any(|(_, v)| v.as_str().is_some_and(|s| s.contains('{'))) {
let mut resolved = Map::new();
for (k, v) in m {
let v = match v {
Value::String(s) => Value::String(resolve_params(s.as_str(), args)),
other => other.clone(),
};
resolved.insert(k.clone(), v);
}
where_v = Some(Value::Object(resolved));
}
if let Some(v) = where_v.take() {
where_v = Some(resolve_placeholders(v, args));
}
let order = args.get("order").and_then(|v| v.as_str());
let paginate = args.get("paginate").is_some();
@@ -493,6 +483,26 @@ fn select_page_data(
.unwrap_or(json!({ "rows": [] }))
}
/// Recursively replace `{param}` in all string leaves (columnar / row tables).
fn resolve_placeholders(v: Value, args: &Value) -> Value {
match v {
Value::String(s) => Value::String(resolve_params(&s, args)),
Value::Array(arr) => Value::Array(
arr.into_iter()
.map(|x| resolve_placeholders(x, args))
.collect(),
),
Value::Object(map) => {
let mut out = Map::new();
for (k, val) in map {
out.insert(k, resolve_placeholders(val, args));
}
Value::Object(out)
}
other => other,
}
}
/// Replace `{param}` placeholders with values from `args["params"]` (a map).
fn resolve_params(s: &str, args: &Value) -> String {
let params = args
@@ -532,8 +542,11 @@ fn field_css(obj: &Map<String, Value>, field: &str) -> String {
}
fn part_src_prefix(args: &Value) -> String {
match args.get("_route").and_then(|v| v.as_str()) {
Some(r) if !r.is_empty() && r != "/" => {
let raw = args.get("_route").and_then(|v| v.as_str()).unwrap_or("");
let resolved = resolve_params(raw, args);
match resolved.as_str() {
"" | "/" => String::new(),
r => {
let mut p = r.to_string();
while p.len() > 1 && p.ends_with('/') {
p.pop();
@@ -544,7 +557,6 @@ fn part_src_prefix(args: &Value) -> String {
format!("/{p}")
}
}
_ => String::new(),
}
}
+2 -3
View File
@@ -475,10 +475,9 @@ pub fn as_css_named_checked(name: &str, table: &Value, strict: bool) -> Result<S
}
fn css_value_suspicious(v: &Value) -> Option<&'static str> {
// Numbers are normal CSS (z-index, opacity, …). Do not treat Markup-evaluated
// ints/floats as bare `/` division false positives.
match v {
Value::Number(_) => Some(
"numeric CSS value (likely bare `/` division such as `1 / 5`; quote the cell, e.g. `\"1 / 5\"`)",
),
Value::Bool(_) => Some("boolean CSS value (quote the cell if intentional)"),
_ => None,
}
+1
View File
@@ -18,6 +18,7 @@ require (
github.com/mattn/go-isatty v0.0.24 // indirect
github.com/ncruces/go-strftime v1.0.0 // indirect
github.com/remyoudompheng/bigfft v0.0.0-20230129092748-24d4a6f8daec // indirect
github.com/yuin/goldmark v1.7.8 // indirect
github.com/yuin/gopher-lua v1.1.1 // indirect
go.uber.org/atomic v1.11.0 // indirect
golang.org/x/sys v0.47.0 // indirect
+2
View File
@@ -34,6 +34,8 @@ github.com/remyoudompheng/bigfft v0.0.0-20230129092748-24d4a6f8daec h1:W09IVJc94
github.com/remyoudompheng/bigfft v0.0.0-20230129092748-24d4a6f8daec/go.mod h1:qqbHyh8v60DhA7CoWK5oRCqLrMHRGoxYCSS9EjAz6Eo=
github.com/stretchr/testify v1.3.0 h1:TivCn/peBQ7UY8ooIcPgZFpTNSz0Q2U6UrFlUfqbe0Q=
github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI=
github.com/yuin/goldmark v1.7.8 h1:iERMLn0/QJeHFhxSt3p6PeN9mGnvIKSpG9YYorDMnic=
github.com/yuin/goldmark v1.7.8/go.mod h1:uzxRWxtg69N339t3louHJ7+O03ezfj6PlliRlaOzY1E=
github.com/yuin/gopher-lua v1.1.1 h1:kYKnWBjvbNP4XLT3+bPEwAXJx262OhaHDWDVOPjL46M=
github.com/yuin/gopher-lua v1.1.1/go.mod h1:GBR0iDaNXjAgGg9zfCvksxSRnQx76gclCIb7kdAd1Pw=
github.com/zeebo/xxh3 v1.1.0 h1:s7DLGDK45Dyfg7++yxI0khrfwq9661w9EN78eP/UZVs=
@@ -0,0 +1,437 @@
package compose
import (
"fmt"
"html"
"strings"
"github.com/marqdo/marqdo/plugins/web/internal/table"
)
// ComposeIntro binds an intro table (|属性|值|样式| / |front|back|style|) onto the
// page — same shape as ComposeMain. Literals go in 值/back; 样式 resolves like
// card_title into styles_css + element class names. Sets page.intro HTML.
//
// Unlike AsBind, the 值/back column is not NormalizeRef'd so inline `code`
// markers survive for richText.
func ComposeIntro(page any, introTable any, callLib CallLib) (any, error) {
obj := asObject(page)
arr := asIntroRows(introTable)
css := strField(obj, "styles_css")
seenStyle := map[string]bool{}
binds := make([]map[string]any, 0, len(arr))
for _, bm := range arr {
front := table.NormalizeRef(strField(bm, "front"))
backRaw := strings.TrimSpace(strField(bm, "back"))
cssRaw := table.NormalizeRef(strField(bm, "css"))
back := backRaw
switch sp := table.ParseSitePath(backRaw); sp.Kind {
case table.SitePathLibMember:
// Intro copy is almost always prose; only resolve clear lib.member refs
// that look like style/module paths (no spaces).
if !strings.ContainsAny(backRaw, " \t\n") {
v, err := callLib(sp.Lib + "." + sp.Member)
if err != nil {
back = sp.Lib + "." + sp.Member
} else if s, ok := v.(string); ok {
back = s
} else {
back = fmt.Sprint(v)
}
}
}
cssName := ""
if cssRaw != "" {
switch sp := table.ParseSitePath(cssRaw); sp.Kind {
case table.SitePathLibMember:
cssName = sp.Member
if !seenStyle[cssName] {
st, err := callLib(sp.Lib + "." + sp.Member)
if err != nil {
return nil, err
}
css += table.AsCSSNamed(sp.Member, st)
seenStyle[cssName] = true
}
case table.SitePathPlain:
cssName = sp.Plain
case table.SitePathDbField:
cssName = table.NormalizeRef(cssRaw)
}
}
if front == "" && back == "" {
continue
}
binds = append(binds, map[string]any{
"front": front,
"back": back,
"css": cssName,
})
}
obj["intro"] = RenderIntroHTML(binds)
obj["intro_bind"] = binds
if css != "" {
obj["styles_css"] = css
}
return obj, nil
}
// MakeIntroHTML builds intro HTML from a bind table without resolving lib styles
// (css column used as class name as-is). Preserves backticks in 值/back.
func MakeIntroHTML(introTable any) string {
arr := asIntroRows(introTable)
binds := make([]map[string]any, 0, len(arr))
for _, bm := range arr {
front := table.NormalizeRef(strField(bm, "front"))
back := strings.TrimSpace(strField(bm, "back"))
cssName := table.NormalizeRef(strField(bm, "css"))
if front == "" && back == "" {
continue
}
binds = append(binds, map[string]any{
"front": front,
"back": back,
"css": cssName,
})
}
return RenderIntroHTML(binds)
}
func asIntroRows(v any) []map[string]any {
switch t := v.(type) {
case []any:
out := make([]map[string]any, 0, len(t))
for _, row := range t {
m, ok := row.(map[string]any)
if !ok {
continue
}
front, back, css := "", "", ""
if x, ok := pickIntro(m, []string{"属性", "前端变量", "front", "field"}); ok {
front = cellIntro(x)
}
if x, ok := pickIntro(m, []string{"值", "后端数据库", "back", "db", "text", "文"}); ok {
back = cellIntro(x)
}
if x, ok := pickIntro(m, []string{"样式", "绑定css样式", "css", "class", "style"}); ok {
css = cellIntro(x)
}
if front != "" || back != "" {
out = append(out, map[string]any{"front": front, "back": back, "css": css})
}
}
return out
case map[string]any:
// Column-oriented map of lists (GFM multi-row table).
fronts, backs, csses := []string{}, []string{}, []string{}
if x, ok := pickIntro(t, []string{"属性", "前端变量", "front", "field"}); ok {
fronts = asIntroStrList(x)
}
if x, ok := pickIntro(t, []string{"值", "后端数据库", "back", "db", "text", "文"}); ok {
backs = asIntroStrList(x)
}
if x, ok := pickIntro(t, []string{"样式", "绑定css样式", "css", "class", "style"}); ok {
csses = asIntroStrList(x)
}
n := len(fronts)
if len(backs) > n {
n = len(backs)
}
out := make([]map[string]any, 0, n)
for i := 0; i < n; i++ {
front, back, css := "", "", ""
if i < len(fronts) {
front = fronts[i]
}
if i < len(backs) {
back = backs[i]
}
if i < len(csses) {
css = csses[i]
}
if front != "" || back != "" {
out = append(out, map[string]any{"front": front, "back": back, "css": css})
}
}
return out
default:
return nil
}
}
func asIntroStrList(v any) []string {
switch t := v.(type) {
case []any:
out := make([]string, 0, len(t))
for _, x := range t {
out = append(out, cellIntro(x))
}
return out
case []string:
return t
default:
s := cellIntro(v)
if s == "" {
return nil
}
return []string{s}
}
}
func pickIntro(m map[string]any, keys []string) (any, bool) {
for _, k := range keys {
if v, ok := m[k]; ok {
return v, true
}
}
return nil, false
}
func cellIntro(v any) string {
switch t := v.(type) {
case nil:
return ""
case string:
return t
case bool:
if t {
return "true"
}
return "false"
case float64:
if t == float64(int64(t)) {
return fmt.Sprintf("%d", int64(t))
}
return fmt.Sprintf("%v", t)
default:
return fmt.Sprint(t)
}
}
// RenderIntroHTML turns normalized intro binds into .main-intro inner HTML.
func RenderIntroHTML(binds []map[string]any) string {
if len(binds) == 0 {
return ""
}
var out strings.Builder
i := 0
for i < len(binds) {
front := strings.TrimSpace(strField(binds[i], "front"))
kind := introKind(front)
switch kind {
case "claim":
j := i
for j < len(binds) && introKind(strField(binds[j], "front")) == "claim" {
j++
}
out.WriteString(`<p class="claim">`)
for _, row := range binds[i:j] {
cls := classAttr(strField(row, "css"))
out.WriteString(fmt.Sprintf("<span%s>%s</span>", cls, richText(strField(row, "back"))))
}
out.WriteString(`</p>`)
i = j
case "step":
j := i
for j < len(binds) && introKind(strField(binds[j], "front")) == "step" {
j++
}
out.WriteString(`<ol class="steps">`)
for _, row := range binds[i:j] {
cls := classAttr(strField(row, "css"))
out.WriteString(fmt.Sprintf("<li%s>%s</li>", cls, richText(strField(row, "back"))))
}
out.WriteString(`</ol>`)
i = j
case "mount":
id := strField(binds[i], "back")
if id == "" {
id = front
}
id = strings.TrimPrefix(id, "#")
out.WriteString(fmt.Sprintf(`<div id="%s"></div>`, html.EscapeString(id)))
i++
case "html":
out.WriteString(strField(binds[i], "back"))
i++
default:
tag, baseClass := introTagClass(kind, front)
cssName := strField(binds[i], "css")
cls := mergeClass(baseClass, cssName)
out.WriteString(fmt.Sprintf("<%s%s>%s</%s>", tag, classAttr(cls), richText(strField(binds[i], "back")), tag))
i++
}
}
return out.String()
}
func introKind(front string) string {
s := strings.ToLower(strings.TrimSpace(front))
switch s {
case "kicker", "eyebrow", "眉题":
return "kicker"
case "title", "h1", "标题":
return "title"
case "lede", "lead", "导语":
return "lede"
case "claim", "badge", "标签":
return "claim"
case "step", "步骤":
return "step"
case "h2", "小标题":
return "h2"
case "p", "段落":
return "p"
case "mount", "插槽", "slot":
return "mount"
case "html", "原文", "raw":
return "html"
default:
return s
}
}
func introTagClass(kind, front string) (tag, baseClass string) {
switch kind {
case "kicker":
return "p", "kicker"
case "title":
return "h1", ""
case "lede":
return "p", "lede"
case "h2":
return "h2", ""
case "p":
return "p", ""
default:
if front != "" {
return "p", front
}
return "p", ""
}
}
func mergeClass(base, style string) string {
base = strings.TrimSpace(base)
style = strings.TrimSpace(style)
switch {
case base == "":
return style
case style == "" || style == base:
return base
default:
return base + " " + style
}
}
func classAttr(class string) string {
class = strings.TrimSpace(class)
if class == "" {
return ""
}
return ` class="` + html.EscapeString(class) + `"`
}
// richText escapes text then applies a tiny Markdown subset: [label](url), `code`, **bold**.
func richText(s string) string {
if s == "" {
return ""
}
type span struct {
kind string // text|a|code|strong
a string
b string
}
var spans []span
rest := s
for len(rest) > 0 {
// find earliest special
iLink := strings.Index(rest, "[")
iCode := strings.Index(rest, "`")
iBold := strings.Index(rest, "**")
next := -1
which := ""
if iLink >= 0 && (next < 0 || iLink < next) {
next, which = iLink, "a"
}
if iCode >= 0 && (next < 0 || iCode < next) {
next, which = iCode, "code"
}
if iBold >= 0 && (next < 0 || iBold < next) {
next, which = iBold, "strong"
}
if next < 0 {
spans = append(spans, span{kind: "text", a: rest})
break
}
if next > 0 {
spans = append(spans, span{kind: "text", a: rest[:next]})
}
rest = rest[next:]
switch which {
case "a":
// [label](url)
endLabel := strings.Index(rest, "](")
if endLabel < 0 {
spans = append(spans, span{kind: "text", a: rest[:1]})
rest = rest[1:]
continue
}
endURL := strings.Index(rest[endLabel+2:], ")")
if endURL < 0 {
spans = append(spans, span{kind: "text", a: rest[:1]})
rest = rest[1:]
continue
}
label := rest[1:endLabel]
url := rest[endLabel+2 : endLabel+2+endURL]
spans = append(spans, span{kind: "a", a: label, b: url})
rest = rest[endLabel+2+endURL+1:]
case "code":
end := strings.Index(rest[1:], "`")
if end < 0 {
spans = append(spans, span{kind: "text", a: rest[:1]})
rest = rest[1:]
continue
}
spans = append(spans, span{kind: "code", a: rest[1 : 1+end]})
rest = rest[1+end+1:]
case "strong":
end := strings.Index(rest[2:], "**")
if end < 0 {
spans = append(spans, span{kind: "text", a: rest[:2]})
rest = rest[2:]
continue
}
spans = append(spans, span{kind: "strong", a: rest[2 : 2+end]})
rest = rest[2+end+2:]
}
}
var out strings.Builder
for _, sp := range spans {
switch sp.kind {
case "a":
out.WriteString(`<a href="`)
out.WriteString(html.EscapeString(sp.b))
out.WriteString(`">`)
out.WriteString(html.EscapeString(sp.a))
out.WriteString(`</a>`)
case "code":
out.WriteString(`<code>`)
out.WriteString(html.EscapeString(sp.a))
out.WriteString(`</code>`)
case "strong":
out.WriteString(`<strong>`)
out.WriteString(html.EscapeString(sp.a))
out.WriteString(`</strong>`)
default:
out.WriteString(html.EscapeString(sp.a))
}
}
return out.String()
}
@@ -1,11 +1,80 @@
package compose_test
import (
"strings"
"testing"
"github.com/marqdo/marqdo/plugins/web/internal/compose"
)
func TestComposeIntroBindAndRichText(t *testing.T) {
page := map[string]any{"title": "Home"}
intro := []any{
map[string]any{"属性": "kicker", "值": "WWW Demo", "样式": "shell.kicker"},
map[string]any{"属性": "title", "值": "Marqdo", "样式": "shell.intro_title"},
map[string]any{"属性": "lede", "值": "Zero author `JS`.", "样式": "shell.lede"},
map[string]any{"属性": "claim", "值": "0 JS", "样式": "shell.claim"},
map[string]any{"属性": "claim", "值": "GFM", "样式": "shell.claim"},
map[string]any{"属性": "step", "值": "Open [New](/new) now.", "样式": "shell.step"},
map[string]any{"属性": "step", "值": "Compare source.", "样式": "shell.step"},
}
callLib := func(path string) (any, error) {
switch path {
case "shell.kicker", "shell.intro_title", "shell.lede", "shell.claim", "shell.step":
return map[string]any{
"property": []any{"color"},
"value": []any{"red"},
}, nil
default:
t.Fatalf("unexpected callLib %q", path)
return nil, nil
}
}
out, err := compose.ComposeIntro(page, intro, callLib)
if err != nil {
t.Fatal(err)
}
obj := out.(map[string]any)
html, _ := obj["intro"].(string)
for _, want := range []string{
`class="kicker"`,
`<h1 class="intro_title">Marqdo</h1>`,
`<code>JS</code>`,
`<p class="claim">`,
`<span class="claim">0 JS</span>`,
`<ol class="steps">`,
`<a href="/new">New</a>`,
} {
if !strings.Contains(html, want) {
t.Fatalf("missing %q in html=%q", want, html)
}
}
css, _ := obj["styles_css"].(string)
if !strings.Contains(css, ".kicker") || !strings.Contains(css, ".intro_title") {
t.Fatalf("styles_css incomplete: %q", css)
}
}
func TestMakeIntroHTMLZHAliases(t *testing.T) {
tbl := []any{
map[string]any{"属性": "眉题", "值": "演示", "样式": "kicker"},
map[string]any{"属性": "标题", "值": "站名", "样式": "intro_title"},
map[string]any{"属性": "标签", "值": "A", "样式": "claim"},
map[string]any{"属性": "步骤", "值": "第一步", "样式": "step"},
}
html := compose.MakeIntroHTML(tbl)
for _, want := range []string{
`class="kicker"`,
`<h1 class="intro_title">站名</h1>`,
`<p class="claim">`,
`<ol class="steps">`,
} {
if !strings.Contains(html, want) {
t.Fatalf("missing %q in %q", want, html)
}
}
}
func TestComposeComponentsFakeCallLib(t *testing.T) {
page := map[string]any{
"title": "Home",
+24 -16
View File
@@ -314,9 +314,10 @@ func (st *state) mountAuthRoutes(mux *http.ServeMux) {
mux.HandleFunc("GET "+altLogin, st.handleLoginGet)
mux.HandleFunc("POST "+altLogin, st.handleLoginPost)
}
// Logout is part of session auth, not only built-in admin=True chrome.
logoutPath := strings.TrimRight(st.auth.adminPrefix, "/") + "/logout"
mux.HandleFunc("GET "+logoutPath, st.handleLogout)
if st.auth.admin {
logoutPath := strings.TrimRight(st.auth.adminPrefix, "/") + "/logout"
mux.HandleFunc("GET "+logoutPath, st.handleLogout)
adminHome := strings.TrimRight(st.auth.adminPrefix, "/")
if adminHome == "" {
adminHome = "/admin"
@@ -427,29 +428,34 @@ func loginPageHTML(loginAction string, errMsg *string, csrf string, next string)
nextField = fmt.Sprintf("<input type=\"hidden\" name=\"next\" value=\"%s\"/>", esc(next))
}
return fmt.Sprintf(`<!DOCTYPE html>
<html lang="zh-CN"><head>
<html lang="en"><head>
<meta charset="utf-8"/>
<meta name="viewport" content="width=device-width, initial-scale=1"/>
<title>Admin Login</title>
<style>
:root { --ink:#1c1917; --muted:#78716c; --paper:#fafaf9; --line:#e7e5e4; --accent:#0f766e; --err:#b91c1c; }
:root { --ink:#0a0809; --paper:#f5e6c8; --gold:#d4af37; --wine:#6b1e3a; --err:#b91c1c; }
* { box-sizing:border-box; }
body { margin:0; min-height:100vh; display:grid; place-items:center; background:var(--paper); color:var(--ink); font-family:"IBM Plex Sans","Noto Sans SC",sans-serif; }
.login { background:rgba(255,255,255,.45); border:1px solid rgba(255,255,255,.5); border-radius:14px; padding:2rem 2.25rem; width:min(92vw,22rem); box-shadow:0 8px 24px rgba(253,189,219,.18); backdrop-filter:blur(14px); }
.login h1 { margin:0 0 .25rem; font-size:1.4rem; color:#a85878; }
.login .sub { color:#666; margin:0 0 1.25rem; font-size:.9rem; }
body { margin:0; min-height:100vh; display:grid; place-items:center; color:var(--paper); font-family:"Noto Sans SC","IBM Plex Sans",system-ui,sans-serif;
background: radial-gradient(ellipse 90%% 55%% at 50%% -15%%, rgba(107,30,58,.5), transparent 58%%), linear-gradient(180deg,#0a0809,#120c10 45%%,#0a0809); }
.login { background:rgba(0,0,0,.45); border:1px solid rgba(212,175,55,.28); border-radius:12px; padding:2rem 2.25rem; width:min(92vw,22rem); box-shadow:0 24px 80px rgba(0,0,0,.55); backdrop-filter:blur(14px); }
.login h1 { margin:0 0 .25rem; font-size:1.55rem; color:var(--gold); letter-spacing:.04em; }
.login .sub { color:rgba(245,230,200,.72); margin:0 0 1.25rem; font-size:.9rem; line-height:1.55; }
.login .hint { color:rgba(245,230,200,.5); margin:1rem 0 0; font-size:.78rem; letter-spacing:.04em; }
.login form { display:grid; gap:.9rem; }
.login label { display:grid; gap:.25rem; font-size:.9rem; }
.login input { padding:.55rem .65rem; border:1px solid rgba(253,189,219,.55); border-radius:999px; font:inherit; background:rgba(255,255,255,.7); }
.login button { background:linear-gradient(120deg,#f0a8c4,#fdbbdb); color:#a85878; border:0; padding:.6rem 1rem; border-radius:999px; cursor:pointer; font:inherit; font-weight:600; }
.login button:hover { filter:brightness(1.05); }
.flash.err { background:#fef2f2; color:#b91c1c; border:1px solid #fecaca; padding:.6rem .8rem; border-radius:6px; margin:0 0 .9rem; font-size:.9rem; }
.login label { display:grid; gap:.25rem; font-size:.85rem; letter-spacing:.08em; }
.login input { padding:.6rem .75rem; border:1px solid rgba(212,175,55,.35); border-radius:8px; font:inherit; color:var(--paper); background:rgba(10,8,9,.7); }
.login input:focus { outline:none; border-color:var(--gold); box-shadow:0 0 0 2px rgba(212,175,55,.25); }
.login button { background:linear-gradient(135deg,#f5e6c8,var(--gold)); color:var(--ink); border:0; padding:.65rem 1rem; border-radius:999px; cursor:pointer; font:inherit; font-weight:600; letter-spacing:.1em; }
.login button:hover { filter:brightness(1.06); }
.flash.err { background:rgba(185,28,28,.15); color:#fecaca; border:1px solid rgba(185,28,28,.45); padding:.6rem .8rem; border-radius:8px; margin:0 0 .9rem; font-size:.9rem; }
a.back { color:var(--gold); text-decoration:none; font-size:.85rem; }
a.back:hover { color:#f5e6c8; }
</style>
</head>
<body style="background:#f8f9fa url('/static/img/bg-body-960.webp') center/cover fixed;">
<body>
<div class="login">
<h1>暗恋见君</h1>
<p class="sub">登录后发帖与管理。</p>
<h1>Marqdo Admin</h1>
<p class="sub">Sign in to open the table-declared desk.</p>
%s
<form method="post" action="%s">
%s%s
@@ -457,6 +463,8 @@ body { margin:0; min-height:100vh; display:grid; place-items:center; background:
<label>Password<input name="password" type="password" autocomplete="current-password" required/></label>
<button type="submit">Sign in</button>
</form>
<p class="hint">Demo · admin / demo</p>
<p style="margin:1.1rem 0 0"><a class="back" href="/">← Site</a></p>
</div>
</body></html>`, errHTML, esc(loginAction), csrfField, nextField)
}
+35 -9
View File
@@ -136,19 +136,17 @@ func NewHandler(appBag map[string]any, entryDir string) (http.Handler, error) {
})
}
if staticDir != "" {
fmt.Fprintf(os.Stderr, "marqdo web static: %s → %s\n", staticMount, staticDir)
fs := http.StripPrefix(staticMount, http.FileServer(http.Dir(staticDir)))
mux.Handle("GET "+staticMount+"/", fs)
mux.Handle("HEAD "+staticMount+"/", fs)
mux.Handle("GET "+staticMount, fs)
mux.Handle("HEAD "+staticMount, fs)
}
// Icon routes before the static prefix so /static/favicon.svg does not
// conflict with Go 1.22+ ServeMux method/path overlap rules.
for _, ir := range iconRoutes {
url := ir.URL
path := ir.Path
ct := ir.ContentType
if staticDir != "" && (url == staticMount || strings.HasPrefix(url, staticMount+"/")) {
// FileServer under staticMount already serves these paths.
fmt.Fprintf(os.Stderr, "marqdo web icon: %s → static %s (via %s)\n", url, path, staticMount)
continue
}
fmt.Fprintf(os.Stderr, "marqdo web icon: %s → %s (%s)\n", url, path, ct)
mux.HandleFunc("GET "+url, func(w http.ResponseWriter, r *http.Request) {
st.serveIcon(w, path, ct)
@@ -158,6 +156,27 @@ func NewHandler(appBag map[string]any, entryDir string) (http.Handler, error) {
})
}
if staticDir != "" {
fmt.Fprintf(os.Stderr, "marqdo web static: %s → %s\n", staticMount, staticDir)
fs := http.StripPrefix(staticMount, http.FileServer(http.Dir(staticDir)))
// Register without method so GET+HEAD share one pattern (avoids conflicts
// with more-specific GET/HEAD icon paths under the same prefix).
mux.Handle(staticMount+"/", http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
if r.Method != http.MethodGet && r.Method != http.MethodHead {
http.Error(w, "method not allowed", http.StatusMethodNotAllowed)
return
}
fs.ServeHTTP(w, r)
}))
mux.Handle(staticMount, http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
if r.Method != http.MethodGet && r.Method != http.MethodHead {
http.Error(w, "method not allowed", http.StatusMethodNotAllowed)
return
}
fs.ServeHTTP(w, r)
}))
}
for _, from := range sortedKeys(st.redirects) {
spec, _ := st.redirects[from].(map[string]any)
to := strOpt(spec, "to", "/")
@@ -625,11 +644,18 @@ func collectPageForms(page map[string]any, forms map[string]any) {
func injectParams(page map[string]any, params map[string]any) {
page["params"] = params
// Stamp concrete path onto `_route` so part slot URLs use /post/slug not /post/{slug}.
if r, ok := page["_route"].(string); ok && r != "" && len(params) > 0 {
page["_route"] = render.ResolveRouteParams(r, params)
}
if parts, ok := page["parts"].(map[string]any); ok {
for k, cfg := range parts {
if m, ok := cfg.(map[string]any); ok {
cp := cloneMap(m)
cp["params"] = params
if r, ok := cp["_route"].(string); ok && r != "" {
cp["_route"] = render.ResolveRouteParams(r, params)
}
parts[k] = cp
}
}
+38
View File
@@ -0,0 +1,38 @@
package render
import (
"bytes"
"strings"
"github.com/yuin/goldmark"
"github.com/yuin/goldmark/extension"
"github.com/yuin/goldmark/parser"
"github.com/yuin/goldmark/renderer/html"
)
// markdownToHTML renders article body Markdown to HTML (GFM subset), matching
// the Rust web plugin's pulldown-cmark path.
func markdownToHTML(md string) string {
md = strings.TrimSpace(md)
if md == "" {
return ""
}
gm := goldmark.New(
goldmark.WithExtensions(
extension.GFM,
extension.Strikethrough,
),
goldmark.WithParserOptions(
parser.WithAutoHeadingID(),
),
goldmark.WithRendererOptions(
html.WithHardWraps(),
html.WithXHTML(),
),
)
var buf bytes.Buffer
if err := gm.Convert([]byte(md), &buf); err != nil {
return `<div class="article-body"><p class="article-p">` + esc(md) + `</p></div>`
}
return `<div class="article-body md">` + buf.String() + `</div>`
}
+80 -3
View File
@@ -191,7 +191,8 @@ func navWhenVisible(when navWhen, auth *bool) bool {
func selectPageData(url, tableName string, page map[string]any, limit, offset int64) map[string]any {
var where any
if q, ok := page["query"]; ok {
where = q
// Expand `{param}` placeholders from dynamic route params (ABI: 查询条件).
where = resolvePlaceholders(q, pageParams(page))
}
order, _ := page["order"].(string)
opts := db.SelectOpts{Where: where, Order: order}
@@ -205,6 +206,78 @@ func selectPageData(url, tableName string, page map[string]any, limit, offset in
return out
}
func pageParams(page map[string]any) map[string]any {
if page == nil {
return nil
}
p, _ := page["params"].(map[string]any)
return p
}
// resolvePlaceholders walks query / route values and replaces `{name}` with
// page.params[name]. Unmatched placeholders are left as `{name}` for debugging.
func resolvePlaceholders(v any, params map[string]any) any {
if len(params) == 0 {
return v
}
switch t := v.(type) {
case string:
return resolveParamsString(t, params)
case map[string]any:
out := make(map[string]any, len(t))
for k, val := range t {
out[k] = resolvePlaceholders(val, params)
}
return out
case []any:
out := make([]any, len(t))
for i, val := range t {
out[i] = resolvePlaceholders(val, params)
}
return out
default:
return v
}
}
// ResolveRouteParams substitutes `{name}` in a route pattern using params.
func ResolveRouteParams(pattern string, params map[string]any) string {
return resolveParamsString(pattern, params)
}
func resolveParamsString(s string, params map[string]any) string {
if !strings.Contains(s, "{") || len(params) == 0 {
return s
}
var out strings.Builder
rest := s
for {
start := strings.Index(rest, "{")
if start < 0 {
out.WriteString(rest)
break
}
out.WriteString(rest[:start])
rest = rest[start+1:]
end := strings.Index(rest, "}")
if end < 0 {
out.WriteByte('{')
out.WriteString(rest)
break
}
key := rest[:end]
if val, ok := params[key]; ok {
out.WriteString(text(val))
} else {
out.WriteByte('{')
out.WriteString(key)
out.WriteByte('}')
}
rest = rest[end+1:]
}
return out.String()
}
func resolveLinks(raw any, dbURL string, page map[string]any) []navLink {
if raw == nil {
return nil
@@ -400,6 +473,7 @@ func fieldCSS(obj map[string]any, field string) string {
func partSrcPrefix(page map[string]any) string {
r, _ := page["_route"].(string)
r = resolveParamsString(r, pageParams(page))
if r == "" || r == "/" {
return ""
}
@@ -479,6 +553,10 @@ const shellWidgets = `
.site-form { margin-top:1.25rem; max-width:28rem; }
.article { background:#fff; border:1px solid var(--line); border-radius:8px; padding:2rem; margin-top:1.5rem; }
.article-title { margin:0 0 .75rem; font-size:2rem; }
.article-body { line-height:1.75; color:var(--ink); }
.article-body.md { line-height: 1.75; }
.article-body.md pre { background:#f5f5f4; border:1px solid var(--line); border-radius:6px; padding:1rem; overflow-x:auto; }
.article-body.md code { font-size:.9em; }
.pagination { display:flex; gap:1rem; align-items:center; margin:1.5rem 0; font-size:.95rem; }
`
@@ -624,8 +702,7 @@ func renderArticle(it map[string]any) string {
s.WriteString(fmt.Sprintf(`<div class="article-tags">%s</div>`, esc(tag)))
}
if body != "" {
// Minimal: escape as paragraphs (full markdown deferred).
s.WriteString(fmt.Sprintf(`<div class="article-body"><p class="article-p">%s</p></div>`, esc(body)))
s.WriteString(markdownToHTML(body))
}
s.WriteString("</article>")
return s.String()
@@ -227,3 +227,33 @@ func TestRenderPageNavChrome(t *testing.T) {
}
}
}
func TestResolveRouteParams(t *testing.T) {
got := render.ResolveRouteParams("/post/{slug}", map[string]any{"slug": "hello-marqdo"})
if got != "/post/hello-marqdo" {
t.Fatalf("got %q", got)
}
got = render.ResolveRouteParams("/post/{slug}", map[string]any{})
if got != "/post/{slug}" {
t.Fatalf("unmatched must stay: %q", got)
}
}
func TestPartSlotSrcUsesResolvedRoute(t *testing.T) {
page := map[string]any{
"title": "post",
"intro": "",
"_route": "/post/{slug}",
"params": map[string]any{"slug": "hello-marqdo"},
"parts": map[string]any{
"index": map[string]any{"slot": "main"},
},
}
html := render.RenderPage(page, "", "")
if strings.Contains(html, "/post/{slug}/_part/") {
t.Fatalf("slot src still has placeholder: %s", html)
}
if !strings.Contains(html, `data-slot-src="/post/hello-marqdo/_part/index"`) {
t.Fatalf("missing resolved slot src: %s", html)
}
}
@@ -0,0 +1,105 @@
package render
import (
"path/filepath"
"strings"
"testing"
"github.com/marqdo/marqdo/plugins/web/internal/db"
)
func TestResolvePlaceholdersColumnarAndRows(t *testing.T) {
params := map[string]any{"slug": "hello-marqdo"}
col := map[string]any{
"字段": []any{"slug"},
"操作": []any{"="},
"值": []any{"{slug}"},
}
got := resolvePlaceholders(col, params).(map[string]any)
vals := got["值"].([]any)
if vals[0] != "hello-marqdo" {
t.Fatalf("columnar 值=%v", vals)
}
rows := []any{
map[string]any{"字段": "slug", "操作": "=", "值": "{slug}"},
}
gotRows := resolvePlaceholders(rows, params).([]any)
m := gotRows[0].(map[string]any)
if m["值"] != "hello-marqdo" {
t.Fatalf("row 值=%v", m["值"])
}
top := map[string]any{"slug": "{slug}"}
gotTop := resolvePlaceholders(top, params).(map[string]any)
if gotTop["slug"] != "hello-marqdo" {
t.Fatalf("map string=%v", gotTop["slug"])
}
}
func TestSelectPageDataResolvesSlug(t *testing.T) {
dir := t.TempDir()
dbPath := filepath.Join(dir, "t.db")
url := "sqlite:" + dbPath
t.Cleanup(db.ResetPool)
fields := []any{
map[string]any{"name": "slug", "type": "text", "nullable": false},
map[string]any{"name": "title", "type": "text", "nullable": false},
map[string]any{"name": "body", "type": "text", "nullable": true},
}
if _, err := db.Init(url, "posts", fields); err != nil {
t.Fatal(err)
}
if _, err := db.Insert(url, "posts", []any{
map[string]any{"slug": "hello-marqdo", "title": "Hello", "body": "## Hi\n\n*world*"},
}); err != nil {
t.Fatal(err)
}
page := map[string]any{
"title": "post",
"detail": true,
"_route": "/post/{slug}",
"params": map[string]any{"slug": "hello-marqdo"},
"query": map[string]any{
"字段": []any{"slug"},
"操作": []any{"="},
"值": []any{"{slug}"},
},
"main": []any{
map[string]any{"front": "title", "back": "posts.title"},
map[string]any{"front": "body", "back": "posts.body"},
},
"parts": map[string]any{
"index": map[string]any{"slot": "main"},
},
}
html := RenderPage(page, url, "")
if !strings.Contains(html, `class="article-title"`) || !strings.Contains(html, "Hello") {
t.Fatalf("missing article title: %s", html)
}
if !strings.Contains(html, `class="article-body md"`) {
t.Fatalf("missing markdown body wrapper: %s", html)
}
if !strings.Contains(html, "world") {
t.Fatalf("missing markdown content: %s", html)
}
if strings.Contains(html, "{slug}") {
t.Fatalf("literal {slug} still present: %s", html)
}
if !strings.Contains(html, `/post/hello-marqdo/_part/`) {
t.Fatalf("slot prefix not resolved: %s", html)
}
}
func TestMarkdownToHTML(t *testing.T) {
out := markdownToHTML("## Title\n\n**bold** and `code`")
if !strings.Contains(out, `class="article-body md"`) {
t.Fatalf("%s", out)
}
if !strings.Contains(out, "<h2") || !strings.Contains(out, "<strong>bold</strong>") {
t.Fatalf("%s", out)
}
}
+20 -2
View File
@@ -38,12 +38,30 @@ func TestStyleStrictKeepsQuotedSlash(t *testing.T) {
}
}
func TestStyleStrictRejectsNumeric(t *testing.T) {
func TestStyleStrictAllowsNumeric(t *testing.T) {
css, err := style.Style(map[string]any{
"name": "x",
"strict": true,
"table": []any{
map[string]any{"选择器": ".x", "属性": "z-index", "值": float64(20)},
map[string]any{"选择器": ".y", "属性": "opacity", "值": float64(0.5)},
map[string]any{"选择器": ".z", "属性": "font-weight", "值": float64(700)},
},
})
if err != nil {
t.Fatalf("numeric CSS must not be suspicious: %v", err)
}
if !strings.Contains(css, "z-index: 20") || !strings.Contains(css, "opacity: 0.5") {
t.Fatalf("%q", css)
}
}
func TestStyleStrictRejectsBoolean(t *testing.T) {
_, err := style.Style(map[string]any{
"name": "x",
"strict": true,
"table": []any{
map[string]any{"选择器": ".x", "属性": "grid-column", "值": float64(0)},
map[string]any{"选择器": ".x", "属性": "display", "值": true},
},
})
if err == nil || !strings.Contains(err.Error(), "suspicious") {
+2 -2
View File
@@ -693,9 +693,9 @@ func AsCSSNamedChecked(name string, table any, strict bool) (string, error) {
}
func cssValueSuspicious(v any) string {
// Numbers are normal CSS (z-index, opacity, font-weight, unitless 0).
// Do not treat Markup-evaluated ints/floats as "bare `/` division".
switch v.(type) {
case float64, int, int64:
return "numeric CSS value (likely bare `/` division such as `1 / 5`; quote the cell, e.g. `\"1 / 5\"`)"
case bool:
return "boolean CSS value (quote the cell if intentional)"
default:
+44
View File
@@ -60,6 +60,8 @@ extern int web_page_chrome(char *args_json, char **out_json, char **err_msg);
extern int web_style(char *args_json, char **out_json, char **err_msg);
extern int web_compose_components(char *args_json, char **out_json, char **err_msg);
extern int web_compose_main(char *args_json, char **out_json, char **err_msg);
extern int web_compose_intro(char *args_json, char **out_json, char **err_msg);
extern int web_intro(char *args_json, char **out_json, char **err_msg);
extern int web_render(char *args_json, char **out_json, char **err_msg);
extern int web_db_new(char *args_json, char **out_json, char **err_msg);
extern int web_db_init(char *args_json, char **out_json, char **err_msg);
@@ -153,6 +155,8 @@ static int register_core(void) {
if (host_register((char *)"web_style", (char *)"name,table,strict", web_style) != 0) return 1;
if (host_register((char *)"web_compose_components", (char *)"page,components", web_compose_components) != 0) return 1;
if (host_register((char *)"web_compose_main", (char *)"page,main", web_compose_main) != 0) return 1;
if (host_register((char *)"web_compose_intro", (char *)"page,intro", web_compose_intro) != 0) return 1;
if (host_register((char *)"web_intro", (char *)"table", web_intro) != 0) return 1;
if (host_register((char *)"web_compose_form", (char *)"page,form,id,target", web_compose_form) != 0) return 1;
if (host_register((char *)"web_render", (char *)"page", web_render) != 0) return 1;
if (host_register((char *)"web_db_new", (char *)"url", web_db_new) != 0) return 1;
@@ -509,6 +513,46 @@ func web_compose_main(argsJSON *C.char, outJSON **C.char, errMsg **C.char) C.int
return replyJSON(outJSON, errMsg, out, err)
}
//export web_compose_intro
func web_compose_intro(argsJSON *C.char, outJSON **C.char, errMsg **C.char) C.int {
args, err := parseArgs(argsJSON)
if err != nil {
return replyJSON(outJSON, errMsg, nil, err)
}
pageBag := asPageMap(args["page"])
intro := args["intro"]
if intro == nil {
intro = args["引言"]
}
if intro == nil {
intro = args["table"]
}
if intro == nil {
return replyJSON(outJSON, errMsg, nil, fmt.Errorf("missing `intro`"))
}
out, err := compose.ComposeIntro(pageBag, intro, callLib)
return replyJSON(outJSON, errMsg, out, err)
}
//export web_intro
func web_intro(argsJSON *C.char, outJSON **C.char, errMsg **C.char) C.int {
args, err := parseArgs(argsJSON)
if err != nil {
return replyJSON(outJSON, errMsg, nil, err)
}
tbl := args["table"]
if tbl == nil {
tbl = args["intro"]
}
if tbl == nil {
tbl = args["表"]
}
if tbl == nil {
return replyJSON(outJSON, errMsg, nil, fmt.Errorf("missing `table`"))
}
return replyJSON(outJSON, errMsg, compose.MakeIntroHTML(tbl), nil)
}
//export web_render
func web_render(argsJSON *C.char, outJSON **C.char, errMsg **C.char) C.int {
args, err := parseArgs(argsJSON)
+19
View File
@@ -13,6 +13,25 @@ AI already prefers Markdown-shaped output. The idea was: why keep docs and code
The language is still young: structure markers, bilingual core names (`print` / `打印`, …), importable stdlibs (see [`stdlib/`](stdlib/) on this site), local `view`, and static export. Contribute on [GitHub](https://github.com/cflmy/marqdo).
## Install
Pick one way to get the CLI:
| Method | Notes |
|--------|-------|
| Ubuntu PPA | `sudo add-apt-repository ppa:cflmy/marqdo` then `sudo apt install marqdo` |
| GitHub Releases | Prebuilt Windows / Linux zips at [releases](https://github.com/cflmy/marqdo/releases) |
| From source | `cargo build --release` (needs Rust) |
Official extensions version independently of the CLI:
```text
marqdo ext add web
marqdo ext add quantum
```
`ext add` tries CDN https://ext.marqdo.com first, then GitHub, then the proxy mirror. See [`features/05-extensions.mq.md`](features/05-extensions.mq.md).
中文文档请看同目录的 [`00-欢迎.mq.md`](00-欢迎.mq.md)(叙述与内置均用中文)。
A small function to say hello:
+19
View File
@@ -13,6 +13,25 @@ AI 偏爱 Markdown结构的输出。作者的念头是:何必再把文档和
语言仍在起步:结构标记、中英内核双名(`打印` / `print` …)、可导入的标准库(见本站 [`stdlib/`](stdlib/))、本地 `view` 与静态导出。欢迎到 [GitHub](https://github.com/cflmy/marqdo) 一起做。
## 安装
解释器(CLI)任选其一:
| 方式 | 说明 |
|------|------|
| Ubuntu PPA | `sudo add-apt-repository ppa:cflmy/marqdo` 后 `sudo apt install marqdo` |
| GitHub Releases | [releases](https://github.com/cflmy/marqdo/releases) 下载 Windows / Linux 预编译包 |
| 源码 | `cargo build --release`(需本机 Rust) |
官方扩展与 CLI 可分开更新。安装扩展:
```text
marqdo ext add web
marqdo ext add quantum
```
`ext add` 下载顺序:CDN https://ext.marqdo.com → GitHub → proxy 镜像。详见本站 [`features/05-扩展.mq.md`](features/05-扩展.mq.md)。
English docs: [`00-welcome.mq.md`](00-welcome.mq.md) (English prose and English builtins).
用一个小函数打个招呼:
+8 -4
View File
@@ -5,7 +5,7 @@ description: Optional packages — not stdlib
# main
ext/ holds official optional extensions. They are not part of lib/. Resolve via MARQDO_EXT, ./ext, or ext/ next to the binary.
ext/ holds official optional extensions. They are not part of lib/. Resolve via `~/.marqdo/ext`, MARQDO_EXT, ./ext, or ext/ next to the binary.
Install (v0.2+):
@@ -15,14 +15,18 @@ marqdo ext add llm
marqdo ext add agent
marqdo ext add web
marqdo ext add quantum
marqdo ext add linalg
```
For packages with a native plugin, build first then add:
`ext add` downloads L1 sources and prebuilt natives when available. Order: CDN https://ext.marqdo.com → GitHub Releases → proxy mirror. Pack SemVer is `ext/VERSION` and may differ from the CLI.
Rebuild natives locally only when developing plugins:
```text
cargo build --release -p marqdo_plugin_agent
cargo build --release -p marqdo_plugin_web
cargo build --release -p marqdo_plugin_quantum
cargo build --release -p marqdo_plugin_linalg
bash ./scripts/build-web-plugin.sh
marqdo ext add agent
marqdo ext add web
marqdo ext add quantum
@@ -34,7 +38,7 @@ ext/llm — OpenAI-compatible chat. Design: doc/design/ext-llm.md
ext/agent — agent framework + native plugin. Design: doc/design/ext-agent.md
ext/web — HTTP / SQLite·Postgres site helpers + native plugin (default *Go libweb*, v0.4.0). **W0–W7 + P3 + W8** + **customization C0–C4**; acceptance example `examples/anlian-mq/`. **Browser embed (routes D/E/F, v0.3.4)**: `web.client_embed` auto-mounts WASM — zero author JS; `lib/browser` + GFM tables; build with `marqdo wasm build`; examples: browser-hello · browser-app · browser-media · web-client-site. Design: doc/design/ext-web.md · WASM: doc/adr/0002-browser-marqdo-wasm.md · roadmaps D/E/F.
ext/web — HTTP / SQLite·Postgres site helpers + native plugin (default *Go libweb*, v0.4.0). W0–W7, P3, W8, and customization C0–C4; acceptance example `examples/anlian-mq/`. Browser embed (routes D/E/F, v0.3.4): `web.client_embed` auto-mounts WASM — zero author JS; `lib/browser` + GFM tables; build with `marqdo wasm build`; examples: browser-hello · browser-app · browser-media · web-client-site. Design: doc/design/ext-web.md · WASM: doc/adr/0002-browser-marqdo-wasm.md · roadmaps D/E/F.
ext/quantum — circuits, draw, noise, formula matrix custom gates, Q7 density/viz, Q8 themed SVG (`theme=dark|light|bw`). Design: doc/design/ext-quantum.md · doc/design/ext-quantum-viz-style.md
+8 -4
View File
@@ -5,7 +5,7 @@ description: 可选包 — 不是标准库
# main
ext/ 存放官方可选扩展,不属于 lib/。解析顺序:MARQDO_EXT、./ext、或可执行文件旁的 ext/。
ext/ 存放官方可选扩展,不属于 lib/。解析顺序:`~/.marqdo/ext`、MARQDO_EXT、./ext、或可执行文件旁的 ext/。
安装(v0.2+):
@@ -15,14 +15,18 @@ marqdo ext add llm
marqdo ext add agent
marqdo ext add web
marqdo ext add quantum
marqdo ext add linalg
```
带原生插件的包需先编译再 add:
`ext add` 会下载 L1 与预编译 native(若有)。下载顺序:CDN https://ext.marqdo.com → GitHub Releases → proxy 镜像。扩展包版本见 `ext/VERSION`,可与 CLI 分开发版。
带原生插件的包若需本地重编:
```text
cargo build --release -p marqdo_plugin_agent
cargo build --release -p marqdo_plugin_web
cargo build --release -p marqdo_plugin_quantum
cargo build --release -p marqdo_plugin_linalg
bash ./scripts/build-web-plugin.sh
marqdo ext add agent
marqdo ext add web
marqdo ext add quantum
@@ -34,7 +38,7 @@ ext/llm(大模型)— OpenAI 兼容聊天。设计:doc/design/ext-llm.md
ext/agent(智能体)— 智能体框架 + 原生插件。设计:doc/design/ext-agent.md
ext/web(网页)— HTTP / SQLite 站点助手 + 原生插件(默认 *Go libweb*,v0.4.0)。**W0–W7 + P3 + W8** + **定制 C0–C4**;验收示例 `examples/anlian-mq/`。**浏览器挂载(路线 D/E/F,v0.3.4)**:`网页.客户端挂载` / `web.client_embed` 自动 mount(作者零业务 JS);`lib/浏览器` + GFM;先 `marqdo wasm build`;示例 examples/browser-hello/ · examples/browser-app/ · examples/browser-media/ · examples/web-client-site/。设计:doc/design/ext-web.md · WASM:doc/adr/0002-browser-marqdo-wasm.md · 路线 D/E/F:doc/roadmap/browser-wasm-*.md
ext/web(网页)— HTTP / SQLite 站点助手 + 原生插件(默认 *Go libweb*,v0.4.0)。W0–W7、P3、W8 与定制 C0–C4;验收示例 `examples/anlian-mq/`。浏览器挂载(路线 D/E/F,v0.3.4):`网页.客户端挂载` / `web.client_embed` 自动 mount(作者零业务 JS);`lib/浏览器` + GFM;先 `marqdo wasm build`;示例 examples/browser-hello/ · examples/browser-app/ · examples/browser-media/ · examples/web-client-site/。设计:doc/design/ext-web.md · WASM:doc/adr/0002-browser-marqdo-wasm.md · 路线 D/E/F:doc/roadmap/browser-wasm-*.md
ext/quantum(量子)— 电路、绘图、噪声、公式矩阵自定义门、Q7 密度/高级图、Q8 主题 SVG(`主题=dark|light|bw`)。设计:doc/design/ext-quantum.md · doc/design/ext-quantum-viz-style.md
+3 -3
View File
@@ -24,8 +24,8 @@ Light statistics and optional `fields=` on log lines — no remote sinks, no dat
`fld` =
| step |
|------|
| done |
| step | status |
|------|--------|
| done | ok |
> log.info text="mid2-m10" fields=`fld`
+1 -1
View File
@@ -13,7 +13,7 @@ No extra allow flags: importing a module means you intend to use it. Under marqd
Modules: text (text / 文本), table (table / 表), files (fs / 文件), time (time / 时间), system (sys / 系统), json (json only), net (net / 网络), math (math / 数学), foreign (foreign / 外联), plugin (plugin / 插件), writeback (writeback / 自写回), subtask (subtask / 子任务).
From **v0.1.2**, official `lib/*.mq.md` is **embedded in the `marqdo` binary** (disk `lib/` or `MARQDO_LIB` still overrides). Standalone `.exe` works without a separate stdlib zip.
From v0.1.2, official `lib/*.mq.md` is embedded in the `marqdo` binary (disk `lib/` or `MARQDO_LIB` still overrides). Standalone `.exe` works without a separate stdlib zip.
Official optional extensions live under ext/ (not stdlib): ext/llm, ext/agent — see features/05-extensions.mq.md and doc/design/ext-llm.md / ext-agent.md.
+1 -1
View File
@@ -13,7 +13,7 @@ description: 如何导入官方 lib 模块
模块:文本(text / 文本)、表(table / 表)、文件(fs / 文件)、时间(time / 时间)、系统(sys / 系统)、json(仅 json)、网络(net / 网络)、数学(math / 数学)、外联(foreign / 外联)、插件(plugin / 插件)、自写回(writeback / 自写回)、子任务(subtask / 子任务)。
自 **v0.1.2** 起,官方 `lib/*.mq.md` **内置于 `marqdo` 二进制**(磁盘 `lib/` 或 `MARQDO_LIB` 仍可覆盖)。单独下载 `.exe` 即可导入标准库,无需再解压 stdlib 包。
自 v0.1.2 起,官方 `lib/*.mq.md` 内置于 `marqdo` 二进制(磁盘 `lib/` 或 `MARQDO_LIB` 仍可覆盖)。单独下载 `.exe` 即可导入标准库,无需再解压 stdlib 包。
官方可选扩展在 ext/(不是标准库):ext/llm、ext/agent — 见 features/05-扩展.mq.md。
+155
View File
@@ -0,0 +1,155 @@
#!/usr/bin/env bash
# Build a signed Ubuntu *source* package for Launchpad PPA.
# Usage: ./scripts/ppa-build-source.sh [series]
# Example: ./scripts/ppa-build-source.sh noble
#
# Launchpad builders have no network and noble's cargo (1.75) cannot read
# Cargo.lock v4. This script therefore:
# 1) cargo vendor → vendor/
# 2) installs a modern Rust toolchain into third_party/rust (cached)
# 3) packs both into the .orig.tar.xz for offline debuild on Launchpad
set -euo pipefail
SERIES="${1:-noble}"
ROOT="$(cd "$(dirname "$0")/.." && pwd)"
cd "$ROOT"
need() { command -v "$1" >/dev/null || { echo "missing tool: $1 (sudo apt install $2)"; exit 1; }; }
need cargo cargo
need debuild devscripts
need dpkg-parsechangelog dpkg-dev
need curl curl
need tar tar
need xz xz-utils
VER="$(sed -n 's/^version = "\(.*\)"/\1/p' Cargo.toml | head -1)"
# Debian revision comes from debian/changelog (e.g. 1.0.2-1ppa2); we append ~series.
CHG_VER="$(dpkg-parsechangelog -l debian/changelog -S Version)"
# Strip any previous ~series suffix from changelog version
BASE_DEB_VER="${CHG_VER%%~*}"
# If changelog still has old upstream, prefer Cargo VER for the upstream part
if [[ "$BASE_DEB_VER" != "$VER"-* ]]; then
# keep debian revision suffix after first '-' following VER if possible
REV="${BASE_DEB_VER#*-}"
if [[ "$BASE_DEB_VER" == *"-"* ]]; then
BASE_DEB_VER="${VER}-${REV}"
else
BASE_DEB_VER="${VER}-1ppa1"
fi
fi
DEB_VER="${BASE_DEB_VER}~${SERIES}"
PKG_ROOT="${TMPDIR:-/tmp}/marqdo-ppa/${VER}"
BUILD_AREA="${ROOT}/../build-area"
GPG_KEY="${MARQDO_PPA_GPG_KEY:-505943294D04C803}"
RUST_VER="${MARQDO_PPA_RUST_VERSION:-1.85.0}"
RUST_TRIPLE="${MARQDO_PPA_RUST_TRIPLE:-x86_64-unknown-linux-gnu}"
RUST_NAME="rust-${RUST_VER}-${RUST_TRIPLE}"
RUST_CACHE="${MARQDO_PPA_RUST_CACHE:-${HOME}/.cache/marqdo-ppa}"
RUST_TARBALL="${RUST_CACHE}/${RUST_NAME}.tar.gz"
RUST_URL="${MARQDO_PPA_RUST_URL:-https://static.rust-lang.org/dist/${RUST_NAME}.tar.gz}"
echo "==> upstream ${VER} → debian ${DEB_VER} (${SERIES})"
rm -rf "$PKG_ROOT"
mkdir -p "$PKG_ROOT" "$BUILD_AREA" "$RUST_CACHE"
# Clean export of sources (no target/, .git)
if command -v git >/dev/null && git rev-parse --is-inside-work-tree >/dev/null 2>&1; then
git archive --format=tar HEAD | tar -x -C "$PKG_ROOT"
else
rsync -a --exclude target --exclude .git --exclude build-area "$ROOT"/ "$PKG_ROOT"/
fi
# Ensure debian/ from working tree (may be newer than last commit)
rsync -a "$ROOT/debian/" "$PKG_ROOT/debian/"
cd "$PKG_ROOT"
python3 - <<PY
from pathlib import Path
import re
p = Path("debian/changelog")
text = p.read_text(encoding="utf-8")
text2 = re.sub(
r"^marqdo \([^)]+\) [^;]+;",
"marqdo (${DEB_VER}) ${SERIES};",
text,
count=1,
flags=re.M,
)
p.write_text(text2, encoding="utf-8")
print("changelog:", p.read_text(encoding="utf-8").splitlines()[0])
PY
echo "==> cargo vendor (Launchpad offline)"
mkdir -p .cargo
cargo vendor --locked vendor >/tmp/marqdo-cargo-vendor.conf
cat > .cargo/config.toml <<'EOF'
[source.crates-io]
replace-with = "vendored-sources"
[source.vendored-sources]
directory = "vendor"
EOF
echo "==> bundle Rust ${RUST_VER} (${RUST_TRIPLE}) for Launchpad"
if [ ! -f "$RUST_TARBALL" ]; then
echo " downloading ${RUST_URL}"
curl -fL --retry 3 --retry-delay 2 -o "${RUST_TARBALL}.partial" "$RUST_URL"
mv "${RUST_TARBALL}.partial" "$RUST_TARBALL"
else
echo " cache hit ${RUST_TARBALL}"
fi
rm -rf third_party/rust
mkdir -p third_party
RUST_EXTRACT="$(mktemp -d "${TMPDIR:-/tmp}/marqdo-rust.XXXXXX")"
tar -xzf "$RUST_TARBALL" -C "$RUST_EXTRACT"
# Official dist tarball contains install.sh
INSTALL_SH="$(find "$RUST_EXTRACT" -maxdepth 2 -name install.sh | head -1)"
if [ -z "$INSTALL_SH" ]; then
echo "error: install.sh not found in ${RUST_TARBALL}" >&2
exit 1
fi
# --disable-ldconfig avoids needing root; strip docs to save space
bash "$INSTALL_SH" \
--prefix="$PKG_ROOT/third_party/rust" \
--without=rust-docs \
--disable-ldconfig
rm -rf "$RUST_EXTRACT"
"$PKG_ROOT/third_party/rust/bin/rustc" --version
"$PKG_ROOT/third_party/rust/bin/cargo" --version
# Always rebuild orig (vendor + rust toolchain change every run)
cd "$(dirname "$PKG_ROOT")"
ORIG="marqdo_${VER}.orig.tar.xz"
echo "==> packing ${ORIG} (vendor + third_party/rust)"
rm -f "$BUILD_AREA/$ORIG" "marqdo_${VER}.orig.tar.xz"
tar -cJf "$BUILD_AREA/$ORIG" \
--exclude=debian \
-C "$(dirname "$PKG_ROOT")" "$(basename "$PKG_ROOT")"
ln -sfn "$BUILD_AREA/$ORIG" "marqdo_${VER}.orig.tar.xz"
ls -lh "$BUILD_AREA/$ORIG"
cd "$PKG_ROOT"
echo "==> debuild -S (key ${GPG_KEY})"
debuild -S -sa -k"${GPG_KEY}" -d
# debuild writes next to package parent (/tmp/marqdo-ppa/); collect into build-area
mkdir -p "$BUILD_AREA"
shopt -s nullglob
for f in ../marqdo_"${DEB_VER}"* ../marqdo_"${VER}".orig.tar.*; do
[ -e "$f" ] || continue
if [ "$(realpath -m "$f")" = "$(realpath -m "$BUILD_AREA/$(basename "$f")")" ]; then
continue
fi
cp -f "$f" "$BUILD_AREA/"
done
shopt -u nullglob
echo "==> artifacts in $BUILD_AREA:"
ls -la "$BUILD_AREA"/marqdo_"${DEB_VER}"* "$BUILD_AREA"/marqdo_"${VER}".orig.tar.* 2>/dev/null || true
CHANGES="$BUILD_AREA/marqdo_${DEB_VER}_source.changes"
if [ -f "$CHANGES" ]; then
echo
echo "Upload with:"
echo " dput ppa:cflmy/marqdo $CHANGES"
echo " # or: ./scripts/ppa-ship.sh ${SERIES}"
fi
+107
View File
@@ -0,0 +1,107 @@
#!/usr/bin/env bash
# One-shot: install packaging tools → build signed source package → dput to Launchpad PPA.
#
# Run in YOUR terminal (needs sudo for apt + GPG passphrase for signing):
# ./scripts/ppa-ship.sh # default series: noble
# ./scripts/ppa-ship.sh resolute # match host /etc/os-release
# ./scripts/ppa-ship.sh noble --no-upload
# sudo ./scripts/ppa-ship.sh noble # also OK — build/sign/upload drop back to $SUDO_USER
#
# PPA: ppa:cflmy/marqdo | key: 505943294D04C803
set -euo pipefail
SERIES="${1:-noble}"
NO_UPLOAD=0
for arg in "${@:2}"; do
case "$arg" in
--no-upload|-n) NO_UPLOAD=1 ;;
*) echo "unknown arg: $arg" >&2; exit 2 ;;
esac
done
ROOT="$(cd "$(dirname "$0")/.." && pwd)"
cd "$ROOT"
# Never cargo/debuild/dput as root — GPG lives in the human user's ~/.gnupg
if [ "$(id -u)" -eq 0 ]; then
if [ -z "${SUDO_USER:-}" ] || [ "$SUDO_USER" = root ]; then
echo "error: run as a normal user, or: sudo -u \$USER ./scripts/ppa-ship.sh" >&2
exit 1
fi
REAL_USER="$SUDO_USER"
REAL_HOME="$(getent passwd "$REAL_USER" | cut -d: -f6)"
echo "==> root detected; apt as root, build/upload as ${REAL_USER}"
run_user() {
local upath="${REAL_HOME}/.cargo/bin:/usr/local/bin:/usr/bin:/bin"
sudo -u "$REAL_USER" -H --preserve-env=MARQDO_PPA_GPG_KEY \
env HOME="$REAL_HOME" PATH="$upath" "$@"
}
APT=(apt-get)
else
REAL_USER="$(id -un)"
REAL_HOME="$HOME"
run_user() { "$@"; }
APT=(sudo apt-get)
fi
PPA_TARGET="${MARQDO_PPA:-ppa:cflmy/marqdo}"
PKGS=(build-essential debhelper devscripts dput lintian
dpkg-dev quilt cargo rustc pkg-config libssl-dev ca-certificates
python3 xz-utils)
need_apt=0
for bin in debuild dput dpkg-parsechangelog cargo gpg; do
if ! command -v "$bin" >/dev/null 2>&1; then
need_apt=1
break
fi
done
# dh_auto_* comes from debhelper even if debuild exists from a partial install
if ! dpkg -s debhelper >/dev/null 2>&1; then
need_apt=1
fi
if [ "$need_apt" -eq 1 ]; then
echo "==> installing packaging toolchain (sudo)…"
"${APT[@]}" update -qq
DEBIAN_FRONTEND=noninteractive "${APT[@]}" install -y "${PKGS[@]}"
else
echo "==> packaging tools already present"
fi
echo "==> building source package for series=${SERIES}"
run_user "$ROOT/scripts/ppa-build-source.sh" "$SERIES"
VER="$(sed -n 's/^version = "\(.*\)"/\1/p' "$ROOT/Cargo.toml" | head -1)"
BUILD_AREA="$(cd "$ROOT/.." && pwd)/build-area"
# Prefer changes matching this series; fall back to newest source.changes
CHANGES="$(ls -1t "$BUILD_AREA"/marqdo_*"~${SERIES}"_source.changes 2>/dev/null | head -1 || true)"
if [ -z "${CHANGES:-}" ]; then
CHANGES="$(ls -1t "$BUILD_AREA"/marqdo_*_source.changes 2>/dev/null | head -1 || true)"
fi
if [ -z "${CHANGES:-}" ] || [ ! -f "$CHANGES" ]; then
echo "error: no *_source.changes under $BUILD_AREA" >&2
ls -la "$BUILD_AREA" 2>/dev/null || true
exit 1
fi
echo "==> artifact: $CHANGES"
if command -v lintian >/dev/null 2>&1; then
echo "==> lintian (non-fatal)"
run_user lintian -i "$CHANGES" || true
fi
if [ "$NO_UPLOAD" -eq 1 ]; then
echo
echo "Skip upload (--no-upload). When ready:"
echo " dput ${PPA_TARGET} ${CHANGES}"
exit 0
fi
echo "==> dput ${PPA_TARGET}"
run_user dput --unchecked "${PPA_TARGET}" "$CHANGES"
echo
echo "Done. Watch builds:"
echo " https://launchpad.net/~cflmy/+archive/ubuntu/marqdo/+builds"
echo "Enable the Ubuntu series (${SERIES}) in PPA → Change details if Launchpad rejects the upload."
+222
View File
@@ -0,0 +1,222 @@
#!/usr/bin/env python3
"""Upload Marqdo extension packs to Cloudflare R2 (CDN: https://ext.marqdo.com).
No third-party deps (stdlib only) — AWS Signature V4 PutObject.
Credentials: ~/.marqdo/r2.env (chmod 600; never commit). Required:
R2_ENDPOINT, R2_BUCKET, R2_ACCESS_KEY_ID, R2_SECRET_ACCESS_KEY
Optional: R2_PUBLIC_BASE, R2_REGION (default auto)
Usage:
python3 scripts/upload-ext-r2.py --version 1.0.2 dist/marqdo-1.0.2-ext.zip \\
dist/marqdo-1.0.2-native-x86_64-unknown-linux-gnu.zip
python3 scripts/upload-ext-r2.py --version 1.0.2 --from-dir dist/
"""
from __future__ import annotations
import argparse
import datetime as dt
import hashlib
import hmac
import os
import sys
import tempfile
import urllib.error
import urllib.request
from pathlib import Path
from urllib.parse import quote, urlparse
def load_env_file(path: Path) -> None:
if not path.is_file():
return
for line in path.read_text(encoding="utf-8").splitlines():
line = line.strip()
if not line or line.startswith("#") or "=" not in line:
continue
k, _, v = line.partition("=")
os.environ.setdefault(k.strip(), v.strip().strip("'").strip('"'))
def sha256_hex(data: bytes) -> str:
return hashlib.sha256(data).hexdigest()
def hmac_sha256(key: bytes, msg: str) -> bytes:
return hmac.new(key, msg.encode("utf-8"), hashlib.sha256).digest()
def signing_key(secret: str, datestamp: str, region: str, service: str) -> bytes:
k_date = hmac_sha256(("AWS4" + secret).encode("utf-8"), datestamp)
k_region = hmac.new(k_date, region.encode("utf-8"), hashlib.sha256).digest()
k_service = hmac.new(k_region, service.encode("utf-8"), hashlib.sha256).digest()
return hmac.new(k_service, b"aws4_request", hashlib.sha256).digest()
def put_object(
*,
endpoint: str,
bucket: str,
key: str,
body: bytes,
content_type: str,
access_key: str,
secret_key: str,
region: str,
) -> None:
endpoint = endpoint.rstrip("/")
host = urlparse(endpoint).netloc
# Path-style: https://endpoint/bucket/key
canonical_uri = "/" + bucket + "/" + quote(key, safe="/~")
amz_date = dt.datetime.now(dt.timezone.utc).strftime("%Y%m%dT%H%M%SZ")
datestamp = amz_date[:8]
payload_hash = sha256_hex(body)
canonical_headers = (
f"content-type:{content_type}\n"
f"host:{host}\n"
f"x-amz-content-sha256:{payload_hash}\n"
f"x-amz-date:{amz_date}\n"
)
signed_headers = "content-type;host;x-amz-content-sha256;x-amz-date"
canonical_request = "\n".join(
[
"PUT",
canonical_uri,
"",
canonical_headers,
signed_headers,
payload_hash,
]
)
credential_scope = f"{datestamp}/{region}/s3/aws4_request"
string_to_sign = "\n".join(
[
"AWS4-HMAC-SHA256",
amz_date,
credential_scope,
sha256_hex(canonical_request.encode("utf-8")),
]
)
sig = hmac.new(
signing_key(secret_key, datestamp, region, "s3"),
string_to_sign.encode("utf-8"),
hashlib.sha256,
).hexdigest()
auth = (
f"AWS4-HMAC-SHA256 Credential={access_key}/{credential_scope}, "
f"SignedHeaders={signed_headers}, Signature={sig}"
)
url = endpoint + canonical_uri
req = urllib.request.Request(url, data=body, method="PUT")
req.add_header("Content-Type", content_type)
req.add_header("x-amz-content-sha256", payload_hash)
req.add_header("x-amz-date", amz_date)
req.add_header("Authorization", auth)
try:
with urllib.request.urlopen(req, timeout=300) as resp:
if resp.status not in (200, 201):
raise RuntimeError(f"PUT {key} HTTP {resp.status}")
except urllib.error.HTTPError as e:
detail = e.read().decode("utf-8", errors="replace")
raise RuntimeError(f"PUT {key} HTTP {e.code}: {detail}") from e
def content_type_for(path: Path) -> str:
if path.name == "VERSION" or path.suffix.lower() == ".txt":
return "text/plain; charset=utf-8"
if path.suffix.lower() == ".json":
return "application/json"
return "application/zip"
def upload_file(
path: Path,
key: str,
*,
endpoint: str,
bucket: str,
access_key: str,
secret_key: str,
region: str,
public_base: str,
) -> None:
body = path.read_bytes()
print(f"upload {path.name} → s3://{bucket}/{key} ({len(body)} bytes)")
put_object(
endpoint=endpoint,
bucket=bucket,
key=key,
body=body,
content_type=content_type_for(path),
access_key=access_key,
secret_key=secret_key,
region=region,
)
print(f" public: {public_base.rstrip('/')}/{key}")
def main() -> int:
load_env_file(Path.home() / ".marqdo" / "r2.env")
load_env_file(Path(".env"))
load_env_file(Path(".env.r2"))
ap = argparse.ArgumentParser(description=__doc__)
ap.add_argument("--version", required=True, help="Extension pack SemVer (no v prefix)")
ap.add_argument("--from-dir", type=Path, help="Upload all marqdo-{VER}-*.zip from dir")
ap.add_argument("files", nargs="*", type=Path, help="Files to upload")
ap.add_argument("--no-latest", action="store_true", help="Do not update latest/ pointers")
args = ap.parse_args()
ver = args.version.lstrip("v")
for key in ("R2_ENDPOINT", "R2_BUCKET", "R2_ACCESS_KEY_ID", "R2_SECRET_ACCESS_KEY"):
if not os.environ.get(key):
print(
f"missing {key}; write ~/.marqdo/r2.env (see .env.r2.example)",
file=sys.stderr,
)
return 1
endpoint = os.environ["R2_ENDPOINT"]
bucket = os.environ["R2_BUCKET"]
access_key = os.environ["R2_ACCESS_KEY_ID"]
secret_key = os.environ["R2_SECRET_ACCESS_KEY"]
region = os.environ.get("R2_REGION", "auto")
public_base = os.environ.get("R2_PUBLIC_BASE", "https://ext.marqdo.com")
files: list[Path] = [p for p in args.files if p.is_file()]
if args.from_dir:
files.extend(sorted(args.from_dir.glob(f"marqdo-{ver}-*.zip")))
if not files:
print("no files to upload", file=sys.stderr)
return 1
kw = dict(
endpoint=endpoint,
bucket=bucket,
access_key=access_key,
secret_key=secret_key,
region=region,
public_base=public_base,
)
for path in files:
upload_file(path, f"v{ver}/{path.name}", **kw)
if not args.no_latest:
upload_file(path, f"latest/{path.name}", **kw)
if not args.no_latest:
with tempfile.NamedTemporaryFile("w", encoding="utf-8", delete=False) as tf:
tf.write(ver + "\n")
tmp = Path(tf.name)
try:
upload_file(tmp, "latest/VERSION", **kw)
upload_file(tmp, f"v{ver}/VERSION", **kw)
finally:
tmp.unlink(missing_ok=True)
print("done.")
return 0
if __name__ == "__main__":
raise SystemExit(main())
+173 -33
View File
@@ -1,16 +1,32 @@
//! Download official `ext/` L1 sources and native plugins from GitHub Releases.
//! Download official `ext/` L1 sources and native plugins.
//!
//! Enables `marqdo ext add web` without a local Rust toolchain or repo checkout.
//! Disable with `MARQDO_EXT_NO_DOWNLOAD=1`. Override tag with `MARQDO_EXT_VERSION=0.3.4`.
//!
//! Disable with `MARQDO_EXT_NO_DOWNLOAD=1`. Override pack SemVer with
//! `MARQDO_EXT_VERSION` (independent of CLI `CARGO_PKG_VERSION`).
//!
//! Download order (first success wins):
//! 1. `MARQDO_EXT_DOWNLOAD_BASE` (optional override)
//! 2. **CDN** `https://ext.marqdo.com` (Cloudflare R2 custom domain)
//! 3. GitHub Releases `github.com/cflmy/marqdo`
//! 4. GitHub via reverse proxy `proxy.cflmy.top`
use std::env;
use std::fs::{self, File};
use std::io::{self, Write};
use std::io::{self, Read, Write};
use std::path::{Path, PathBuf};
use std::sync::OnceLock;
use std::time::Duration;
use anyhow::{bail, Context, Result};
const REPO: &str = "cflmy/marqdo";
/// Public CDN for extension packs (R2 bucket `marqdo`, custom domain).
pub const EXT_CDN_BASE: &str = "https://ext.marqdo.com";
/// HTTPS reverse proxy used when github.com is slow or blocked.
const GITHUB_MIRROR_PREFIX: &str = "https://proxy.cflmy.top/github.com";
/// Packaged with the repo; may diverge from CLI SemVer for ext-only releases.
const EMBEDDED_EXT_VERSION: &str = include_str!(concat!(env!("CARGO_MANIFEST_DIR"), "/ext/VERSION"));
pub fn downloads_enabled() -> bool {
match env::var("MARQDO_EXT_NO_DOWNLOAD") {
@@ -22,17 +38,69 @@ pub fn downloads_enabled() -> bool {
}
}
/// SemVer without leading `v` (matches release asset names).
fn normalize_semver(raw: &str) -> Option<String> {
let v = raw.trim().trim_start_matches('v').trim();
if v.is_empty() {
return None;
}
// one line only
let v = v.lines().next()?.trim().trim_start_matches('v').trim();
if v.is_empty() {
return None;
}
Some(v.to_string())
}
/// SemVer of the **extension pack** (may differ from CLI version).
///
/// Resolution order:
/// 1. `MARQDO_EXT_VERSION`
/// 2. CDN `GET {EXT_CDN}/latest/VERSION` (short timeout; skipped if downloads disabled)
/// 3. Embedded `ext/VERSION` at build time
/// 4. CLI `CARGO_PKG_VERSION`
pub fn release_version() -> String {
if let Ok(v) = env::var("MARQDO_EXT_VERSION") {
let v = v.trim().trim_start_matches('v');
if !v.is_empty() {
return v.to_string();
if let Some(n) = normalize_semver(&v) {
return n;
}
}
if downloads_enabled() {
if let Some(n) = fetch_cdn_latest_version() {
return n;
}
}
if let Some(n) = normalize_semver(EMBEDDED_EXT_VERSION) {
return n;
}
env!("CARGO_PKG_VERSION").to_string()
}
fn fetch_cdn_latest_version() -> Option<String> {
static CACHED: OnceLock<Option<String>> = OnceLock::new();
CACHED
.get_or_init(|| {
let base = env::var("MARQDO_EXT_CDN")
.ok()
.map(|s| s.trim().trim_end_matches('/').to_string())
.filter(|s| !s.is_empty())
.unwrap_or_else(|| EXT_CDN_BASE.to_string());
let url = format!("{base}/latest/VERSION");
let agent = ureq::AgentBuilder::new()
.timeout_connect(Duration::from_secs(5))
.timeout_read(Duration::from_secs(10))
.user_agent(&user_agent())
.build();
let resp = agent.get(&url).call().ok()?;
if !(200..300).contains(&resp.status()) {
return None;
}
let mut body = String::new();
resp.into_reader().read_to_string(&mut body).ok()?;
normalize_semver(&body)
})
.clone()
}
pub fn host_target_triple() -> Option<&'static str> {
if cfg!(all(target_os = "windows", target_arch = "x86_64")) {
Some("x86_64-pc-windows-msvc")
@@ -61,13 +129,58 @@ fn user_agent() -> String {
format!("marqdo/{}", env!("CARGO_PKG_VERSION"))
}
fn http_agent() -> ureq::Agent {
ureq::AgentBuilder::new()
.timeout_connect(Duration::from_secs(20))
.timeout_read(Duration::from_secs(600))
.user_agent(&user_agent())
.build()
}
fn cdn_base() -> String {
env::var("MARQDO_EXT_CDN")
.ok()
.map(|s| s.trim().trim_end_matches('/').to_string())
.filter(|s| !s.is_empty())
.unwrap_or_else(|| EXT_CDN_BASE.to_string())
}
/// Candidate download URLs for a release asset.
///
/// Order: optional `MARQDO_EXT_DOWNLOAD_BASE` → CDN → GitHub → GitHub proxy.
pub fn release_asset_urls(ver: &str, filename: &str) -> Vec<String> {
let mut urls = Vec::new();
if let Ok(base) = env::var("MARQDO_EXT_DOWNLOAD_BASE") {
let base = base.trim().trim_end_matches('/');
if !base.is_empty() {
urls.push(format!("{base}/{REPO}/releases/download/v{ver}/{filename}"));
urls.push(format!("{base}/releases/download/v{ver}/{filename}"));
urls.push(format!("{base}/v{ver}/{filename}"));
urls.push(format!("{base}/{filename}"));
}
}
let cdn = cdn_base();
// Preferred public layout on ext.marqdo.com / R2
urls.push(format!("{cdn}/v{ver}/{filename}"));
urls.push(format!("{cdn}/releases/v{ver}/{filename}"));
urls.push(format!("{cdn}/{filename}"));
urls.push(format!(
"https://github.com/{REPO}/releases/download/v{ver}/{filename}"
));
urls.push(format!(
"{GITHUB_MIRROR_PREFIX}/{REPO}/releases/download/v{ver}/{filename}"
));
let mut seen = std::collections::HashSet::new();
urls.into_iter().filter(|u| seen.insert(u.clone())).collect()
}
fn download_to_file(url: &str, dest: &Path) -> Result<()> {
if let Some(parent) = dest.parent() {
fs::create_dir_all(parent)?;
}
let tmp = dest.with_extension("download-tmp");
let resp = ureq::get(url)
.set("User-Agent", &user_agent())
let resp = http_agent()
.get(url)
.set("Accept", "application/octet-stream")
.call()
.with_context(|| format!("GET {url}"))?;
@@ -86,6 +199,30 @@ fn download_to_file(url: &str, dest: &Path) -> Result<()> {
Ok(())
}
fn download_first_ok(urls: &[String], dest: &Path) -> Result<()> {
let mut errors: Vec<String> = Vec::new();
for (i, url) in urls.iter().enumerate() {
if i == 0 {
println!("downloading ({url})…");
} else {
println!("retry ({url})…");
}
match download_to_file(url, dest) {
Ok(()) => return Ok(()),
Err(e) => {
eprintln!("note: {e:#}");
errors.push(format!("{url} → {e:#}"));
let _ = fs::remove_file(dest.with_extension("download-tmp"));
}
}
}
bail!(
"all download mirrors failed for {}:\n - {}",
dest.file_name().and_then(|s| s.to_str()).unwrap_or("asset"),
errors.join("\n - ")
)
}
fn extract_zip(zip_path: &Path, dest_dir: &Path) -> Result<()> {
fs::create_dir_all(dest_dir)?;
let file = File::open(zip_path).with_context(|| format!("open {}", zip_path.display()))?;
@@ -121,10 +258,6 @@ fn extract_zip(zip_path: &Path, dest_dir: &Path) -> Result<()> {
Ok(())
}
fn release_asset_url(ver: &str, filename: &str) -> String {
format!("https://github.com/{REPO}/releases/download/v{ver}/{filename}")
}
/// Ensure L1 `ext/` tree is available (repo checkout or downloaded Release zip).
/// Returns a directory that contains `web/web.mq.md`, `ai/…`, etc.
pub fn ensure_ext_source_tree() -> Result<PathBuf> {
@@ -134,7 +267,6 @@ pub fn ensure_ext_source_tree() -> Result<PathBuf> {
if marker.is_file() {
return Ok(cache);
}
// Zip layout from CI: top-level `ext/…`
let nested = cache.join("ext").join("web").join("web.mq.md");
if nested.is_file() {
return Ok(cache.join("ext"));
@@ -143,16 +275,14 @@ pub fn ensure_ext_source_tree() -> Result<PathBuf> {
bail!("extension sources not found and downloads disabled (MARQDO_EXT_NO_DOWNLOAD)");
}
let zip_name = format!("marqdo-{ver}-ext.zip");
let url = release_asset_url(&ver, &zip_name);
let urls = release_asset_urls(&ver, &zip_name);
let zip_path = cache_root()?.join(&zip_name);
println!("downloading official ext sources ({url})…");
download_to_file(&url, &zip_path)?;
download_first_ok(&urls, &zip_path)?;
let stage = cache_root()?.join(format!("ext-src-v{ver}-extract"));
if stage.exists() {
let _ = fs::remove_dir_all(&stage);
}
extract_zip(&zip_path, &stage)?;
// Prefer `ext/` child if present
let src = if stage.join("ext").join("web").join("web.mq.md").is_file() {
stage.join("ext")
} else if stage.join("web").join("web.mq.md").is_file() {
@@ -165,7 +295,6 @@ pub fn ensure_ext_source_tree() -> Result<PathBuf> {
if cache.exists() {
let _ = fs::remove_dir_all(&cache);
}
// Move/copy tree into stable cache path
copy_dir_recursive(&src, &cache)?;
let _ = fs::remove_dir_all(&stage);
if !cache.join("web").join("web.mq.md").is_file() {
@@ -206,24 +335,22 @@ pub fn download_native_plugin(short: &str, lib_name: &str) -> Result<PathBuf> {
};
let ver = release_version();
let zip_name = format!("marqdo-{ver}-native-{triple}.zip");
let url = release_asset_url(&ver, &zip_name);
let urls = release_asset_urls(&ver, &zip_name);
let cache = cache_root()?.join(format!("native-v{ver}-{triple}"));
let lib_in_cache = cache.join("native").join(lib_name);
if lib_in_cache.is_file() {
return Ok(lib_in_cache);
}
// Also accept flat layout
let flat = cache.join(lib_name);
if flat.is_file() {
return Ok(flat);
}
let zip_path = cache_root()?.join(&zip_name);
println!("downloading prebuilt native plugins ({url})…");
download_to_file(&url, &zip_path).with_context(|| {
download_first_ok(&urls, &zip_path).with_context(|| {
format!(
"failed to download prebuilt plugins for {triple}. \
Build locally with `cargo build --release -p marqdo_plugin_{short}`, \
or check https://github.com/{REPO}/releases/tag/v{ver}"
Set MARQDO_EXT_CDN / MARQDO_EXT_DOWNLOAD_BASE, build locally, \
or check https://github.com/{REPO}/releases and https://ext.marqdo.com/v{ver}/"
)
})?;
if cache.exists() {
@@ -238,7 +365,6 @@ pub fn download_native_plugin(short: &str, lib_name: &str) -> Result<PathBuf> {
if flat.is_file() {
return Ok(flat);
}
// Search recursively for the lib name
if let Some(found) = find_named_file(&cache, lib_name)? {
return Ok(found);
}
@@ -283,17 +409,31 @@ mod tests {
use super::*;
#[test]
fn asset_url_shape() {
let u = release_asset_url("0.3.4", "marqdo-0.3.4-ext.zip");
assert_eq!(
u,
"https://github.com/cflmy/marqdo/releases/download/v0.3.4/marqdo-0.3.4-ext.zip"
);
fn asset_urls_prefer_cdn_then_github_then_proxy() {
let u = release_asset_urls("1.0.2", "marqdo-1.0.2-ext.zip");
assert!(u[0].starts_with("https://ext.marqdo.com/"));
assert!(u.iter().any(|x| x.contains("github.com/cflmy/marqdo")));
assert!(u
.iter()
.any(|x| x.contains("proxy.cflmy.top/github.com/cflmy/marqdo")));
let gh = u
.iter()
.position(|x| x.starts_with("https://github.com/"))
.unwrap();
let proxy = u
.iter()
.position(|x| x.contains("proxy.cflmy.top"))
.unwrap();
assert!(gh < proxy);
}
#[test]
fn embedded_ext_version_parses() {
assert!(normalize_semver(EMBEDDED_EXT_VERSION).is_some());
}
#[test]
fn triple_known_on_ci_hosts() {
// At least one of these builds is what we ship.
let t = host_target_triple();
if cfg!(any(
all(target_os = "linux", target_arch = "x86_64"),
+18 -5
View File
@@ -140,10 +140,18 @@ pub fn resolve_import(from_dir: &Path, rel: &str) -> Result<PathBuf> {
"cannot resolve import `{rel}` from {}",
from_dir.display()
);
if env::var_os("MARQDO_EXT").is_none() {
msg.push_str(
"\nhint: set MARQDO_EXT to the directory that contains web/ (or run `marqdo ext add web`)",
);
let user_ext = crate::ext_cli::default_user_ext_dir();
if env::var_os("MARQDO_EXT").is_none() && !user_ext.join("web").join("web.mq.md").is_file()
{
msg.push_str(&format!(
"\nhint: run `marqdo ext add web` (installs under {}), or set MARQDO_EXT",
user_ext.display()
));
} else if env::var_os("MARQDO_EXT").is_none() {
msg.push_str(&format!(
"\nhint: looked under {}; set MARQDO_EXT to override",
user_ext.display()
));
}
bail!("{msg}");
}
@@ -194,6 +202,8 @@ fn ext_search_roots() -> Vec<PathBuf> {
if let Ok(h) = env::var("MARQDO_EXT") {
roots.push(PathBuf::from(h));
}
// Default install root from `marqdo ext add` (~/.marqdo/ext)
roots.push(crate::ext_cli::default_user_ext_dir());
if let Ok(cwd) = env::current_dir() {
roots.push(cwd.join("ext"));
}
@@ -318,7 +328,10 @@ mod tests {
"{msg}"
);
assert!(
msg.contains("hint: set MARQDO_EXT to the directory that contains web/"),
msg.contains("hint:")
&& (msg.contains("marqdo ext add")
|| msg.contains("MARQDO_EXT")
|| msg.contains(".marqdo/ext")),
"{msg}"
);
}
+19
View File
@@ -323,6 +323,16 @@ impl<'a> Cursor<'a> {
fun.body.push(self.parse_loop_or_err()?);
continue;
}
// Unbound GFM table = collection value (not assigned); evaluate and discard.
if trimmed.starts_with('|') {
let span = Span {
line: l.line_no,
col: 1,
};
let value = self.consume_table()?;
fun.body.push(Stmt::Expr { value, span });
continue;
}
let stmt = self.parse_simple_stmt()?;
let end_body = matches!(stmt, Stmt::Return { .. }) && level >= 2;
@@ -382,6 +392,13 @@ impl<'a> Cursor<'a> {
return Ok(Stmt::Call { call, span });
}
// Unbound GFM table (header already consumed by bump above).
if trimmed.starts_with('|') {
self.i -= 1;
let value = self.consume_table()?;
return Ok(Stmt::Expr { value, span });
}
// Bare assign `` `x` = … ``
if trimmed.starts_with('`') {
if let Some(stmt) = self.parse_backtick_assign(trimmed, span.clone())? {
@@ -695,6 +712,8 @@ impl<'a> Cursor<'a> {
/// - first header `@` / `行` / `row` → List of row Maps (marker col excluded)
/// - else ≥2-col → Map (column-oriented)
///
/// Also used for **unbound** tables in a function body (value computed, not stored).
///
/// Data cells are expressions ([`parse_call_arg_value`]); headers stay key text.
fn consume_table(&mut self) -> Result<Expr> {
self.skip_noise();
+55
View File
@@ -0,0 +1,55 @@
---
title: web compose_intro bind table
description: Intro uses the same front/back/style bind as compose_main.
import web:ext/web/web.mq.md
import sys:lib/sys.mq.md
---
# main
`intro` =
| front | back | style |
|-------|------|-------|
| kicker | Demo kicker | kicker |
| title | Hello | intro_title |
| lede | "Try code and [link](/x)." | lede |
| claim | A | claim |
| claim | B | claim |
| step | First step | step |
**page = > web.page title="Intro bind"**
**page = > page.compose_intro intro=intro**
**html = > page.render**
**a = > split value=`html` sep="class=\"kicker\""**
**na = > len value=`a`**
**b = > split value=`html` sep="class=\"intro_title\""**
**nb = > len value=`b`**
**c = > split value=`html` sep="href=\"/x\""**
**nc = > len value=`c`**
**d = > split value=`html` sep="class=\"claim\""**
**nd = > len value=`d`**
**e = > split value=`html` sep="class=\"steps\""**
**ne = > len value=`e`**
1. `na` > 1
1. `nb` > 1
1. `nc` > 1
1. `nd` > 1
1. `ne` > 1
> print text=compose-intro-ok
2. *
> print text=compose-intro-steps-missing
> sys.exit code=1
2. *
> print text=compose-intro-claim-missing
> sys.exit code=1
2. *
> print text=compose-intro-link-missing
> sys.exit code=1
2. *
> print text=compose-intro-title-missing
> sys.exit code=1
2. *
> print text=compose-intro-kicker-missing
> sys.exit code=1
+5
View File
@@ -132,6 +132,11 @@ fn structure_hello() {
assert_out("tests/structure/hello.mq.md", "Hello World!");
}
#[test]
fn structure_unbound_table() {
assert_out("tests/structure/unbound-table.mq.md", "ok");
}
#[test]
fn structure_object_handle() {
assert_out("tests/structure/object-handle.mq.md", "counter\n3\n4");
+15
View File
@@ -0,0 +1,15 @@
---
title: Unbound GFM table is a discarded value
---
# main
Documentation may include a table that is not bound to a name. It is still a
collection value; evaluating it must not error.
| Method | Notes |
|--------|-------|
| PPA | apt |
| Source | cargo |
> print text=ok