Rewrite ext/web around tables and class methods.
Drop bag/scaffold glue and rebuild the web plugin for compose, SQLite CRUD, and listen, with call_lib_path support and a §4 English site sample. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
1 parent
8041a2274c
commit
9599303c4c
38 files changed
+2772
-4658
No files matched your search
@@ -1,65 +0,0 @@
|
||||
---
|
||||
title: web demo
|
||||
> ext/web/web.mq.md
|
||||
---
|
||||
|
||||
# main
|
||||
|
||||
> web.ensure_plugin
|
||||
|
||||
`nav` =
|
||||
|
||||
| 前端变量 | 后端数据库 | 绑定css样式 |
|
||||
|----------|------------|-------------|
|
||||
| 首页 | / | |
|
||||
| 管理 | /admin | |
|
||||
|
||||
`side` =
|
||||
|
||||
| 前端变量 | 后端数据库 | 绑定css样式 |
|
||||
|----------|------------|-------------|
|
||||
| 全部文章 | / | |
|
||||
| 管理后台 | /admin | |
|
||||
|
||||
`foot` =
|
||||
|
||||
| 前端变量 | 后端数据库 | 绑定css样式 |
|
||||
|----------|------------|-------------|
|
||||
| Marqdo | https://github.com/cflmy/marqdo | |
|
||||
|
||||
`articles` =
|
||||
|
||||
| 字段 | 类型 | 可空 |
|
||||
|------|------|------|
|
||||
| id | integer | false |
|
||||
| title | text | false |
|
||||
| body | text | true |
|
||||
|
||||
`主体` =
|
||||
|
||||
| 前端变量 | 后端数据库 | 绑定css样式 |
|
||||
|----------|------------|-------------|
|
||||
| title | title | card-title |
|
||||
| body | body | card-body |
|
||||
|
||||
`种子` =
|
||||
|
||||
| @ | title | body |
|
||||
|---|-------|------|
|
||||
| 1 | hello | first-row |
|
||||
| 2 | second | card-body |
|
||||
|
||||
*`db` = > web.db url="sqlite:./data/web-demo.db" *
|
||||
*`articles` = > `db`.init name=articles fields=`articles` *
|
||||
> `db`.insert table=`articles` rows=`种子`
|
||||
|
||||
*`page` = > web.page title=Demo *
|
||||
*`page` = > `page`.nav table=`nav` *
|
||||
*`page` = > `page`.sidebar table=`side` *
|
||||
*`page` = > `page`.footer table=`foot` *
|
||||
*`page` = > `page`.main table=`articles` bind=`主体` layout=cards intro="<h1>Marqdo Web</h1><p>变量名即表名:articles;页面先创建再挂 nav / main。</p>" *
|
||||
|
||||
*`app` = > web.app page=`page` db=`db` admin=True host=127.0.0.1 port=18080 *
|
||||
> `app`.static dir=ext/web/templates/starter/static
|
||||
> print text=listening
|
||||
> `app`.listen
|
||||
@@ -0,0 +1,10 @@
|
||||
# examples/web-site
|
||||
|
||||
Canonical English sample for `ext/web` (design §4).
|
||||
|
||||
```bash
|
||||
cargo build -p marqdo_plugin_web
|
||||
cargo run -- examples/web-site/index.mq.md
|
||||
```
|
||||
|
||||
Then open http://127.0.0.1:18081/ (admin at `/admin`).
|
||||
@@ -0,0 +1,9 @@
|
||||
## foot
|
||||
|
||||
`foot` =
|
||||
|
||||
| 属性 | 值 | 样式 |
|
||||
|------|-----|------|
|
||||
| Marqdo | https://github.com | |
|
||||
|
||||
**`foot`**
|
||||
@@ -0,0 +1,13 @@
|
||||
## nav
|
||||
|
||||
Static top links for the shell.
|
||||
|
||||
`nav` =
|
||||
|
||||
| 属性 | 值 | 样式 |
|
||||
|------|-----|------|
|
||||
| Home | / | |
|
||||
| About | /about | |
|
||||
| Admin | /admin | |
|
||||
|
||||
**`nav`**
|
||||
@@ -0,0 +1,10 @@
|
||||
## side
|
||||
|
||||
`side` =
|
||||
|
||||
| 属性 | 值 | 样式 |
|
||||
|------|-----|------|
|
||||
| Notes | / | |
|
||||
| Docs | https://github.com | |
|
||||
|
||||
**`side`**
|
||||
@@ -0,0 +1,22 @@
|
||||
## schema
|
||||
|
||||
`fields` =
|
||||
|
||||
| 字段 | 类型 | 可空 |
|
||||
|------|------|------|
|
||||
| id | integer | false |
|
||||
| title | text | false |
|
||||
| body | text | true |
|
||||
|
||||
**`fields`**
|
||||
|
||||
## seed
|
||||
|
||||
`rows` =
|
||||
|
||||
| id | title | body |
|
||||
|----|-------|------|
|
||||
| 1 | Hello Marqdo | First article from a GFM table. |
|
||||
| 2 | Code as docs | The page table is the program. |
|
||||
|
||||
**`rows`**
|
||||
@@ -0,0 +1,20 @@
|
||||
---
|
||||
title: db/index
|
||||
description: Open sqlite, init articles, seed once.
|
||||
> ext/web/web.mq.md
|
||||
> articles.mq.md as articles
|
||||
> lib/fs.mq.md
|
||||
---
|
||||
|
||||
## open
|
||||
|
||||
*`store` = > web.db url="sqlite:data/site.db" *
|
||||
*`fields` = > articles.schema *
|
||||
> `store`.init name=articles fields=`fields`
|
||||
*`rows` = > `store`.select table=articles limit=1 *
|
||||
1. `rows`
|
||||
**`store`**
|
||||
2. *
|
||||
*`seed` = > articles.seed *
|
||||
> `store`.insert table=articles rows=`seed`
|
||||
**`store`**
|
||||
@@ -0,0 +1,37 @@
|
||||
---
|
||||
title: web-site
|
||||
description: Home = page table; main inline; class methods assemble.
|
||||
> ext/web/web.mq.md
|
||||
> styles/shell.mq.md
|
||||
> components/nav.mq.md
|
||||
> components/side.mq.md
|
||||
> components/foot.mq.md
|
||||
> db/articles.mq.md
|
||||
> db/index.mq.md as db
|
||||
---
|
||||
|
||||
# main
|
||||
|
||||
`home` =
|
||||
|
||||
| 组件 | 样式 |
|
||||
|------|------|
|
||||
| nav.`nav` | shell.`topnav` |
|
||||
| side.`side` | shell.`side_panel` |
|
||||
| foot.`foot` | |
|
||||
|
||||
Main content is not a reusable component, so it is authored here.
|
||||
|
||||
`index` =
|
||||
|
||||
| 属性 | 值 | 样式 |
|
||||
|------|-----|------|
|
||||
| `title` | articles.`articles`.title | shell.`card_title` |
|
||||
| `body` | articles.`articles`.body | shell.`card_body` |
|
||||
|
||||
*`store` = > db.open *
|
||||
*`page` = > web.page title="Marqdo Web Site" intro="<h1>Web Site</h1><p>Tables + class methods.</p>" *
|
||||
*`page` = > `page`.compose_components components=`home` *
|
||||
*`page` = > `page`.compose_main main=`index` *
|
||||
*`app` = > web.app page=`page` db=`store` admin=True host=127.0.0.1 port=18081 *
|
||||
> `app`.listen
|
||||
@@ -0,0 +1,42 @@
|
||||
## topnav
|
||||
|
||||
`topnav` =
|
||||
|
||||
| 属性 | 值 |
|
||||
|------|-----|
|
||||
| background | #ffffff |
|
||||
| border-bottom | 1px solid #e7e5e4 |
|
||||
|
||||
**`topnav`**
|
||||
|
||||
## side_panel
|
||||
|
||||
`side_panel` =
|
||||
|
||||
| 属性 | 值 |
|
||||
|------|-----|
|
||||
| background | #f5f5f4 |
|
||||
|
||||
**`side_panel`**
|
||||
|
||||
## card_title
|
||||
|
||||
`card_title` =
|
||||
|
||||
| 属性 | 值 |
|
||||
|------|-----|
|
||||
| font-size | 1.15rem |
|
||||
| margin | 0 0 0.35rem |
|
||||
|
||||
**`card_title`**
|
||||
|
||||
## card_body
|
||||
|
||||
`card_body` =
|
||||
|
||||
| 属性 | 值 |
|
||||
|------|-----|
|
||||
| color | #57534e |
|
||||
| margin | 0 |
|
||||
|
||||
**`card_body`**
|
||||
Reference in new issue
Block a user