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

+29
View File
@@ -0,0 +1,29 @@
---
markup: occlusion
title: Room page components
import:
component: ext/web/component/index.mq.md
table: lib/table.mq.md
fs: lib/fs.mq.md
---
The parent contains an introduction and one log control. Ordinary copy lives in intro.md; the control keeps only its event target and plain initial text. Content has no transport setup, server lifetime or generated HTML.
## nodes
| 返回 | 类型 | 说明 |
|---|---|---|
| result | list | Ordered introduction and log control rows |
The introduction is a terminal Markdown content block and is read within the granted site root. The event log is a preformatted native leaf with id log; incoming client messages may replace its text without changing the layout. Attribute values remain typed data until rendering, and initial text is escaped. These two independent responsibilities are merged in reading order, without a string of raw HTML or a second layout schema.
We **intro = [Read the terminal Markdown content](fs.read_text(path="intro.md"))** and **overview = [Describe the introduction as Markdown](component.markdown(text=`intro`, slot="intro"))**.
`attributes` =
| id | aria-live |
|---|---|
| log | polite |
We **log = [Describe the independent event log](component.element(kind="pre", value="Connect a client to /chat/lobby.", attrs=`attributes`, slot="log"))**.
Return *[Keep introduction and event log in reading order](table.concat(a=`overview`, b=`log`))*.
+33 -7
View File
@@ -1,14 +1,40 @@
---
markup: occlusion
title: web-ws-room demo
description: Dynamic room WS with presence (G-WS1/2 bag). Open / and connect via bridge or wscat.
type: web
view: main
route: /
title: Room transport composed from Documents and Resources
import:
web: ext/web/web.mq.md
socket: ext/net/websocket.mq.md
home: home.mq.md
---
# main
This local demonstration serves a Markdown introduction and a native log control. The page is a Document; the room transport is an explicitly bound network resource. From the checkout root, call serve with --effects plugin,fs.read,network.write and --fs-root examples/web-ws-room. It blocks until the supervising process stops it. Connect a WebSocket client to /chat/lobby to join chat.room.lobby; presence uses the same native room protocol as other transports. This loopback-only example explicitly permits anonymous room access; a deployed site should attach authentication and retain the default private route policy.
**page = > web.page title="WS room" intro="<p class='lede'>Chat room <code>lobby</code> via <code>/chat/lobby</code>. Presence joins <code>chat.room.lobby.presence</code>.</p><pre id='log'></pre>"**
**app = > web.app page=`page` host="127.0.0.1" port=18091 admin=False**
**app = > `app`.route_ws path="/chat/{id}" mode="room" room_key="chat.room.{id}" presence=True**
> `app`.listen
## main
| 返回 | 类型 | 说明 |
|---|---|---|
| result | list | The homepage View rows, without starting a server |
The Document's main function only assembles content. The introduction remains a Markdown leaf and the event log is one native control with a stable id. The parent keeps those responsibilities as separate nodes, so changing the transport does not require rewriting the page as HTML. The View renderer receives structured values, and reading the content requires the granted site root.
After selecting the homepage components, return *[Assemble the readable room page](home.nodes())*.
## serve
| 参数 | 类型 | 默认 | 说明 |
|---|---|---|---|
| root | text | "examples/web-ws-room" | Explicit site directory relative to the current working directory |
| port | number | 18091 | Loopback server port |
| 返回 | 类型 | 说明 |
|---|---|---|
| result | map | Blocking listener result for the declared page and room route |
Use `root`="examples/web-ws-room" and `port`=18091 from the checkout root. Preparing the site performs Document discovery and one startup assembly before any socket opens. Then the network resource binds /chat/{id} using the chat.room.{id} room template and publishes presence messages. This intentionally public local demo sets require_auth=False; it is not a recommendation to expose anonymous production rooms. Keep each returned app value because binding updates are immutable. The final listener retains the original site root for callbacks and resources.
We **app = [Discover the site's Documents and Endpoints](web.prepare(root=`root`, host="127.0.0.1", port=`port`))**.
We **app = [Bind the room and its presence channel](socket.route(app=`app`, path="/chat/{id}", mode="room", room_key="chat.room.{id}", presence=True, require_auth=False))**.
After all bindings are ready, return *[Listen with the complete site resources](web.listen(app=`app`))*.
+5
View File
@@ -0,0 +1,5 @@
# WebSocket room
Join **lobby** through `/chat/lobby`. Messages are shared in `chat.room.lobby`; the native presence channel announces participants.
Open two controlled clients to observe room messages and presence. This demonstration listens only on the local host and explicitly permits anonymous room access.