Files
marqdo/examples/web-site/index.mq.md
T
cflmy 9331af78e2 release(2.8.0): 合入 CHANGELOG/README/发版说明/skills prove 任务;CI 链接指向 doc/releases
- CHANGELOG.md:v2.8.0 条目(中英双语);
- README.md:版本行 2.7.1→2.8.0 + 愿景第 6 条(知识可证明);
- doc/releases/v2.8.0.md:双语发版说明(亮点/用法/已知限制);
- skills/marqdo-dev/index.mq.md:新增 prove 任务(路径/目录模式/
  require_lean/json;参数用 + 行声明升参,check 与 narrative-ratio 通过);
- 设计文档 §12.5 标记已合入;发版链接统一指向 doc/releases/v2.8.0.md。
2026-11-18 10:29:26 +08:00

4.2 KiB
Executable File

markup, type, view, route, title, import
markup type view route title import
occlusion web main / Marqdo Web Site
layout intro articles database forms theme web form auth fs table
components/index.mq.md components/intro.mq.md components/articles.mq.md db/index.mq.md forms.mq.md styles/index.mq.md ext/web/web.mq.md ext/data/form.mq.md ext/security/auth.mq.md lib/fs.mq.md lib/table.mq.md

This entry is the executable site handbook. Follow components/index for public and administration geometry, then Markdown leaves, current article resources, the form and database. Five declared Documents retain Home, About, New, Admin and slug detail. Session navigation and server access policy remain separate; the custom desk does not enable the unrelated native administration landing page.

main

返回 类型 说明
result list Public frame containing the readable introduction and current article cards

Startup assembly reads terminal Markdown and constructs a typed query, without querying or initializing a database. The retained application resource supplies current articles at request time. Shared layout preserves navigation, side rail, footer, SEO, fonts and the compiled literary theme. Follow each imported responsibility rather than rebuilding the complete page here.

We introduction = Read the terminal home introduction and cards = Describe the current article cards and body = [Keep the introduction before the records](table.concat(a=introduction, b=cards)). Return [Place home inside the shared public frame](layout.frame(body=body, homepage=True)).

serve

参数 类型 默认 说明
root text "examples/web-site" Explicit site discovery directory from the checkout
port number 18081 Loopback demonstration port
url any None None uses retained site-root SQLite; tests supply an owned URI
返回 类型 说明
result map Blocking listener after real data, form, authentication and desk policy bindings

Use root="examples/web-site", port=18081 and url=None from the checkout with --fs-root examples/web-site and plugin,fs.write,network.write. Database initialization preserves existing rows and seeds only an empty table. The original declaration leaves remain unchanged; styles/index projects their selectors onto the recursive View layout and restores the named style properties previously attached by removed compose APIs.

Theme output is explicitly generated under public/generated before discovery. Preparation reads declared Documents but opens no listener. Mount the same public article form used by New and the desk, attach local fixture authentication, and protect the actual /admin path before listening. Keep every returned application. The admin/demo credentials are local demonstration data; replace the user store and network policy for a real deployment. Shutdown belongs to the supervising caller, not a hidden background process.

We store = Initialize the retained article database and css = Compile the actual View theme projection and Create only the explicit generated resource directory and [Write the compiled theme through native IO](fs.atomic_write(path="public/generated/theme.css", text=css)). We app = [Discover the five declared site Documents](web.prepare(root=root, host="127.0.0.1", port=port, db=store, static_dir="public")) and article = Construct one shared server-validation resource and app = [Mount the public article submission explicitly](form.mount(app=app, id="article", form=article)).

users =

@ username password role
1 admin demo admin

We app = [Attach native login sessions](auth.attach(app=app, users=users, login_path="/login", login_redirect="/admin", logout_redirect="/")) and app = [Protect direct requests to the custom desk](auth.gate(app=app, path="/admin", roles="admin", match="prefix", on_deny="redirect", exclude="/login")). Return Listen after actual resources and policy are ready.