Release 2.7.0: executable handbooks and native user-site workflows
This commit is contained in:
1 parent
aa0c4d0f55
commit
d9aef957f7
562 files changed
+21064
-20387
No files matched your search
@@ -1,27 +1,32 @@
|
||||
---
|
||||
markup: occlusion
|
||||
title: 文章结构与种子调用手册
|
||||
import:
|
||||
document: lib/document.mq.md
|
||||
---
|
||||
|
||||
本文件解释各个调用的用途;相邻的 [articles.tables.md](articles.tables.md) 保存可直接阅读的字面表。把 --fs-root 指向站点目录,读取需要 fs.read。字段、样式与正文是数据,读取不会执行文件中的说明。
|
||||
|
||||
## 结构
|
||||
|
||||
`字段` =
|
||||
| 返回 | 类型 | 说明 |
|
||||
|---|---|---|
|
||||
| result | any | 原生字面表的原始类型与列式数据形态 |
|
||||
|
||||
| 字段 | 类型 | 可空 |
|
||||
|------|------|------|
|
||||
| id | integer | false |
|
||||
| title | text | false |
|
||||
| body | text | true |
|
||||
声明文章的字段、原生类型与可空约束;id 的数值类型和必填字段保持不变。数据库初始化器使用此表保证结构,不负责猜测用户数据的迁移。
|
||||
|
||||
*`字段`*
|
||||
授予站点文件根的 fs.read 后可独立调用。章节名精确匹配且必须唯一;表头、行列不齐或动态表达式会保留原生文档诊断。需要实际样式时再调用 css;需要数据库记录时交给数据库资源。返回值不是 HTML,也不是已应用的浏览器效果。
|
||||
|
||||
完成后返回*[读取 结构 的实际字面表](document.read_table(path="db/articles.tables.md", title="结构"))*.
|
||||
|
||||
## 种子
|
||||
|
||||
`行` =
|
||||
| 返回 | 类型 | 说明 |
|
||||
|---|---|---|
|
||||
| result | any | 原生字面表的原始类型与列式数据形态 |
|
||||
|
||||
| id | title | body |
|
||||
|----|-------|------|
|
||||
| 1 | 欢迎来到网络扩展站 | 首页列表来自 SQLite。 |
|
||||
| 2 | 登录门禁后台 | /admin 页面需要 session 会话。 |
|
||||
| 3 | WebSocket 实时 | /live 端点会把你的消息实时回显。 |
|
||||
提供起始演示文章,保留原来的 id、短链、摘要与正文。只有数据库初始化器确认空表后才应插入;读取本函数不会写入或重置现有文章。
|
||||
|
||||
*`行`*
|
||||
授予站点文件根的 fs.read 后可独立调用。章节名精确匹配且必须唯一;表头、行列不齐或动态表达式会保留原生文档诊断。需要实际样式时再调用 css;需要数据库记录时交给数据库资源。返回值不是 HTML,也不是已应用的浏览器效果。
|
||||
|
||||
完成后返回*[读取 种子 的实际字面表](document.read_table(path="db/articles.tables.md", title="种子"))*.
|
||||
@@ -0,0 +1,23 @@
|
||||
# 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.
|
||||
|
||||
## 结构
|
||||
|
||||
Field definitions for the native database initializer; nullable values remain booleans.
|
||||
|
||||
| 字段 | 类型 | 可空 |
|
||||
|------|------|------|
|
||||
| id | integer | false |
|
||||
| title | text | false |
|
||||
| body | text | true |
|
||||
|
||||
## 种子
|
||||
|
||||
Initial demonstration records in their original column-oriented shape; ids and stable slugs retain their meaning.
|
||||
|
||||
| id | title | body |
|
||||
|----|-------|------|
|
||||
| 1 | 欢迎来到网络扩展站 | 首页列表来自 SQLite。 |
|
||||
| 2 | 登录门禁后台 | /admin 页面需要 session 会话。 |
|
||||
| 3 | WebSocket 实时 | /live 端点会把你的消息实时回显。 |
|
||||
@@ -1,21 +1,37 @@
|
||||
---
|
||||
markup: occlusion
|
||||
title: db/index
|
||||
description: 打开 sqlite、建表、幂等种子。
|
||||
导入:
|
||||
网页: ext/web/网页.mq.md
|
||||
title: web-net-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.
|
||||
|
||||
## 打开
|
||||
|
||||
**store = > 网页.数据库 地址="sqlite:data/site-net-zh.db"**
|
||||
**字段 = > articles.结构**
|
||||
> `store`.初始化 名=articles 字段=`字段`
|
||||
**行 = > store.查询 表="articles" 上限=1**
|
||||
1. `行`
|
||||
*store*
|
||||
2. *
|
||||
**种子 = > articles.种子**
|
||||
> `store`.插入 表=articles 行=`种子`
|
||||
*store*
|
||||
| 参数 | 类型 | 默认 | 说明 |
|
||||
|---|---|---|---|
|
||||
| url | any | None | None selects data/site-net-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-net-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.结构())**.
|
||||
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.种子())** 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.
|
||||
Reference in new issue
Block a user