Release 2.7.0: executable handbooks and native user-site workflows

This commit is contained in:
cflmy committed 2026-11-10 17:03:06 +08:00
1 parent aa0c4d0f55
commit d9aef957f7
562 files changed
+21064 -20387

No files matched your search

+18 -22
View File
@@ -1,36 +1,32 @@
---
markup: occlusion
title: 文章结构与种子调用手册
import:
document: lib/document.mq.md
---
本文件解释各个调用的用途;相邻的 [articles.tables.md](articles.tables.md) 保存可直接阅读的字面表。把 --fs-root 指向站点目录,读取需要 fs.read。字段、样式与正文是数据,读取不会执行文件中的说明。
## schema
`fields` =
| 返回 | 类型 | 说明 |
|---|---|---|
| result | any | 原生字面表的原始类型与列式数据形态 |
| 字段 | 类型 | 可空 |
|------|------|------|
| id | integer | false |
| title | text | false |
| slug | text | false |
| summary | text | true |
| body | text | true |
声明文章的字段、原生类型与可空约束;id 的数值类型和必填字段保持不变。数据库初始化器使用此表保证结构,不负责猜测用户数据的迁移。
*`fields`*
授予站点文件根的 fs.read 后可独立调用。章节名精确匹配且必须唯一;表头、行列不齐或动态表达式会保留原生文档诊断。需要实际样式时再调用 css;需要数据库记录时交给数据库资源。返回值不是 HTML,也不是已应用的浏览器效果。
完成后返回*[读取 schema 的实际字面表](document.read_table(path="db/articles.tables.md", title="schema"))*.
## seed
卡片显示 summary;/post/{slug} 显示完整 body(Markdown)。
| 返回 | 类型 | 说明 |
|---|---|---|
| result | any | 原生字面表的原始类型与列式数据形态 |
`rows` =
提供起始演示文章,保留原来的 id、短链、摘要与正文。只有数据库初始化器确认空表后才应插入;读取本函数不会写入或重置现有文章。
| 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 与浏览器对照。这个闭环就是投稿本身。" |
授予站点文件根的 fs.read 后可独立调用。章节名精确匹配且必须唯一;表头、行列不齐或动态表达式会保留原生文档诊断。需要实际样式时再调用 css;需要数据库记录时交给数据库资源。返回值不是 HTML,也不是已应用的浏览器效果。
*`rows`*
完成后返回*[读取 seed 的实际字面表](document.read_table(path="db/articles.tables.md", title="seed"))*.
@@ -0,0 +1,30 @@
# Article data
Literal article schema and demonstration content. Reading these tables does not open a database or insert rows. Follow articles.mq.md for callable use; the database initializer decides whether seeding is appropriate.
## schema
Field definitions for the native database initializer; nullable values remain booleans.
| 字段 | 类型 | 可空 |
|------|------|------|
| id | integer | false |
| title | text | false |
| slug | text | false |
| summary | text | true |
| body | text | true |
## seed
Initial demonstration records in their original column-oriented shape; ids and stable slugs retain their meaning.
| 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 与浏览器对照。这个闭环就是投稿本身。" |
+30 -14
View File
@@ -1,21 +1,37 @@
---
markup: occlusion
title: db/index
description: 打开 sqlite、建表、幂等种子。
导入:
网页: ext/web/网页.mq.md
title: web-site-zh database lifecycle
import:
data: ext/data/db.mq.md
articles: articles.mq.md
fs: lib/fs.mq.md
text: lib/text.mq.md
---
The database entry connects schema and literal seed leaves to the actual data resource. It no longer uses the removed web database constructor. Grant fs.write and plugin with the site directory as --fs-root; the SQLite path is resolved through that native root rather than the process working directory.
## open
**store = > 网页.数据库 地址="sqlite:data/site-zh.db"**
**fields = > articles.schema**
> `store`.初始化 名=articles 字段=`fields`
**rows = > store.查询 表="articles" 上限=1**
1. `rows`
*store*
2. *
**seed = > articles.seed**
> `store`.插入 表=articles 行=`seed`
*store*
| 参数 | 类型 | 默认 | 说明 |
|---|---|---|---|
| url | any | None | None selects data/site-zh.db under the site root; tests provide a disposable explicit URI |
| 返回 | 类型 | 说明 |
|---|---|---|
| result | any | Initialized articles database resource with existing rows preserved |
Use `url`=None to open the site's local database. Create the default data directory through native file operations, then resolve the actual SQLite filename within the granted root. An explicit SQLite path goes through the same root and symlink checks before the native database resource receives it. Other supported database URIs retain their resource-specific backend contract; they are not sandboxed by filesystem permissions.
The schema reader preserves native field types and nullability. Initialization ensures the table exists, queries one row to distinguish an empty table, and inserts the original demonstration content only into an empty table. An existing or partly populated table is kept unchanged. This is not a column migrator, data repair tool or reason to delete a user's articles. A native connection, schema or insert diagnostic stops the caller before it starts serving.
For isolated verification choose a caller-owned temporary SQLite file and copy the article data leaf under that granted site root. Keep the returned resource in the same program for subsequent queries. Close the process before cleaning its owned directory; do not run tests against the example's existing data directory.
1. `url` == None
We **[Create only the site's default data directory](fs.make_dirs(path="data"))** and **file = [Resolve its database filename](fs.resolve(path="data/site-zh.db"))** and **url = "sqlite:" + file**.
1. [The explicit or default URI selects SQLite](text.starts_with(text=`url`, prefix="sqlite:"))
We **file = [Read the selected SQLite path](text.replace(text=`url`, old="sqlite:", new="", count=1))** and **file = [Apply the native file-root policy](fs.resolve(path=`file`))** and **url = "sqlite:" + file**.
We **store = [Open the selected actual database resource](data.db(url=`url`))** and **fields = [Read the documented article schema](articles.schema())**.
We **[Ensure the table without clearing it](> `store`.init name="articles" fields=`fields`)** and **existing = [Check whether business records already exist](> `store`.select table="articles" limit=1)**.
1. not `existing`
We **seed = [Read the original demonstration data](articles.seed())** and **[Seed only the empty article table](> `store`.insert table="articles" rows=`seed`)**.
Once the selected database is ready, return *store* for the site's resource bindings.