Add marqdo-blog example with GFM-table style assembly
Introduce web_style ABI (样式装配) so themes are GFM style tables
(|选择器|属性|值|, optional |媒体| column for @media) assembled by
functions instead of hand-written CSS strings — 文档即代码. The new
examples/marqdo-blog shows a full blog: card grid, dynamic /post/{slug},
tag archive, WebSocket live widget, and session-gated admin CRUD, plus a
smoke test (15 checks) and README.
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
1 parent
7645dd4c1f
commit
da9fc75b1e
20 files changed
+1518
-93
No files matched your search
+55
-2
@@ -17,6 +17,19 @@ Load the ABI v2 `web` plugin once.
|
||||
> sys.exit code=1
|
||||
****
|
||||
|
||||
## make_style
|
||||
+ `name`=""
|
||||
+ `table`
|
||||
|
||||
Assemble a GFM style table into a CSS string. Two shapes are accepted:
|
||||
`|选择器|属性|值|` rule rows (arbitrary selectors; rows sharing a selector are
|
||||
merged, and a leading `|媒体|` column groups rows into `@media` blocks), or
|
||||
`|属性|值|` property rows wrapped as `.name { … }`. Styles stay as data tables,
|
||||
`make_style` turns them into CSS — 样式即数据、装配即函数.
|
||||
|
||||
> ensure_plugin
|
||||
**> web_style name=`name` table=`table`**
|
||||
|
||||
# page
|
||||
+ `title`="Marqdo Web"
|
||||
+ `intro`=""
|
||||
@@ -38,6 +51,45 @@ Assemble main from a bind table (`|属性|值|样式|` or `|front|back|css|`).
|
||||
|
||||
**> web_compose_main page=`self` main=`main`**
|
||||
|
||||
## query
|
||||
+ `query`
|
||||
|
||||
Attach a DB where-condition map for the main bind. Values may contain `{param}`
|
||||
placeholders that are resolved from dynamic-route params (e.g. `/post/{slug}`).
|
||||
|
||||
**> web_page_query page=`self` query=`query`**
|
||||
|
||||
## order
|
||||
+ `order`
|
||||
|
||||
Set a default `ORDER BY` for the main bind (e.g. `-created_at` for newest first).
|
||||
|
||||
**> web_page_order page=`self` order=`order`**
|
||||
|
||||
## link_prefix
|
||||
+ `prefix`
|
||||
|
||||
Prefix for card links in the main bind (default `/post/`). Cards whose bind has
|
||||
an `href`/`链接` field become `<a href="{prefix}{href}">`.
|
||||
|
||||
**> web_page_link_prefix page=`self` prefix=`prefix`**
|
||||
|
||||
## css
|
||||
+ `css`
|
||||
|
||||
Append a raw CSS string to the page's stylesheet (`styles_css`). Use it to ship
|
||||
a hand-written theme alongside the assembled shell.
|
||||
|
||||
**> web_page_css page=`self` css=`css`**
|
||||
|
||||
## detail
|
||||
+ `detail`=True
|
||||
|
||||
Render the main bind's first row as a full article (title/meta/tags/body) instead
|
||||
of a list of cards. Set on the dynamic post page so `/post/{slug}` shows one post.
|
||||
|
||||
**> web_page_detail page=`self` detail=`detail`**
|
||||
|
||||
## compose_form
|
||||
+ `form`
|
||||
+ `id`
|
||||
@@ -95,11 +147,12 @@ Style tables live as `##` exports in site style modules; compose resolves them b
|
||||
+ `table`
|
||||
+ `where`=None
|
||||
+ `limit`=200
|
||||
+ `order`=None
|
||||
|
||||
Simple filters: one-row map of column→value (AND `=`), or rows `|字段|操作|值|` (`=` `!=` `>` `>=` `<` `<=` `like`).
|
||||
Simple filters: one-row map of column→value (AND `=`), or rows `|字段|操作|值|` (`=` `!=` `>` `>=` `<` `<=` `like`). `order` is a column name with optional `-` prefix for descending (`"created_at"`, `"-created_at"`), comma-separated for multiple keys.
|
||||
|
||||
*url = self[^url]*
|
||||
*r = > web_db_select url=`url` table=`table` where=`where` limit=`limit`*
|
||||
**> web_db_select url=`url` table=`table` where=`where` limit=`limit` order=`order`**
|
||||
**r[^rows]**
|
||||
|
||||
## get
|
||||
|
||||
+50
-2
@@ -17,6 +17,18 @@ import sys:lib/sys.mq.md
|
||||
> sys.exit code=1
|
||||
****
|
||||
|
||||
## 样式装配
|
||||
+ `名`=""
|
||||
+ `表`
|
||||
|
||||
把 GFM 样式表装配成一段 CSS 文本。支持两种表形:
|
||||
`|选择器|属性|值|` 规则行(选择器任意,同一选择器多行合并成一条规则;
|
||||
加 `|媒体|` 列即可分组进 `@media` 块),或 `|属性|值|` 属性行(按 `.名 { … }` 包裹)。
|
||||
样式即数据、装配即函数 —— 主题模块据此把样式表拼成完整样式表。
|
||||
|
||||
> 确保插件
|
||||
**> web_style name=`名` table=`表`**
|
||||
|
||||
# 页面
|
||||
+ `标题`="站点"
|
||||
+ `引言`=""
|
||||
@@ -34,6 +46,41 @@ import sys:lib/sys.mq.md
|
||||
|
||||
**> web_compose_main page=`self` main=`主体`**
|
||||
|
||||
## 查询条件
|
||||
+ `条件`
|
||||
|
||||
为主主体绑定附加 DB 条件映射。值可含 `{参数}` 占位符,由动态路由参数替换(如 `/post/{slug}`)。
|
||||
|
||||
**> web_page_query page=`self` query=`条件`**
|
||||
|
||||
## 排序
|
||||
+ `排序`
|
||||
|
||||
设置主主体绑定的默认 `ORDER BY`(如 `-created_at` 表示最新在前)。
|
||||
|
||||
**> web_page_order page=`self` order=`排序`**
|
||||
|
||||
## 链接前缀
|
||||
+ `前缀`
|
||||
|
||||
卡片链接前缀(默认 `/post/`)。主体绑定中含 `链接`/`href` 字段时,卡片标题会包成 `<a href="{前缀}{值}">`。
|
||||
|
||||
**> web_page_link_prefix page=`self` prefix=`前缀`**
|
||||
|
||||
## 样式
|
||||
+ `样式`
|
||||
|
||||
把一段手写 CSS 字符串追加到页面样式表(`styles_css`),用于在装配好的外壳上叠加自定义主题。
|
||||
|
||||
**> web_page_css page=`self` css=`样式`**
|
||||
|
||||
## 详情
|
||||
+ `详情`=True
|
||||
|
||||
把主体绑定的首行渲染成完整文章(标题/日期/标签/正文)而非卡片列表。用于动态文章页 `/post/{slug}`。
|
||||
|
||||
**> web_page_detail page=`self` detail=`详情`**
|
||||
|
||||
## 表单装配
|
||||
+ `表单`
|
||||
+ `id`
|
||||
@@ -87,11 +134,12 @@ import sys:lib/sys.mq.md
|
||||
+ `表`
|
||||
+ `条件`=None
|
||||
+ `上限`=200
|
||||
+ `排序`=None
|
||||
|
||||
简单条件:单行列→值映射(AND `=`),或 `|字段|操作|值|` 表(`=` `!=` `>` `>=` `<` `<=` `like`)。
|
||||
简单条件:单行列→值映射(AND `=`),或 `|字段|操作|值|` 表(`=` `!=` `>` `>=` `<` `<=` `like`)。`排序` 是列名,`-` 前缀表示倒序(`"created_at"`、`"-created_at"`),可逗号分隔多列。
|
||||
|
||||
*url = self[^url]*
|
||||
*r = > web_db_select url=`url` table=`表` where=`条件` limit=`上限`*
|
||||
*r = > web_db_select url=`url` table=`表` where=`条件` limit=`上限` order=`排序`*
|
||||
**r[^rows]**
|
||||
|
||||
## 获取
|
||||
|
||||
Reference in new issue
Block a user