refactor: prefer link-index get across examples and tests

Migrate remaining footnote-style collection access in examples,
public/structure, and ext/lib smokes to [key](base); teach link-index in
structure pages and use bracket calls in the cafe journal example.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
cflmyandCursor committed 2026-09-14 12:54:38 +08:00
1 parent 8d97adc1dc
commit abcb141737
75 files changed
+284 -281

No files matched your search

Binary file not shown.
+3 -3
View File
@@ -17,15 +17,15 @@ import demo:agent-mcp-server-helpers.mq.md
**srv = > agent.mcp_server name="marqdo-test"**
**srv = > `srv`.tool name="ping" fn="demo.ping" description="ping tool"**
**tools = srv[^tools]**
**tools = [tools](srv)**
**n = > len value=`tools`**
1. `n` == 1
> print text=mcp-tool-ok
2. *
> print text=mcp-tool-fail
**t0 = tools[^1]**
**fn = t0[^fn]**
**t0 = [1](tools)**
**fn = [fn](t0)**
1. `fn` == "demo.ping"
> print text=mcp-fn-ok
2. *
+3 -3
View File
@@ -38,8 +38,8 @@ $$
> print text=trace-fail
**`sol` = > la.solve a=`A` b=`b`**
**`x` = sol[^x]**
**`data` = x[^data]**
**`x` = [x](sol)**
**`data` = [data](x)**
**`row0` = > at value=`data` index=0**
**`x0` = > at value=`row0` index=0**
**`e0` = > math.sub a=`x0` b=2**
@@ -52,7 +52,7 @@ $$
**`I` = > la.eye n=2**
**`P` = > la.mul a=`A` b=`I`**
**`E` = > la.explicit expr=`P`**
**`ed` = E[^data]**
**`ed` = [data](E)**
**`ed0` = > at value=`ed` index=0**
**`ed00` = > at value=`ed0` index=0**
**`ee` = > math.sub a=`ed00` b=2**
+1 -1
View File
@@ -42,7 +42,7 @@ import la:ext/linalg/linalg.mq.md
> print text=`ct`
**`ping` = > la.ping**
**`ok` = ping[^ok]**
**`ok` = [ok](ping)**
1. `ok`
> print text=ping-ok
2. *
+2 -2
View File
@@ -28,8 +28,8 @@ Narration: \((AB)^\top = B^\top A^\top\). The identity is checked by running thi
| 2 | Y | 2 | 2 |
**`env` = > la.declare table=`shapes`**
**`X` = env[^X]**
**`Y` = env[^Y]**
**`X` = [X](env)**
**`Y` = [Y](env)**
**`S` = `X` + `Y`**
**`st` = > la.ascii expr=`S`**
1. `st` == "X + Y"
+7 -7
View File
@@ -16,13 +16,13 @@ $$
**`eps` = > math.div a=1 b=1000**
**`f` = > la.factorize matrix=`M` kind="eig"**
**`kind` = f[^kind]**
**`kind` = [kind](f)**
1. `kind` == eig
> print text=eig-kind-ok
2. *
> print text=eig-kind-fail
**`evals` = f[^eigenvalues]**
**`evals` = [eigenvalues](f)**
**`ev0` = > at value=`evals` index=0**
**`e0` = > math.sub a=`ev0` b=3**
**`e0` = > math.abs value=`e0`**
@@ -32,13 +32,13 @@ $$
> print text=eig-val-fail
**`img` = > la.draw factor=`f` kind="eig" path="linalg-factor-eig.svg"**
**`ik` = img[^kind]**
**`ik` = [kind](img)**
1. `ik` == eig
> print text=draw-kind-ok
2. *
> print text=draw-kind-fail
**`svg` = img[^svg]**
**`svg` = [svg](img)**
**`parts` = > split value=`svg` sep="data-linalg=\"eig\""**
**`pn` = > len value=`parts`**
1. `pn` > 1
@@ -60,8 +60,8 @@ $$
**`b` = > la.from_formula formula=`b`**
**`lu` = > la.factorize matrix=`A` kind="lu"**
**`sol` = > la.solve factor=`lu` b=`b`**
**`x` = sol[^x]**
**`data` = x[^data]**
**`x` = [x](sol)**
**`data` = [data](x)**
**`row0` = > at value=`data` index=0**
**`x0` = > at value=`row0` index=0**
**`xe` = > math.sub a=`x0` b=2**
@@ -72,7 +72,7 @@ $$
> print text=lu-solve-fail
**`svd` = > la.factorize matrix=`M` kind="svd"**
**`sk` = svd[^ascii]**
**`sk` = [ascii](svd)**
1. `sk` == SVD
> print text=svd-ok
2. *
+1 -1
View File
@@ -15,7 +15,7 @@ import la:ext/linalg/linalg.mq.md
> print text=`txt`
**`ping` = > la.ping**
**`ok` = ping[^ok]**
**`ok` = [ok](ping)**
1. `ok`
> print text=ping-ok
2. *
+2 -2
View File
@@ -17,7 +17,7 @@ import la:ext/linalg/linalg.mq.md
**`st` = > `Pt`.ascii**
> print text=`st`
**`ty` = C[^_type]**
**`ty` = [_type](C)**
1. `ty` == matrix
> print text=type-ok
2. *
@@ -35,7 +35,7 @@ $$
**`S` = `M` + `N`**
**`Se` = > la.explicit expr=`S`**
**`d` = Se[^data]**
**`d` = [data](Se)**
**`r0` = > at value=`d` index=0**
**`x00` = > at value=`r0` index=0**
**`xs` = > str value=`x00`**
+6 -6
View File
@@ -23,8 +23,8 @@ $$
**`eps` = > math.div a=1 b=1000**
**`ls` = > la.lstsq a=`A` b=`b`**
**`x` = ls[^x]**
**`xd` = x[^data]**
**`x` = [x](ls)**
**`xd` = [data](x)**
**`r0` = > at value=`xd` index=0**
**`x0` = > at value=`r0` index=0**
**`e0` = > math.sub a=`x0` b=1.1666666667**
@@ -49,7 +49,7 @@ $$
**`D` = > la.from_formula formula=`D`**
**`c` = > la.cond expr=`D`**
**`cv` = c[^value]**
**`cv` = [value](c)**
**`ce` = > math.sub a=`cv` b=2**
**`ce` = > math.abs value=`ce`**
1. `ce` < `eps`
@@ -65,7 +65,7 @@ $$
**`raw` = > json.parse text="[[[0,1],[1,0]],[[1,0],[0,-1]]]"**
**`Z` = > la.from_list data=`raw`**
**`dt` = Z[^dtype]**
**`dt` = [dtype](Z)**
1. `dt` == complex
> print text=complex-dtype-ok
2. *
@@ -80,13 +80,13 @@ $$
> print text=complex-norm-fail
**`img` = > la.draw factor=`D` kind="heatmap" theme="dark" path="linalg-metrics-heat.svg"**
**`th` = img[^theme]**
**`th` = [theme](img)**
1. `th` == dark
> print text=theme-ok
2. *
> print text=theme-fail
**`svg` = img[^svg]**
**`svg` = [svg](img)**
**`parts` = > split value=`svg` sep="data-theme=\"dark\""**
**`pn` = > len value=`parts`**
1. `pn` > 1
+1 -1
View File
@@ -15,7 +15,7 @@ import la:ext/linalg/线性代数.mq.md
> 打印 内容=`txt`
**`ping` = > la.探测**
**`ok` = ping[^ok]**
**`ok` = [ok](ping)**
1. `ok`
> 打印 内容=探测-ok
2. *
+2 -2
View File
@@ -7,5 +7,5 @@ import llm:ext/ai/llm.mq.md
# main
**model = > llm.llm**
> print text=`model`[^model]
> print text=`model`[^suffix]
> print text=[model](`model`)
> print text=[suffix](`model`)
+1 -1
View File
@@ -10,7 +10,7 @@ import quantum:ext/quantum/quantum.mq.md
**qc = > `qc`.x qubit=0**
**qc = > `qc`.noise kind="amplitude_damping" p=1**
**r = > `qc`.run shots=32 seed=7**
**c0 = r[^counts][^0]**
**c0 = [0]([counts](r))**
1. `c0` == 32
> print text=amp-ok
+1 -1
View File
@@ -10,7 +10,7 @@ description: 泡利X 后 振幅阻尼 p=1 全部落回 |0⟩.
**qc = > `qc`.泡利X 比特=0**
**qc = > `qc`.噪声 种类="振幅阻尼" 概率=1**
**r = > `qc`.运行 次数=32 种子=7**
**c0 = r[^counts][^0]**
**c0 = [0]([counts](r))**
1. `c0` == 32
> print text=amp-ok
+3 -3
View File
@@ -13,14 +13,14 @@ import quantum:ext/quantum/quantum.mq.md
**qc = > `qc`.measure**
**st = > `qc`.state**
**dim = st[^dim]**
**dim = [dim](st)**
1. `dim` == 4
> print text=state-ok
2. *
> print text=state-fail
**img = > `qc`.draw path="quantum-author-draw.svg"**
**kind = img[^kind]**
**kind = [kind](img)**
1. `kind` == circuit
> print text=draw-ok
2. *
@@ -29,7 +29,7 @@ import quantum:ext/quantum/quantum.mq.md
**other = > quantum.circuit qubits=2**
**other = > `other`.x qubit=1**
**qc2 = > `qc`.append op=`other`**
**ops = qc2[^ops]**
**ops = [ops](qc2)**
**n = > len `ops`**
1. `n` == 5
> print text=append-ok
+3 -3
View File
@@ -13,14 +13,14 @@ description: 屏障 / 测量 / 追加 / 态 / 绘图.
**qc = > `qc`.测量**
**st = > `qc`.态**
**dim = st[^dim]**
**dim = [dim](st)**
1. `dim` == 4
> print text=state-ok
2. *
> print text=state-fail
**img = > `qc`.绘图 路径="quantum-author-zh-draw.svg"**
**kind = img[^kind]**
**kind = [kind](img)**
1. `kind` == circuit
> print text=draw-ok
2. *
@@ -29,7 +29,7 @@ description: 屏障 / 测量 / 追加 / 态 / 绘图.
**other = > 量子.电路 比特数=2**
**other = > `other`.泡利X 比特=1**
**qc2 = > `qc`.追加 操作=`other`**
**ops = qc2[^ops]**
**ops = [ops](qc2)**
**n = > len `ops`**
1. `n` == 5
> print text=append-ok
+3 -3
View File
@@ -12,8 +12,8 @@ import math:lib/math.mq.md
**qc = > `qc`.cx control=0 target=1**
**p = > `qc`.probabilities**
**p00 = p[^00]**
**p11 = p[^11]**
**p00 = [00](p)**
**p11 = [11](p)**
**lo = > math.div a=2 b=5**
**hi = > math.div a=3 b=5**
@@ -34,7 +34,7 @@ import math:lib/math.mq.md
> print text=p11-fail
**ping = > quantum_ping**
**ok = ping[^ok]**
**ok = [ok](ping)**
1. `ok`
> print text=ping-ok
2. *
+1 -1
View File
@@ -16,7 +16,7 @@ $$
**qc = > quantum.circuit qubits=1**
**qc = > `qc`.apply gate=`U` qubits=0**
**p = > `qc`.probabilities**
**p0 = p[^0]**
**p0 = [0](p)**
**lo = > math.div a=4 b=10**
**hi = > math.div a=6 b=10**
+1 -1
View File
@@ -16,7 +16,7 @@ $$
**qc = > 量子.电路 比特数=1**
**qc = > `qc`.施加 门=`U` 比特=0**
**p = > `qc`.概率**
**p0 = p[^0]**
**p0 = [0](p)**
**lo = > math.div a=4 b=10**
**hi = > math.div a=6 b=10**
+2 -2
View File
@@ -15,7 +15,7 @@ import quantum:ext/quantum/quantum.mq.md
**qc = > quantum.circuit qubits=2 steps=`steps`**
**img = > `qc`.draw kind="probs" path="quantum-draw-probs.svg"**
**kind = img[^kind]**
**kind = [kind](img)**
1. `kind` == probs
> print text=probs-ok
@@ -25,7 +25,7 @@ import quantum:ext/quantum/quantum.mq.md
**qc1 = > quantum.circuit qubits=1**
**qc1 = > `qc1`.h qubit=0**
**bloch = > `qc1`.draw kind="bloch" path="quantum-draw-bloch.svg"**
**bk = bloch[^kind]**
**bk = [kind](bloch)**
1. `bk` == bloch
> print text=bloch-ok
+1 -1
View File
@@ -8,7 +8,7 @@ import quantum:ext/quantum/quantum.mq.md
**H = > quantum.gate name="H"**
**img = > `H`.draw kind="matrix" path="quantum-gate-heatmap.svg"**
**kind = img[^kind]**
**kind = [kind](img)**
1. `kind` == matrix
> print text=heatmap-ok
+6 -6
View File
@@ -14,7 +14,7 @@ H-Z-H on |0⟩ → |1⟩.
**qc = > `qc`.z qubit=0**
**qc = > `qc`.h qubit=0**
**p = > `qc`.probabilities**
**p1 = p[^1]**
**p1 = [1](p)**
**lo = > math.div a=9 b=10**
1. `p1` > `lo`
@@ -28,7 +28,7 @@ Ry(π) on |0⟩ → |1⟩.
**ry = > quantum.circuit qubits=1**
**ry = > `ry`.ry qubit=0 theta=`pi`**
**rp = > `ry`.probabilities**
**rp1 = rp[^1]**
**rp1 = [1](rp)**
1. `rp1` > `lo`
> print text=ry-ok
@@ -41,10 +41,10 @@ Bell run with fixed seed: both 00 and 11 appear; shots sum.
**bell = > `bell`.h qubit=0**
**bell = > `bell`.cx control=0 target=1**
**res = > `bell`.run shots=200 seed=42**
**counts = res[^counts]**
**c00 = counts[^00]**
**c11 = counts[^11]**
**shots = res[^shots]**
**counts = [counts](res)**
**c00 = [00](counts)**
**c11 = [11](counts)**
**shots = [shots](res)**
1. `c00`
1. `c11`
+1 -1
View File
@@ -40,7 +40,7 @@ import math:lib/math.mq.md
> print text=expect-fail
**sch = > `qc`.schmidt cut=1**
**ent = sch[^entropy]**
**ent = [entropy](sch)**
**elo = > math.div a=1 b=2**
1. `ent` > `elo`
> print text=schmidt-ok
+1 -1
View File
@@ -10,7 +10,7 @@ import quantum:ext/quantum/quantum.mq.md
**qc = > `qc`.i qubit=0**
**qc = > `qc`.noise kind="bitflip" p=1**
**r = > `qc`.run shots=32 seed=3**
**c1 = r[^counts][^1]**
**c1 = [1]([counts](r))**
1. `c1` == 32
> print text=noise-ok
+1 -1
View File
@@ -10,7 +10,7 @@ description: 噪声 bitflip p=1 后 I 使全部射中 |1⟩.
**qc = > `qc`.单位 比特=0**
**qc = > `qc`.噪声 种类="bitflip" 概率=1**
**r = > `qc`.运行 次数=32 种子=3**
**c1 = r[^counts][^1]**
**c1 = [1]([counts](r))**
1. `c1` == 32
> print text=noise-ok
+2 -2
View File
@@ -16,7 +16,7 @@ import math:lib/math.mq.md
**qc = > quantum.circuit qubits=2 steps=`steps`**
**p = > `qc`.probabilities**
**p00 = p[^00]**
**p00 = [00](p)**
**lo = > math.div a=2 b=5**
**hi = > math.div a=3 b=5**
@@ -29,7 +29,7 @@ import math:lib/math.mq.md
> print text=steps-fail
**img = > `qc`.draw path="quantum-steps-draw.svg"**
**kind = img[^kind]**
**kind = [kind](img)**
1. `kind` == circuit
> print text=draw-ok
+1 -1
View File
@@ -12,7 +12,7 @@ import math:lib/math.mq.md
**电路 = > `电路`.泡利Z 比特=0**
**电路 = > `电路`.哈达玛 比特=0**
**概率 = > `电路`.概率**
**p1 = 概率[^1]**
**p1 = [1](概率)**
**lo = > math.div a=9 b=10**
1. `p1` > `lo`
+3 -3
View File
@@ -24,15 +24,15 @@ import sys:lib/sys.mq.md
**page = > web.page title="Home"**
**page = > page.meta meta=`meta`**
**mm = page[^meta]**
**m = mm[^title]**
**mm = [meta](page)**
**m = [title](mm)**
1. `m` == "My Site"
> print text=meta-ok
2. *
> print text=meta-fail
**page = > page.paginate offset=0 limit=5 path="/"**
**poff = page[^paginate][^offset]**
**poff = [offset]([paginate](page))**
1. `poff` == 0
> print text=paginate-ok
2. *
+4 -4
View File
@@ -49,8 +49,8 @@ import json:lib/json.mq.md
> print text=count-where-fail
**page1 = > `store`.paginate table="posts" limit=2 跳过=0**
**total1 = page1[^total]**
**p1r = page1[^rows]**
**total1 = [total](page1)**
**p1r = [rows](page1)**
**n1 = > len value=`p1r`**
1. `total1` == 4
1. `n1` == 2
@@ -59,7 +59,7 @@ import json:lib/json.mq.md
> print text=page-fail
**page2 = > `store`.paginate table="posts" limit=2 跳过=2**
**p2r = page2[^rows]**
**p2r = [rows](page2)**
**n2 = > len value=`p2r`**
1. `n2` == 2
> print text=page2-ok
@@ -107,7 +107,7 @@ import json:lib/json.mq.md
> print text=or-fail
**agg = > `store`.query sql="SELECT title, views FROM posts WHERE views >= 30 ORDER BY views DESC"**
**nagg = agg[^count]**
**nagg = [count](agg)**
1. `nagg` == 2
> print text=query-ok
2. *
+6 -6
View File
@@ -15,7 +15,7 @@ import web:ext/web/web.mq.md
| 2 | CREATE TABLE IF NOT EXISTS comments (id INTEGER PRIMARY KEY AUTOINCREMENT, post_id INTEGER NOT NULL, body TEXT NOT NULL, status TEXT NOT NULL DEFAULT 'pending') |
**m1 = > `store`.migrate steps=`steps`**
**a1 = m1[^applied]**
**a1 = [applied](m1)**
**n1 = > len value=`a1`**
1. `n1` == 2
> print text=migrate-ok
@@ -23,7 +23,7 @@ import web:ext/web/web.mq.md
> print text=migrate-fail
**m2 = > `store`.migrate steps=`steps`**
**a2 = m2[^applied]**
**a2 = [applied](m2)**
**n2 = > len value=`a2`**
1. `n2` == 0
> print text=migrate-idempotent-ok
@@ -68,15 +68,15 @@ import web:ext/web/web.mq.md
> `store`.fts table="posts" columns="title,body"
**hit = > `store`.search table="posts" q="hello" limit=10**
**hn = hit[^count]**
**hn = [count](hit)**
1. `hn` >= 1
> print text=fts-ok
2. *
> print text=fts-fail
**rows2 = hit[^rows]**
**first = rows2[^1]**
**ft = first[^title]**
**rows2 = [rows](hit)**
**first = [1](rows2)**
**ft = [title](first)**
1. `ft`
> print text=fts-row-ok
2. *
+6 -6
View File
@@ -19,7 +19,7 @@ import sys:lib/sys.mq.md
**c = > web.cache url="memory:drivers-smoke"**
> `c`.set key="k1" value="v1" ttl=60
**g = > `c`.get key="k1"**
**gv = g[^value]**
**gv = [value](g)**
1. `gv` == "v1"
> print text=cache-ok
2. *
@@ -27,7 +27,7 @@ import sys:lib/sys.mq.md
> `c`.del key="k1"
**ex = > `c`.exists key="k1"**
**eok = ex[^ok]**
**eok = [ok](ex)**
1. `eok`
> print text=cache-del-fail
2. *
@@ -38,14 +38,14 @@ import sys:lib/sys.mq.md
**blob = > web.storage url="file:tests/ext/web-fixtures/data/drivers-blobs"**
> `blob`.put key="notes/a.txt" body="hello" content_type="text/plain"
**got = > `blob`.get key="notes/a.txt"**
**body = got[^body]**
**body = [body](got)**
1. `body` == "hello"
> print text=storage-ok
2. *
> print text=storage-fail
**ls = > `blob`.list prefix="notes/"**
**n = ls[^count]**
**n = [count](ls)**
1. `n` == 1
> print text=storage-list-ok
2. *
@@ -56,7 +56,7 @@ import sys:lib/sys.mq.md
<!-- db: postgres URL is accepted as a handle (no live server required) -->
**pg = > web.db url="postgres://marqdo:marqdo@127.0.0.1:5432/marqdo"**
**purl = pg[^url]**
**purl = [url](pg)**
1. `purl` == "postgres://marqdo:marqdo@127.0.0.1:5432/marqdo"
> print text=postgres-url-ok
2. *
@@ -65,7 +65,7 @@ import sys:lib/sys.mq.md
<!-- s3 URL shape validates at open -->
**s3 = > web.storage url="s3://bucket?endpoint=http://127.0.0.1:9000"**
**sb = s3[^backend]**
**sb = [backend](s3)**
1. `sb` == "s3"
> print text=s3-open-ok
2. *
+2 -2
View File
@@ -18,13 +18,13 @@ import plugin:lib/plugin.mq.md
| 0ae9134cca7eff9d756fbf52402ee28ae0c2be22f01e53653e4fe86021479703 | read,api |
**ok = > web_api_key_check key="smoke-secret" authorization="" pepper=`pepper` keys=`keys`**
1. ok[^ok]
1. [ok](ok)
> print text=api-key-ok
2. *
> print text=api-key-fail
**bad = > web_api_key_check key="wrong" authorization="" pepper=`pepper` keys=`keys`**
1. bad[^ok]
1. [ok](bad)
> print text=api-key-bad-ok
2. *
> print text=api-key-bad-fail
+1 -1
View File
@@ -12,7 +12,7 @@ Nested plugin call (`web.page`) while `app.listen` is the outer plugin frame —
must not clear GLOBAL_HOST so a second HTTP invoke still works.
**pg = > web.page title=`msg`**
**title = pg[^title]**
**title = [title](pg)**
`out` =
+22 -22
View File
@@ -50,33 +50,33 @@ import sys:lib/sys.mq.md
**app = > web.app page=`pg`**
**app = > `app`.configure cors=`cors` security=`sec` compress=True body_limit=1048576 json=`api`**
**mw = app[^middleware]**
**mw = [middleware](app)**
<!-- cors -->
**cobj = mw[^cors]**
**origins = cobj[^allow_origins]**
**o0 = origins[^1]**
**cobj = [cors](mw)**
**origins = [allow_origins](cobj)**
**o0 = [1](origins)**
1. `o0` == "https://a.example"
> print text=cors-origin-ok
2. *
> print text=cors-origin-fail
**methods = cobj[^methods]**
**m1 = methods[^2]**
**methods = [methods](cobj)**
**m1 = [2](methods)**
1. `m1` == "POST"
> print text=cors-method-ok
2. *
> print text=cors-method-fail
**expose = cobj[^expose_headers]**
**e0 = expose[^1]**
**expose = [expose_headers](cobj)**
**e0 = [1](expose)**
1. `e0` == "X-Total"
> print text=cors-expose-ok
2. *
> print text=cors-expose-fail
**cred = cobj[^credentials]**
**cred = [credentials](cobj)**
1. `cred`
> print text=cors-cred-ok
2. *
@@ -84,14 +84,14 @@ import sys:lib/sys.mq.md
<!-- security -->
**secmap = mw[^security]**
**frame = secmap[^X-Frame-Options]**
**secmap = [security](mw)**
**frame = [X-Frame-Options](secmap)**
1. `frame` == "DENY"
> print text=security-frame-ok
2. *
> print text=security-frame-fail
**csp = secmap[^Content-Security-Policy]**
**csp = [Content-Security-Policy](secmap)**
1. `csp` == "default-src 'self'"
> print text=security-csp-ok
2. *
@@ -99,13 +99,13 @@ import sys:lib/sys.mq.md
<!-- compress / body_limit -->
**comp = mw[^compress]**
**comp = [compress](mw)**
1. `comp`
> print text=compress-ok
2. *
> print text=compress-fail
**bl = mw[^body_limit]**
**bl = [body_limit](mw)**
1. `bl` == 1048576
> print text=body-limit-ok
2. *
@@ -113,34 +113,34 @@ import sys:lib/sys.mq.md
<!-- json routes -->
**jmap = mw[^json_routes]**
**posts = jmap[^api/posts]**
**pok = posts[^method]**
**jmap = [json_routes](mw)**
**posts = [api/posts](jmap)**
**pok = [method](posts)**
1. `pok` == "GET"
> print text=json-get-ok
2. *
> print text=json-get-fail
**ptable = posts[^table]**
**ptable = [table](posts)**
1. `ptable` == "articles"
> print text=json-table-ok
2. *
> print text=json-table-fail
**porder = posts[^order]**
**porder = [order](posts)**
1. `porder` == "-created_at"
> print text=json-order-ok
2. *
> print text=json-order-fail
**plimit = posts[^limit]**
**plimit = [limit](posts)**
1. `plimit` == 20
> print text=json-limit-ok
2. *
> print text=json-limit-fail
**pub = jmap[^api/publish]**
**pmethod = pub[^method]**
**pub = [api/publish](jmap)**
**pmethod = [method](pub)**
1. `pmethod` == "POST"
> print text=json-post-ok
2. *
+20 -20
View File
@@ -28,35 +28,35 @@ import sys:lib/sys.mq.md
<!-- session CRUD -->
**sess = > web_session_new ttl_sec=120**
**sid = sess[^id]**
**sid = [id](sess)**
1. `sid` != ""
> print text=session-new-ok
2. *
> print text=session-new-fail
**set1 = > web_session_set id=`sid` key="theme" value="dark"**
**ok1 = set1[^ok]**
**ok1 = [ok](set1)**
1. `ok1`
> print text=session-set-ok
2. *
> print text=session-set-fail
**get1 = > web_session_get id=`sid` key="theme"**
**v1 = get1[^value]**
**v1 = [value](get1)**
1. `v1` == "dark"
> print text=session-get-ok
2. *
> print text=session-get-fail
**del1 = > web_session_del id=`sid` key="theme"**
**ok2 = del1[^ok]**
**ok2 = [ok](del1)**
1. `ok2`
> print text=session-del-ok
2. *
> print text=session-del-fail
**get2 = > web_session_get id=`sid` key="theme"**
**ok3 = get2[^ok]**
**ok3 = [ok](get2)**
1. `ok3`
> print text=session-del-confirm-fail
2. *
@@ -65,43 +65,43 @@ import sys:lib/sys.mq.md
<!-- auth login/check/logout -->
**login = > web_auth_login username="admin" password="secret" users=`users` session_ttl=120**
**lok = login[^ok]**
**lok = [ok](login)**
1. `lok`
> print text=auth-login-ok
2. *
> print text=auth-login-fail
**sid2 = login[^session_id]**
**sid2 = [session_id](login)**
**check = > web_auth_check session_id=`sid2`**
**cok = check[^ok]**
**cok = [ok](check)**
1. `cok`
> print text=auth-check-ok
2. *
> print text=auth-check-fail
**badlogin = > web_auth_login username="admin" password="wrong" users=`users` session_ttl=120**
**bok = badlogin[^ok]**
**bok = [ok](badlogin)**
1. `bok`
> print text=auth-bad-should-fail
2. *
> print text=auth-bad-ok
**zhlogin = > web_auth_login username="站长" password="pw123" users=`users` session_ttl=120**
**zhok = zhlogin[^ok]**
**zhok = [ok](zhlogin)**
1. `zhok`
> print text=auth-zh-ok
2. *
> print text=auth-zh-fail
**logout = > web_auth_logout session_id=`sid2`**
**dok = logout[^ok]**
**dok = [ok](logout)**
1. `dok`
> print text=auth-logout-ok
2. *
> print text=auth-logout-fail
**check2 = > web_auth_check session_id=`sid2`**
**cok2 = check2[^ok]**
**cok2 = [ok](check2)**
1. `cok2`
> print text=auth-logout-confirm-fail
2. *
@@ -112,18 +112,18 @@ import sys:lib/sys.mq.md
**pg = > web.page title="ws-test"**
**app = > web.app page=`pg` admin=True**
**app = > `app`.route_ws path="/live" echo=True**
**routes = app[^ws_routes]**
**has_live = routes[^/live]**
**routes = [ws_routes](app)**
**has_live = [/live](routes)**
1. `has_live`
> print text=ws-route-ok
2. *
> print text=ws-route-fail
**app = > `app`.auth users=`users` session_ttl=120**
**authobj = app[^auth]**
**ausers = authobj[^users]**
**au1 = ausers[^1][^用户]**
**ou1 = users[^1][^用户]**
**authobj = [auth](app)**
**ausers = [users](authobj)**
**au1 = [用户]([1](ausers))**
**ou1 = [用户]([1](users))**
1. `au1` == `ou1`
> print text=app-auth-ok
2. *
@@ -133,7 +133,7 @@ import sys:lib/sys.mq.md
**authz = > web.auth users=`users` session_ttl=120**
**login2 = > `authz`.login username="admin" password="secret"**
**lok2 = login2[^ok]**
**lok2 = [ok](login2)**
1. `lok2`
> print text=ext-auth-ok
2. *
@@ -141,7 +141,7 @@ import sys:lib/sys.mq.md
**ws = > web.ws timeout_sec=1**
**badurl = > `ws`.connect url="ws://127.0.0.1:1" message="hi"**
**bwok = badurl[^ok]**
**bwok = [ok](badurl)**
1. `bwok`
> print text=ws-connect-should-fail
2. *
+7 -7
View File
@@ -48,7 +48,7 @@ import json:lib/json.mq.md
> `store`.insert table="posts" rows=`rows`
**got = > `store`.get table="posts" id=1**
**ca = got[^created_at]**
**ca = [created_at](got)**
1. `ca`
> print text=audit-insert-ok
2. *
@@ -57,14 +57,14 @@ import json:lib/json.mq.md
**upd = > json.parse text={"title":"Hello P3b"}**
> `store`.update table="posts" id=1 row=`upd`
**got2 = > `store`.get table="posts" id=1**
**ua2 = got2[^updated_at]**
**ua2 = [updated_at](got2)**
1. `ua2`
> print text=audit-update-ok
2. *
> print text=audit-update-fail
**fk = > `store`.query sql="SELECT sql FROM sqlite_master WHERE type='table' AND name='comments'"**
**fkddl = fk[^rows][^1][^sql]**
**fkddl = [sql]([1]([rows](fk)))**
1. `fkddl`
> print text=fk-ok
2. *
@@ -78,7 +78,7 @@ import json:lib/json.mq.md
| alice | secret | author |
**login = > web_auth_login username="alice" password="secret" users=`users` session_ttl=120**
**role = login[^role]**
**role = [role](login)**
1. `role` == "author"
> print text=rbac-login-ok
2. *
@@ -88,7 +88,7 @@ import json:lib/json.mq.md
**app = > web.app page=`pg` port=18130**
**app = > `app`.auth users=`users`**
**app = > `app`.gate path="/write*" roles="admin,author"**
**gates = app[^gates]**
**gates = [gates](app)**
**ng = > len value=`gates`**
1. `ng` >= 2
> print text=rbac-gate-ok
@@ -98,8 +98,8 @@ import json:lib/json.mq.md
**blob = > web.storage url="file:web-fixtures/data/p3-gallery"**
> `blob`.put key="uploads/a.txt" body="hi" content_type="text/plain"
**app = > `app`.gallery path="/gallery" storage=`blob` prefix="uploads/" title="Media" download_base="/_media"**
**gal = app[^gallery_routes]**
**g = gal[^/gallery]**
**gal = [gallery_routes](app)**
**g = [/gallery](gal)**
1. `g`
> print text=gallery-ok
2. *
+12 -12
View File
@@ -32,43 +32,43 @@ import sys:lib/sys.mq.md
**app = > `app`.proxy path="/v1/stream" upstream="https://example.com/v1/chat" stream=True headers_from_env="TOKEN=X-Token"**
**app = > `app`.invoke path="/api/ping" fn="demo.ping" method="GET" body="query"**
**proutes = app[^proxy_routes]**
**chat = proutes[^proxy/chat]**
**up = chat[^upstream]**
**proutes = [proxy_routes](app)**
**chat = [proxy/chat](proutes)**
**up = [upstream](chat)**
1. `up` == "$OPENAI_BASE_URL"
> print text=proxy-table-ok
2. *
> print text=proxy-table-fail
**stream = chat[^stream]**
**stream = [stream](chat)**
1. `stream`
> print text=proxy-stream-ok
2. *
> print text=proxy-stream-fail
**hdr = chat[^headers_from_env]**
**hdr = [headers_from_env](chat)**
1. `hdr` == "OPENAI_API_KEY=Authorization"
> print text=proxy-env-ok
2. *
> print text=proxy-env-fail
**v1 = proutes[^v1/stream]**
**v1u = v1[^upstream]**
**v1 = [v1/stream](proutes)**
**v1u = [upstream](v1)**
1. `v1u` == "https://example.com/v1/chat"
> print text=proxy-method-ok
2. *
> print text=proxy-method-fail
**iroutes = app[^invoke_routes]**
**echo = iroutes[^api/echo]**
**efn = echo[^fn]**
**iroutes = [invoke_routes](app)**
**echo = [api/echo](iroutes)**
**efn = [fn](echo)**
1. `efn` == "demo.echo"
> print text=invoke-table-ok
2. *
> print text=invoke-table-fail
**ping = iroutes[^api/ping]**
**pm = ping[^method]**
**ping = [api/ping](iroutes)**
**pm = [method](ping)**
1. `pm` == "GET"
> print text=invoke-method-ok
2. *
+3 -3
View File
@@ -19,7 +19,7 @@ import sys:lib/sys.mq.md
<!-- argon2 hash must be non-empty PHC string -->
**hash = > web_password_hash password="secret"**
**h = hash[^hash]**
**h = [hash](hash)**
1. `h` != ""
> print text=hash-ok
2. *
@@ -34,14 +34,14 @@ import sys:lib/sys.mq.md
| 1 | admin | secret |
**login = > web_auth_login username="admin" password="secret" users=`users` session_ttl=120**
**lok = login[^ok]**
**lok = [ok](login)**
1. `lok`
> print text=auth-login-ok
2. *
> print text=auth-login-fail
**bad = > web_auth_login username="admin" password="wrong" users=`users` session_ttl=120**
**bok = bad[^ok]**
**bok = [ok](bad)**
1. `bok`
> print text=auth-bad-should-fail
2. *
+6 -6
View File
@@ -23,21 +23,21 @@ import sys:lib/sys.mq.md
**m = > web.media**
**ok = > `m`.validate filename="a.png" content_type="image/png" size=100 max_bytes=1000 types=`types`**
**ook = ok[^ok]**
**ook = [ok](ok)**
1. `ook`
> print text=validate-ok
2. *
> print text=validate-fail
**bad = > `m`.validate filename="a.exe" content_type="application/octet-stream" size=100 max_bytes=1000 types=`types`**
**bok = bad[^ok]**
**bok = [ok](bad)**
1. `bok`
> print text=reject-type-fail
2. *
> print text=reject-type-ok
**big = > `m`.validate filename="a.png" content_type="image/png" size=9000 max_bytes=1000 types=`types`**
**gok = big[^ok]**
**gok = [ok](big)**
1. `gok`
> print text=reject-size-fail
2. *
@@ -46,15 +46,15 @@ import sys:lib/sys.mq.md
**blob = > web.storage url="file:tests/ext/web-fixtures/data/upload-blobs"**
**m = > web.media storage=`blob`**
**saved = > `m`.save path="tests/ext/web-fixtures/upload/sample.txt" content_type="text/plain" prefix="smoke/"**
**sok = saved[^ok]**
**skey = saved[^key]**
**sok = [ok](saved)**
**skey = [key](saved)**
1. `sok`
> print text=save-ok
2. *
> print text=save-fail
**got = > `blob`.get key=`skey`**
**body = got[^body]**
**body = [body](got)**
1. `body` == "hello-upload"
> print text=save-roundtrip-ok
2. *
+8 -8
View File
@@ -27,7 +27,7 @@ import sys:lib/sys.mq.md
> `store`.init name=posts fields=`fields`
**idx = > `store`.query sql="SELECT name FROM sqlite_master WHERE type='index' AND tbl_name='posts'"**
**nidx = > len value=idx[^rows]**
**nidx = > len value=[rows](idx)**
1. `nidx` >= 1
> print text=unique-ok
2. *
@@ -41,7 +41,7 @@ import sys:lib/sys.mq.md
| /about | 2026-08-28 |
**sm = > web_sitemap_build base="https://example.com" items=`items`**
**xml = sm[^xml]**
**xml = [xml](sm)**
1. `xml`
> print text=sitemap-ok
2. *
@@ -55,27 +55,27 @@ import sys:lib/sys.mq.md
**app = > `app`.error_page status=404 page=`notfound`**
**app = > `app`.sitemap path="/sitemap.xml" base="https://example.com" items=`items`**
**app = > `app`.robots sitemap="https://example.com/sitemap.xml"**
**rd = app[^redirects]**
**has = rd[^/old]**
**rd = [redirects](app)**
**has = [/old](rd)**
1. `has`
> print text=redirect-ok
2. *
> print text=redirect-fail
**rb = app[^robots_body]**
**rb = [robots_body](app)**
1. `rb`
> print text=robots-ok
2. *
> print text=robots-fail
**mw = app[^middleware]**
**cc = mw[^cache_control]**
**mw = [middleware](app)**
**cc = [cache_control](mw)**
1. `cc` == "public, max-age=60"
> print text=cache-control-ok
2. *
> print text=cache-control-fail
**p404 = app[^page_404]**
**p404 = [page_404](app)**
1. `p404`
> print text=error-page-ok
2. *
+5 -5
View File
@@ -16,17 +16,17 @@ import sys:lib/sys.mq.md
**pg = > web.page title="w6b"**
**app = > web.app page=`pg` port=18111**
**app = > `app`.route_ws path="/room" mode="broadcast"**
**routes = app[^ws_routes]**
**room = routes[^/room]**
**mode = room[^mode]**
**routes = [ws_routes](app)**
**room = [/room](routes)**
**mode = [mode](room)**
1. `mode` == "broadcast"
> print text=ws-broadcast-route-ok
2. *
> print text=ws-broadcast-route-fail
**app = > `app`.configure access_log=True compress=False**
**mw = app[^middleware]**
**al = mw[^access_log]**
**mw = [middleware](app)**
**al = [access_log](mw)**
1. `al`
> print text=access-log-ok
2. *