@arshdelight/practi 0.20.0 → 0.21.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -4
- package/dist/cmd/new.js +0 -10
- package/dist/cmd/new.js.map +1 -1
- package/dist/cmd/search.js +8 -87
- package/dist/cmd/search.js.map +1 -1
- package/dist/index.js +1 -21
- package/dist/index.js.map +1 -1
- package/dist/retrieval.js +0 -25
- package/dist/retrieval.js.map +1 -1
- package/package.json +2 -5
- package/skills/use-practi/SKILL.md +2 -19
- package/web-default/chain.html +9 -20
- package/web-default/chain.js +34 -20
- package/web-default/detail.html +1 -0
- package/web-default/detail.js +29 -23
- package/web-default/home.html +23 -18
- package/web-default/home.js +138 -25
- package/web-default/lang.js +20 -5
- package/web-default/style.css +267 -156
- package/dist/cmd/claim.js +0 -98
- package/dist/cmd/claim.js.map +0 -1
- package/dist/cmd/comment.js +0 -245
- package/dist/cmd/comment.js.map +0 -1
- package/dist/cmd/edit.js +0 -158
- package/dist/cmd/edit.js.map +0 -1
- package/dist/cmd/embed.js +0 -150
- package/dist/cmd/embed.js.map +0 -1
- package/dist/cmd/fetch.js +0 -44
- package/dist/cmd/fetch.js.map +0 -1
- package/dist/cmd/instance.js +0 -97
- package/dist/cmd/instance.js.map +0 -1
- package/dist/cmd/lifecycle.js +0 -119
- package/dist/cmd/lifecycle.js.map +0 -1
- package/dist/cmd/ls.js +0 -61
- package/dist/cmd/ls.js.map +0 -1
- package/dist/cmd/migrate.js +0 -149
- package/dist/cmd/migrate.js.map +0 -1
- package/dist/cmd/practice.js +0 -56
- package/dist/cmd/practice.js.map +0 -1
- package/dist/cmd/promote.js +0 -124
- package/dist/cmd/promote.js.map +0 -1
- package/dist/cmd/publish.js +0 -124
- package/dist/cmd/publish.js.map +0 -1
- package/dist/cmd/remove.js +0 -34
- package/dist/cmd/remove.js.map +0 -1
- package/dist/cmd/repair.js +0 -34
- package/dist/cmd/repair.js.map +0 -1
- package/dist/commits.js +0 -116
- package/dist/commits.js.map +0 -1
- package/dist/embed/cache.js +0 -207
- package/dist/embed/cache.js.map +0 -1
- package/dist/embed/model.js +0 -217
- package/dist/embed/model.js.map +0 -1
- package/dist/embed/optional.js +0 -128
- package/dist/embed/optional.js.map +0 -1
- package/dist/embed/ready.js +0 -15
- package/dist/embed/ready.js.map +0 -1
- package/dist/embed/tokenizer.js +0 -185
- package/dist/embed/tokenizer.js.map +0 -1
|
@@ -148,7 +148,7 @@ practi export <hash> [-o f] # write any revision back out (the current one IS
|
|
|
148
148
|
practi log [--branch <b>] [--json] # commit history, tip first; (local, unpushed) marked
|
|
149
149
|
practi lint # quality hints on the current branch head
|
|
150
150
|
practi show <hash> [--json] [--doc] # inspect one revision node (hash prefix OK)
|
|
151
|
-
practi search <q> [--notes]
|
|
151
|
+
practi search <q> [--notes] # search this practice's revisions (literal BM25, title-first)
|
|
152
152
|
practi similar <hash> # content neighbours within this practice (literal bigram
|
|
153
153
|
# similarity, not semantics)
|
|
154
154
|
practi note add|list|edit|delete # learning notes pinned to node hashes (.practi/notes.json)
|
|
@@ -157,8 +157,6 @@ practi web # browse practices locally — inside a practice
|
|
|
157
157
|
# branches, per-revision reader (wizard / standard view / doc
|
|
158
158
|
# tree); anywhere else: the practices home directory page
|
|
159
159
|
# (default ~/.practi/practices), rows click through to the reader
|
|
160
|
-
practi embed status|pull|build|prune # optional vector model (.practi/models/), scoped to
|
|
161
|
-
# this practice; without it search is lexical-only
|
|
162
160
|
```
|
|
163
161
|
|
|
164
162
|
- The **working file is the write door**, `export` is the read-back door. `commit` when the file equals the head says `nothing to commit`.
|
|
@@ -210,27 +208,12 @@ practi history reword <seq> -m <msg> | squash <seq> | drop <seq> | reset <seq>
|
|
|
210
208
|
- **Multiple words are ANDed, and may match in different fields.** `practi search listary 编码` needs both words somewhere in the same node — not adjacent in the text. Quote a phrase to require it whole.
|
|
211
209
|
- **`field:value` scopes one word** — `name:`, `desc:`, `content:`, `flow:` (declared inputs/outputs), `loop:`, `op:`, `hash:`. `practi search name:yt-dlp` hits only nodes whose *name* says it.
|
|
212
210
|
- **Chinese is matched by character bigram, not by word** — no dictionary needed. A query word matches only when *all* of its bigrams are present, so word order matters; when strict matching finds nothing the command retries with a strict-majority-of-terms rule and labels every row `partial match`. **A partial-match row is a hint, not an answer** — never present one as the found practice without reading it.
|
|
213
|
-
- **A literal search is not a semantic one, and that is deliberate.** Queries that share no wording with the record return *nothing*. So when `practi search` reports no matches, it prints the next move — retry with `--notes`,
|
|
211
|
+
- **A literal search is not a semantic one, and that is deliberate.** Queries that share no wording with the record return *nothing*. So when `practi search` reports no matches, it prints the next move — retry with `--notes`, or start from a node you already have with `practi similar`. Take that step instead of rephrasing the same query repeatedly. (The optional `--semantic` vector layer was removed in the 2026-11-17 early-stage simplification; search is lexical-only.)
|
|
214
212
|
- **`--notes` also searches your local notes** (off by default, so the plain result set stays stable). Notes are where the most conversational keywords end up — when a search comes up empty, retry it with `--notes` before giving up.
|
|
215
213
|
- **Results are ranked title-first and each says why it matched.** Trust the explanation over the number.
|
|
216
214
|
- **`practi similar <hash>` answers the other question** — not "where did I write X" but "what else is about X". Literal: a paraphrase sharing no wording will not surface.
|
|
217
215
|
- Across practices, browse folders in your file manager — a practice folder *is* its own listing.
|
|
218
216
|
|
|
219
|
-
## Semantic recall (optional, off by default)
|
|
220
|
-
|
|
221
|
-
Literal search cannot find a paraphrase. When that matters, practi can add a real vector layer, scoped to the practice. It is **optional and never automatic**:
|
|
222
|
-
|
|
223
|
-
```bash
|
|
224
|
-
practi embed pull # download the model once (~24MB int8 ONNX) into .practi/models/
|
|
225
|
-
practi embed build # embed every stored node (incremental: only new hashes are embedded)
|
|
226
|
-
practi embed status # is the model present? how many nodes are covered?
|
|
227
|
-
practi search <q> --semantic # fuse vector recall with the lexical ranking (RRF)
|
|
228
|
-
```
|
|
229
|
-
|
|
230
|
-
- **Nothing here is required.** Without a model `practi search` is lexical-only; `--semantic` then says what is missing on stderr and answers from the lexical index anyway.
|
|
231
|
-
- **It costs one build.** After that only new nodes are embedded, so day-to-day use is incremental. Model bytes and vectors live under `.practi/` as **derived** sidecars — never written into a node, never part of a hash.
|
|
232
|
-
- **The vector layer can never break a command.** `--semantic` degrades to lexical with the reason on stderr if anything is missing; only `practi embed pull|build` — explicit requests — fail loudly.
|
|
233
|
-
|
|
234
217
|
## Local notes
|
|
235
218
|
|
|
236
219
|
```bash
|
package/web-default/chain.html
CHANGED
|
@@ -4,34 +4,23 @@
|
|
|
4
4
|
<meta charset="utf-8">
|
|
5
5
|
<meta name="viewport" content="width=device-width, initial-scale=1">
|
|
6
6
|
<title>practi — practice</title>
|
|
7
|
-
<link rel="icon" type="image/svg+xml" href="data:image/svg+xml,%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20viewBox%3D%2267.5%2075%20459%20459%22%20fill%3D%22none%22%20stroke%3D%22%23111827%22%20stroke-width%3D%2227%22%20stroke-linecap%3D%22round%22%20stroke-linejoin%3D%22round%22%3E%3Cpath%20d%3D%22M%20301.0%20252.0%20C%20300.5%20246.2%20299.6%20228.7%20298.0%20217.2%20C%20296.4%20205.7%20294.8%20194.1%20291.4%20183.0%20C%20287.9%20171.8%20283.5%20160.2%20277.3%20150.3%20C%20271.1%20140.4%20263.1%20130.9%20254.1%20123.7%20C%20245.1%20116.5%20234.0%20110.2%20223.1%20107.1%20C%20212.2%20104.1%20199.5%20103.2%20188.5%20105.4%20C%20177.5%20107.5%20165.6%20112.8%20157.2%20119.9%20C%20148.8%20127.8%20138.0%20148.2%20128.8%20182.7%20C%20127.7%20194.3%20127.4%20208.0%20131.8%20218.0%20C%20136.2%20228.0%20145.9%20236.1%20155.2%20242.8%20C%20164.4%20249.6%20176.1%20254.3%20187.3%20258.4%20C%20198.4%20262.5%20210.4%20264.9%20222.0%20267.2%20C%20233.7%20269.5%20256.5%20269.2%20257.2%20272.3%20C%20257.8%20275.5%20236.5%20281.6%20225.8%20286.2%20C%20215.0%20290.7%20203.3%20294.4%20192.6%20299.5%20C%20181.8%20304.7%20171.2%20310.6%20161.2%20317.1%20C%20151.2%20323.6%20140.8%20330.3%20132.6%20338.6%20C%20124.3%20346.9%20115.6%20356.3%20111.5%20366.7%20C%20107.4%20377.1%20103.6%20391.8%20107.9%20400.9%20C%20112.1%20410.0%20126.3%20418.0%20137.0%20421.5%20C%20147.7%20425.0%20160.5%20423.7%20172.0%20422.0%20C%20183.5%20420.2%20195.4%20416.3%20206.0%20411.3%20C%20216.6%20406.2%20226.8%20399.5%20235.6%20391.8%20C%20244.4%20384.1%20251.5%20374.1%20259.0%20365.0%20C%20266.5%20355.9%20280.7%20337.4%20287.0%20329.2%20294.3%20319.6%20297.0%20316.0%22%20/%3E%3Cpath%20d%3D%22M%20381.0%20210.0%20C%20386.8%20209.4%20404.2%20205.8%20415.6%20206.3%20C%20426.9%20206.8%20438.9%20208.3%20449.1%20212.9%20C%20459.2%20217.4%20469.8%20224.7%20476.4%20233.4%20C%20483.1%20242.2%
|
|
7
|
+
<link rel="icon" type="image/svg+xml" href="data:image/svg+xml,%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20viewBox%3D%2267.5%2075%20459%20459%22%20fill%3D%22none%22%20stroke%3D%22%23111827%22%20stroke-width%3D%2227%22%20stroke-linecap%3D%22round%22%20stroke-linejoin%3D%22round%22%3E%3Cpath%20d%3D%22M%20301.0%20252.0%20C%20300.5%20246.2%20299.6%20228.7%20298.0%20217.2%20C%20296.4%20205.7%20294.8%20194.1%20291.4%20183.0%20C%20287.9%20171.8%20283.5%20160.2%20277.3%20150.3%20C%20271.1%20140.4%20263.1%20130.9%20254.1%20123.7%20C%20245.1%20116.5%20234.0%20110.2%20223.1%20107.1%20C%20212.2%20104.1%20199.5%20103.2%20188.5%20105.4%20C%20177.5%20107.5%20165.6%20112.8%20157.2%20119.9%20C%20148.8%20127.1%20142.8%20137.8%20138.0%20148.2%20C%20133.3%20158.7%20129.8%20171.1%20128.8%20182.7%20C%20127.7%20194.3%20127.4%20208.0%20131.8%20218.0%20C%20136.2%20228.0%20145.9%20236.1%20155.2%20242.8%20C%20164.4%20249.6%20176.1%20254.3%20187.3%20258.4%20C%20198.4%20262.5%20210.4%20264.9%20222.0%20267.2%20C%20233.7%20269.5%20256.5%20269.2%20257.2%20272.3%20C%20257.8%20275.5%20236.5%20281.6%20225.8%20286.2%20C%20215.0%20290.7%20203.3%20294.4%20192.6%20299.5%20C%20181.8%20304.7%20171.2%20310.6%20161.2%20317.1%20C%20151.2%20323.6%20140.8%20330.3%20132.6%20338.6%20C%20124.3%20346.9%20115.6%20356.3%20111.5%20366.7%20C%20107.4%20377.1%20103.6%20391.8%20107.9%20400.9%20C%20112.1%20410.0%20126.3%20418.0%20137.0%20421.5%20C%20147.7%20425.0%20160.5%20423.7%20172.0%20422.0%20C%20183.5%20420.2%20195.4%20416.3%20206.0%20411.3%20C%20216.6%20406.2%20226.8%20399.5%20235.6%20391.8%20C%20244.4%20384.1%20251.5%20374.1%20259.0%20365.0%20C%20266.5%20355.9%20274.3%20345.5%20280.7%20337.4%20C%20287.0%20329.2%20294.3%20319.6%20297.0%20316.0%22%20/%3E%3Cpath%20d%3D%22M%20381.0%20210.0%20C%20386.8%20209.4%20404.2%20205.8%20415.6%20206.3%20C%20426.9%20206.8%20438.9%20208.3%20449.1%20212.9%20C%20459.2%20217.4%20469.8%20224.7%20476.4%20233.4%20C%20483.1%20242.2%20485.2%20299.6%20C%20480.7%20309.8%20471.5%20320.6%20462.1%20326.7%20C%20452.7%20332.7%20428.8%20336.0%20C%20417.4%20336.9%20404.9%20334.7%20393.6%20332.1%20C%20382.3%20329.4%20369.0%20323.1%20353.1%20320.1%20C%20346.0%20312.0%22%20/%3E%3Cpath%20d%3D%22M%20310.0%20303.0%20C%20311.1%20308.7%20315.4%20337.4%20316.0%20372.1%20C%20315.4%20325.9%20295.1%20439.9%20246.0%20505.0%22%20/%3E%3C/svg%3E">
|
|
8
8
|
<link rel="stylesheet" href="/style.css">
|
|
9
|
-
<style>
|
|
10
|
-
main { max-width: 760px; margin: 0 auto; padding: 24px 20px 60px; }
|
|
11
|
-
.repo-head { display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; margin-bottom: 6px; }
|
|
12
|
-
.repo-name { font-size: 22px; font-weight: 700; color: #111; }
|
|
13
|
-
.repo-owner { color: #555; }
|
|
14
|
-
.branches { display: flex; gap: 8px; flex-wrap: wrap; margin: 10px 0 18px; }
|
|
15
|
-
.branch-btn { border: 1px solid #d0d7de; background: #fff; border-radius: 999px; padding: 3px 12px; font-size: 13px; cursor: pointer; color: #111; }
|
|
16
|
-
.branch-btn.current { border-color: #111827; font-weight: 600; }
|
|
17
|
-
.commits { list-style: none; margin: 0; padding: 0; }
|
|
18
|
-
.commit { display: flex; align-items: baseline; gap: 12px; padding: 9px 4px; border-bottom: 1px solid #eaeef2; }
|
|
19
|
-
.commit .seq { color: #57606a; min-width: 34px; font-variant-numeric: tabular-nums; }
|
|
20
|
-
.commit a.root { font-family: ui-monospace, monospace; font-size: 13px; color: #111827; text-decoration: none; }
|
|
21
|
-
.commit a.root:hover { text-decoration: underline; }
|
|
22
|
-
.commit .msg { flex: 1; color: #111; }
|
|
23
|
-
.commit .badge { font-size: 12px; color: #57606a; }
|
|
24
|
-
.empty { color: #57606a; padding: 24px 0; }
|
|
25
|
-
</style>
|
|
26
9
|
</head>
|
|
27
10
|
<body>
|
|
28
11
|
<header>
|
|
29
12
|
<a class="brand-link" href="/" aria-label="practi">
|
|
30
|
-
|
|
13
|
+
<svg class="logo" viewBox="67.5 75 459 459" fill="none" stroke="currentColor" stroke-width="27" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true">
|
|
14
|
+
<path d="M 301.0 252.0 C 300.5 246.2 299.6 228.7 298.0 217.2 C 296.4 205.7 294.8 194.1 291.4 183.0 C 287.9 171.8 283.5 160.2 277.3 150.3 C 271.1 140.4 263.1 130.9 254.1 123.7 C 245.1 116.5 234.0 110.2 223.1 107.1 C 212.2 104.1 199.5 103.2 188.5 105.4 C 177.5 107.5 165.6 112.8 157.2 119.9 C 148.8 127.1 142.8 137.8 138.0 148.2 C 133.3 158.7 129.8 171.1 128.8 182.7 C 127.7 194.3 127.4 208.0 131.8 218.0 C 136.2 228.0 145.9 236.1 155.2 242.8 C 164.4 249.6 176.1 254.3 187.3 258.4 C 198.4 262.5 210.4 264.9 222.0 267.2 C 233.7 269.5 256.5 269.2 257.2 272.3 C 257.8 275.5 236.5 281.6 225.8 286.2 C 215.0 290.7 203.3 294.4 192.6 299.5 C 181.8 304.7 171.2 310.6 161.2 317.1 C 151.2 323.6 140.8 330.3 132.6 338.6 C 124.3 346.9 115.6 356.3 111.5 366.7 C 107.4 377.1 103.6 391.8 107.9 400.9 C 112.1 410.0 126.3 418.0 137.0 421.5 C 147.7 425.0 160.5 423.7 172.0 422.0 C 183.5 420.2 195.4 416.3 206.0 411.3 C 216.6 406.2 226.8 399.5 235.6 391.8 C 244.4 384.1 251.5 374.1 259.0 365.0 C 266.5 355.9 274.3 345.5 280.7 337.4 C 287.0 329.2 294.3 319.6 297.0 316.0" />
|
|
15
|
+
<path d="M 381.0 210.0 C 386.8 209.4 404.2 205.8 415.6 206.3 C 426.9 206.8 438.9 208.3 449.1 212.9 C 459.2 217.4 469.8 224.7 476.4 233.4 C 483.1 242.2 487.7 254.4 489.1 265.4 C 490.6 276.5 489.7 289.4 485.2 299.6 C 480.7 309.8 471.5 320.6 462.1 326.7 C 452.7 332.7 440.2 335.1 428.8 336.0 C 417.4 336.9 404.9 334.7 393.6 332.1 C 382.3 329.4 369.0 323.4 361.0 320.1 C 353.1 316.7 348.5 313.3 346.0 312.0" />
|
|
16
|
+
<path d="M 310.0 303.0 C 311.1 308.7 315.4 325.9 316.8 337.4 C 318.1 349.0 319.1 360.6 318.0 372.1 C 316.8 383.7 313.7 395.6 309.9 406.8 C 306.1 418.1 300.9 429.2 295.1 439.5 C 289.3 449.9 283.2 458.2 275.0 469.1 C 266.9 480.1 250.8 499.0 246.0 505.0" />
|
|
17
|
+
</svg>
|
|
18
|
+
<span class="brand">practi</span>
|
|
31
19
|
</a>
|
|
20
|
+
<nav class="crumbs" id="crumbs" aria-label="breadcrumb"></nav>
|
|
32
21
|
</header>
|
|
33
22
|
<main id="app">
|
|
34
|
-
<div class="empty">…</div>
|
|
23
|
+
<div class="empty"><p class="lead">…</p></div>
|
|
35
24
|
</main>
|
|
36
25
|
<script src="/lang.js" defer></script>
|
|
37
26
|
<script src="/chain.js" defer></script>
|
package/web-default/chain.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
// 实例浏览页:提交链(当前支 tip 在前)+
|
|
1
|
+
// 实例浏览页:提交链(当前支 tip 在前)+ 支切换,形态对齐 hub commits 页
|
|
2
|
+
// (分支选择器行 + divide-y 版本行列表)。数据窗 /api/repo,只读。
|
|
2
3
|
// 单仓模式挂在 / 下;home 模式挂 /p/<name>/ 下,服务器注入 window.POP_WEB_PREFIX 供拼 API 与链接。
|
|
3
4
|
'use strict';
|
|
4
5
|
|
|
@@ -13,35 +14,47 @@
|
|
|
13
14
|
});
|
|
14
15
|
}
|
|
15
16
|
|
|
17
|
+
function renderCrumbs(repo) {
|
|
18
|
+
var el = document.getElementById('crumbs');
|
|
19
|
+
if (!el) return;
|
|
20
|
+
el.innerHTML = (repo.owner ? '<a class="crumb" href="' + P + '/">' + esc(repo.owner) + '</a><span class="crumb-sep">/</span>' : '')
|
|
21
|
+
+ '<span class="crumb current">' + esc(repo.name) + '</span>';
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
var EMPTY_ICON = '<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M22 12h-6l-2 3h-4l-2-3H2"/><path d="M5.45 5.11 2 12v6a2 2 0 0 0 2 2h16a2 2 0 0 0 2-2v-6l-3.45-6.89A2 2 0 0 0 16.76 4H7.24a2 2 0 0 0-1.79 1.11z"/></svg>';
|
|
25
|
+
|
|
16
26
|
fetch(P + '/api/repo' + (wantedBranch ? '?branch=' + encodeURIComponent(wantedBranch) : ''))
|
|
17
27
|
.then(function (r) { return r.json(); })
|
|
18
28
|
.then(function (repo) {
|
|
19
29
|
var app = document.getElementById('app');
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
var branches = '<div class="branches">' + repo.branches.map(function (b) {
|
|
25
|
-
var label = esc(b.name) + (b.isDefault ? ' (default)' : '');
|
|
30
|
+
document.title = repo.name + ' — practi';
|
|
31
|
+
renderCrumbs(repo);
|
|
32
|
+
|
|
33
|
+
var bar = '<div class="branch-bar">' + repo.branches.map(function (b) {
|
|
26
34
|
return '<button class="branch-btn' + (b.current ? ' current' : '') + '" data-branch="' + esc(b.name) + '"'
|
|
27
|
-
+ (b.current ? ' disabled' : '') + '>' +
|
|
28
|
-
|
|
35
|
+
+ (b.current ? ' disabled' : '') + '>' + esc(b.name)
|
|
36
|
+
+ (b.isDefault ? '<span class="branch-default">' + esc(POP_I18N.t('defaultBranch')) + '</span>' : '')
|
|
37
|
+
+ '</button>';
|
|
38
|
+
}).join('')
|
|
39
|
+
+ '<span class="rev-count">' + esc(POP_I18N.t('commitCount', repo.commits.length)) + '</span></div>';
|
|
29
40
|
|
|
30
41
|
var rows;
|
|
31
42
|
if (!repo.commits || repo.commits.length === 0) {
|
|
32
|
-
rows = '<div class="empty">
|
|
33
|
-
+ '
|
|
43
|
+
rows = '<div class="empty">' + EMPTY_ICON
|
|
44
|
+
+ '<p class="lead">' + esc(POP_I18N.t('chainEmptyLead')) + '</p>'
|
|
45
|
+
+ '<p class="hint">' + POP_I18N.t('chainEmptyHint', esc(repo.name)) + '</p></div>';
|
|
34
46
|
} else {
|
|
35
|
-
rows = '<
|
|
36
|
-
return '<
|
|
37
|
-
+ '<span class="seq">v' + c.seq + '</span>'
|
|
38
|
-
+ '<a class="root" href="' + P + '/pop/' + encodeURIComponent(c.root) + '" title="' + esc(c.root) + '">' + esc(c.root.slice(7, 19)) + '</a>'
|
|
47
|
+
rows = '<div class="commit-list">' + repo.commits.map(function (c) {
|
|
48
|
+
return '<div class="commit">'
|
|
49
|
+
+ '<span class="rev-seq">v' + c.seq + '</span>'
|
|
39
50
|
+ '<span class="msg">' + esc(c.message) + '</span>'
|
|
40
|
-
+ (c.pushedAt ? '' : '<span class="badge">
|
|
41
|
-
+ '</
|
|
42
|
-
|
|
51
|
+
+ (c.pushedAt ? '' : '<span class="badge-pill badge-warn">' + esc(POP_I18N.t('unpushed')) + '</span>')
|
|
52
|
+
+ '<span class="hash-link" title="' + esc(c.root) + '">' + esc(c.root.slice(7, 19)) + '</span>'
|
|
53
|
+
+ '<a class="browse" href="' + P + '/pop/' + encodeURIComponent(c.root) + '">' + esc(POP_I18N.t('browse')) + '</a>'
|
|
54
|
+
+ '</div>';
|
|
55
|
+
}).join('') + '</div>';
|
|
43
56
|
}
|
|
44
|
-
app.innerHTML =
|
|
57
|
+
app.innerHTML = bar + rows;
|
|
45
58
|
|
|
46
59
|
Array.prototype.forEach.call(app.querySelectorAll('.branch-btn'), function (btn) {
|
|
47
60
|
btn.addEventListener('click', function () {
|
|
@@ -51,6 +64,7 @@
|
|
|
51
64
|
});
|
|
52
65
|
})
|
|
53
66
|
.catch(function (e) {
|
|
54
|
-
document.getElementById('app').innerHTML = '<div class="empty"
|
|
67
|
+
document.getElementById('app').innerHTML = '<div class="empty"><p class="lead">'
|
|
68
|
+
+ esc(POP_I18N.t('loadFail', (e && e.message) || String(e))) + '</p></div>';
|
|
55
69
|
});
|
|
56
70
|
})();
|
package/web-default/detail.html
CHANGED
package/web-default/detail.js
CHANGED
|
@@ -277,7 +277,7 @@ function markSide() {
|
|
|
277
277
|
}
|
|
278
278
|
}
|
|
279
279
|
|
|
280
|
-
// 顶部区已撤:返回职责归 header 左上角 brand-link
|
|
280
|
+
// 顶部区已撤:返回职责归 header 左上角 brand-link(回首页),定位职责归左侧大纲
|
|
281
281
|
|
|
282
282
|
function nodeHtml(node) {
|
|
283
283
|
// 标题层级对齐 hub:根 h1(22px)/ 子节点 h2(20px)——语义与视觉层级一致
|
|
@@ -316,7 +316,7 @@ function fmtNoteTime(iso) {
|
|
|
316
316
|
// 草稿(失焦有内容才落库,空=静默放弃——存储层不允许空笔记)。写入门之二
|
|
317
317
|
// (其一=CLI practi note):POST /api/notes,CSRF 闸与 /api/run 同规格
|
|
318
318
|
|
|
319
|
-
var TRASH_ICON = '<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="
|
|
319
|
+
var TRASH_ICON = '<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M10 11v6"/><path d="M14 11v6"/><path d="M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6"/><path d="M3 6h18"/><path d="M8 6V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2"/></svg>';
|
|
320
320
|
var PLUS_ICON = '<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M5 12h14"/><path d="M12 5v14"/></svg>';
|
|
321
321
|
|
|
322
322
|
/** 开合同步:面板宽度与内容列让位由 CSS transition 承担,这里只切类
|
|
@@ -351,7 +351,7 @@ function renderNoteSide() {
|
|
|
351
351
|
|
|
352
352
|
/** 面板渲染=把 DOM 对齐到服务端笔记。笔记本体是常驻可编辑的 textarea(无边框、
|
|
353
353
|
* 自动长高,观感与正文一致)——没有「进入编辑态」这个动作,点了就有光标,失焦即存。
|
|
354
|
-
*
|
|
354
|
+
* 重建时保留未落库的改动与聚焦位(重拉/语言切换/导航不打断打字) */
|
|
355
355
|
function reconcileNoteSide() {
|
|
356
356
|
var panel = document.getElementById('note-side');
|
|
357
357
|
if (!panel) return;
|
|
@@ -545,7 +545,7 @@ function mediaMissingCard(fig) {
|
|
|
545
545
|
var el = document.createElement('div');
|
|
546
546
|
el.className = 'media-missing';
|
|
547
547
|
el.innerHTML =
|
|
548
|
-
'<svg class="mm-icon" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><
|
|
548
|
+
'<svg class="mm-icon" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><line x1="2" x2="22" y1="2" y2="22"/><path d="M10.41 10.41a2 2 0 1 1-2.83-2.83"/><line x1="13.5" x2="6" y1="13.5" y2="21"/><line x1="18" x2="21" y1="12" y2="15"/><path d="M3.59 3.59A1.99 1.99 0 0 0 3 5v14a2 2 0 0 0 2 2h14c.55 0 1.052-.22 1.41-.59"/><path d="M21 15V5a2 2 0 0 0-2-2H9"/></svg>' +
|
|
549
549
|
'<span class="mm-title">' + escapeHtml(alt || POP_I18N.t('mediaAttach')) + '</span>' +
|
|
550
550
|
(hash ? '<span class="mm-hash">' + escapeHtml(hash.length > 16 ? hash.slice(0, 16) + '…' : hash) + '</span>' : '') +
|
|
551
551
|
'<span class="mm-badge">' + POP_I18N.t('mediaMissing') + '</span>';
|
|
@@ -721,7 +721,7 @@ function showToast(text) {
|
|
|
721
721
|
// 本地文档没有状态/上传者/认领/浏览这些 hub 数据,弹窗只列节点数与根哈希 ──
|
|
722
722
|
var FP_SVG = '<svg width="13" height="13" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M12 10a2 2 0 0 0-2 2c0 1.02-.1 2.51-.26 4"/><path d="M14 13.12c0 2.38 0 6.38-1 8.88"/><path d="M17.29 21.02c.12-.6.43-2.3.5-3.02"/><path d="M2 12a10 10 0 0 1 18-6"/><path d="M2 16h.01"/><path d="M21.8 16c.2-2 .131-5.354 0-6"/><path d="M5 19.5C5.5 18 6 15 6 12a6 6 0 0 1 .34-2"/><path d="M8.65 22c.21-.66.45-1.32.57-2"/><path d="M9 6.8a6 6 0 0 1 9 5.2v2"/></svg>';
|
|
723
723
|
var INFO_SVG = '<svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><circle cx="12" cy="12" r="10"/><path d="M12 16v-4"/><path d="M12 8h.01"/></svg>';
|
|
724
|
-
var CLIP_SVG = '<svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="
|
|
724
|
+
var CLIP_SVG = '<svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="m16 6-8.414 8.586a2 2 0 0 0 2.829 2.829l8.414-8.586a4 4 0 1 0-5.657-5.657l-8.379 8.551a6 6 0 1 0 8.485 8.485l8.379-8.551"/></svg>';
|
|
725
725
|
var BACK_SVG = '<svg width="13" height="13" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="m12 19-7-7 7-7"/><path d="M19 12H5"/></svg>';
|
|
726
726
|
|
|
727
727
|
/** 节点附件平铺(附件跟随节点:practice 无附件表,action 列自己的) */
|
|
@@ -1140,9 +1140,9 @@ document.addEventListener('DOMContentLoaded', function () {
|
|
|
1140
1140
|
if (!ta.value.trim()) { ta.value = n.content; autoGrow(ta); return; } // 清空=还原原文
|
|
1141
1141
|
var content = ta.value;
|
|
1142
1142
|
queueNoteOp(function () {
|
|
1143
|
-
|
|
1143
|
+
// 契约=服务端 handleNoteWrite:update{id,text};成功只回 {ok:true},本地直接改内存
|
|
1144
|
+
return postNote({ op: 'update', id: id, text: content }).then(function () {
|
|
1144
1145
|
n.content = content;
|
|
1145
|
-
if (j.note && j.note.updatedAt) n.updatedAt = j.note.updatedAt;
|
|
1146
1146
|
}).catch(function (err) { noteFail(err); });
|
|
1147
1147
|
});
|
|
1148
1148
|
} else {
|
|
@@ -1157,13 +1157,11 @@ document.addEventListener('DOMContentLoaded', function () {
|
|
|
1157
1157
|
draftByHash[hash] = ta.value; // 先记着:POST 在途时重渲染不丢
|
|
1158
1158
|
var content2 = ta.value;
|
|
1159
1159
|
queueNoteOp(function () {
|
|
1160
|
-
|
|
1161
|
-
|
|
1162
|
-
|
|
1160
|
+
// 契约=服务端 handleNoteWrite:add{hash,text};成功只回 {ok:true}(新条目的 id/时间
|
|
1161
|
+
// 以服务端为准)——重拉本文档笔记,右栏与侧栏徽标一并重建
|
|
1162
|
+
return postNote({ op: 'add', hash: hash, text: content2 }).then(function () {
|
|
1163
1163
|
delete draftByHash[hash];
|
|
1164
|
-
|
|
1165
|
-
document.getElementById('side').innerHTML = sideHtml(); // 徽标 0→N
|
|
1166
|
-
updateNoteCount();
|
|
1164
|
+
loadNotesData();
|
|
1167
1165
|
}).catch(function (err) { noteFail(err); });
|
|
1168
1166
|
});
|
|
1169
1167
|
}
|
|
@@ -1204,24 +1202,30 @@ function onNotesArrived() {
|
|
|
1204
1202
|
|
|
1205
1203
|
function loadNotesData() {
|
|
1206
1204
|
fetch(P + '/api/notes?ref=' + encodeURIComponent(HASH))
|
|
1207
|
-
.then(function (r) { return r.ok ? r.json() : {
|
|
1205
|
+
.then(function (r) { return r.ok ? r.json() : {}; })
|
|
1208
1206
|
.then(function (j) {
|
|
1207
|
+
// 数据窗=哈希分组的 map({ "<hash>": [note…] },web.ts notesRoute 口径);非对象形状按空处理
|
|
1209
1208
|
notesByHash = {};
|
|
1210
|
-
(j
|
|
1211
|
-
(
|
|
1212
|
-
|
|
1209
|
+
if (j && typeof j === 'object') {
|
|
1210
|
+
Object.keys(j).forEach(function (h) {
|
|
1211
|
+
var arr = Array.isArray(j[h]) ? j[h] : [];
|
|
1212
|
+
arr.forEach(function (n) {
|
|
1213
|
+
(notesByHash[n.hash] = notesByHash[n.hash] || []).push(n);
|
|
1214
|
+
});
|
|
1215
|
+
});
|
|
1216
|
+
}
|
|
1217
|
+
var total = Object.keys(notesByHash).reduce(function (s, h) { return s + notesByHash[h].length; }, 0);
|
|
1213
1218
|
// 默认折叠;首载本文档有笔记则自动展开(用户手动开合过就不再自动介入)
|
|
1214
|
-
if (!notesTouched &&
|
|
1219
|
+
if (!notesTouched && total) notesOpen = true;
|
|
1215
1220
|
onNotesArrived();
|
|
1216
1221
|
})
|
|
1217
1222
|
.catch(function () { /* 笔记是锦上添花:拉取失败静默,文档照常显示 */ });
|
|
1218
1223
|
}
|
|
1219
1224
|
|
|
1220
|
-
//
|
|
1221
|
-
//
|
|
1222
|
-
document.
|
|
1223
|
-
|
|
1224
|
-
});
|
|
1225
|
+
// header 接线:brand-link 回首页(practices 总览);修订历史走内容列顶栏按钮。
|
|
1226
|
+
// 单仓模式无独立首页,/ 即本仓链页
|
|
1227
|
+
var brandLink = document.querySelector('.brand-link');
|
|
1228
|
+
if (brandLink) brandLink.setAttribute('href', '/');
|
|
1225
1229
|
|
|
1226
1230
|
fetch(P + '/doc/' + encodeURIComponent(HASH) + '.json')
|
|
1227
1231
|
.then(function (r) {
|
|
@@ -1234,6 +1238,8 @@ fetch(P + '/doc/' + encodeURIComponent(HASH) + '.json')
|
|
|
1234
1238
|
nodeIndex = d.nodeIndex || null;
|
|
1235
1239
|
buildHashByPath();
|
|
1236
1240
|
document.title = doc.name + ' — practi';
|
|
1241
|
+
var crumbs = document.getElementById('crumbs');
|
|
1242
|
+
if (crumbs) crumbs.innerHTML = '<span class="crumb muted">' + escapeHtml(doc.name) + '</span>';
|
|
1237
1243
|
document.getElementById('side').innerHTML = sideHtml();
|
|
1238
1244
|
render();
|
|
1239
1245
|
loadNotesData();
|
package/web-default/home.html
CHANGED
|
@@ -4,31 +4,36 @@
|
|
|
4
4
|
<meta charset="utf-8">
|
|
5
5
|
<meta name="viewport" content="width=device-width, initial-scale=1">
|
|
6
6
|
<title>practi — practices</title>
|
|
7
|
-
<link rel="icon" type="image/svg+xml" href="data:image/svg+xml,%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20viewBox%3D%2267.5%2075%20459%20459%22%20fill%3D%22none%22%20stroke%3D%22%23111827%22%20stroke-width%3D%2227%22%20stroke-linecap%3D%22round%22%20stroke-linejoin%3D%22round%22%3E%3Cpath%20d%3D%22M%20301.0%20252.0%20C%20300.5%20246.2%20299.6%20228.7%20298.0%20217.2%20C%20296.4%20205.7%20294.8%20194.1%20291.4%20183.0%20C%20287.9%20171.8%20283.5%20160.2%20277.3%20150.3%20C%20271.1%20140.4%20263.1%20130.9%20254.1%20123.7%20C%20245.1%20116.5%20234.0%20110.2%20223.1%20107.1%20C%20212.2%20104.1%20199.5%20103.2%20188.5%20105.4%20C%20177.5%20107.5%20165.6%20112.8%20157.2%20119.9%20C%20148.8%20127.1%20142.8%20137.8%20138.0%20148.2%20C%20133.3%20158.7%20129.8%20171.1%20128.8%20182.7%20C%20127.7%20194.3%20127.4%20208.0%20131.8%20218.0%20C%20136.2%20228.0%20145.9%20236.1%20155.2%20242.8%20C%20164.4%20249.6%20176.1%20254.3%20187.3%20258.4%20C%20198.4%20262.5%20210.4%20264.9%20222.0%20267.2%20C%20233.7%20269.5%20256.5%20269.2%20257.2%20272.3%20C%20257.8%20275.5%20236.5%20281.6%20225.8%20286.2%20C%20215.0%20290.7%20203.3%20294.4%20192.6%20299.5%20C%20181.8%20304.7%20171.2%20310.6%20161.2%20317.1%20C%20151.2%20323.6%20140.8%20330.3%20132.6%20338.6%20C%20124.3%20346.9%20115.6%20356.3%20111.5%20366.7%20C%20107.4%20377.1%20103.6%20391.8%20107.9%20400.9%20C%20112.1%20410.0%20126.3%20418.0%20137.0%20421.5%20C%20147.7%20425.0%20160.5%20423.7%20172.0%20422.0%20C%20183.5%20420.2%20195.4%20416.3%20206.0%20411.3%20C%20216.6%20406.2%20226.8%20399.5%20235.6%20391.8%20C%20244.4%20384.1%20251.5%20374.1%20259.0%20365.0%20C%20266.5%20355.9%20274.3%20345.5%20280.7%20337.4%20C%20287.0%20329.2%20294.3%20319.6%20297.0%20316.0%22%20/%3E%3Cpath%20d%3D%22M%20381.0%20210.0%20C%20386.8%20209.4%20404.2%20205.8%20415.6%20206.3%20C%20426.9%20206.8%20438.9%20208.3%20449.1%20212.9%20C%20459.2%20217.4%20469.8%20224.7%20476.4%20233.4%20C%20483.1%20242.2%
|
|
7
|
+
<link rel="icon" type="image/svg+xml" href="data:image/svg+xml,%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20viewBox%3D%2267.5%2075%20459%20459%22%20fill%3D%22none%22%20stroke%3D%22%23111827%22%20stroke-width%3D%2227%22%20stroke-linecap%3D%22round%22%20stroke-linejoin%3D%22round%22%3E%3Cpath%20d%3D%22M%20301.0%20252.0%20C%20300.5%20246.2%20299.6%20228.7%20298.0%20217.2%20C%20296.4%20205.7%20294.8%20194.1%20291.4%20183.0%20C%20287.9%20171.8%20283.5%20160.2%20277.3%20150.3%20C%20271.1%20140.4%20263.1%20130.9%20254.1%20123.7%20C%20245.1%20116.5%20234.0%20110.2%20223.1%20107.1%20C%20212.2%20104.1%20199.5%20103.2%20188.5%20105.4%20C%20177.5%20107.5%20165.6%20112.8%20157.2%20119.9%20C%20148.8%20127.1%20142.8%20137.8%20138.0%20148.2%20C%20133.3%20158.7%20129.8%20171.1%20128.8%20182.7%20C%20127.7%20194.3%20127.4%20208.0%20131.8%20218.0%20C%20136.2%20228.0%20145.9%20236.1%20155.2%20242.8%20C%20164.4%20249.6%20176.1%20254.3%20187.3%20258.4%20C%20198.4%20262.5%20210.4%20264.9%20222.0%20267.2%20C%20233.7%20269.5%20256.5%20269.2%20257.2%20272.3%20C%20257.8%20275.5%20236.5%20281.6%20225.8%20286.2%20C%20215.0%20290.7%20203.3%20294.4%20192.6%20299.5%20C%20181.8%20304.7%20171.2%20310.6%20161.2%20317.1%20C%20151.2%20323.6%20140.8%20330.3%20132.6%20338.6%20C%20124.3%20346.9%20115.6%20356.3%20111.5%20366.7%20C%20107.4%20377.1%20103.6%20391.8%20107.9%20400.9%20C%20112.1%20410.0%20126.3%20418.0%20137.0%20421.5%20C%20147.7%20425.0%20160.5%20423.7%20172.0%20422.0%20C%20183.5%20420.2%20195.4%20416.3%20206.0%20411.3%20C%20216.6%20406.2%20226.8%20399.5%20235.6%20391.8%20C%20244.4%20384.1%20251.5%20374.1%20259.0%20365.0%20C%20266.5%20355.9%20274.3%20345.5%20280.7%20337.4%20C%20287.0%20329.2%20294.3%20319.6%20297.0%20316.0%22%20/%3E%3Cpath%20d%3D%22M%20381.0%20210.0%20C%20386.8%20209.4%20404.2%20205.8%20415.6%20206.3%20C%20426.9%20206.8%20438.9%20208.3%20449.1%20212.9%20C%20459.2%20217.4%20469.8%20224.7%20476.4%20233.4%20C%20483.1%20242.2%20485.2%20299.6%20C%20480.7%20309.8%20471.5%20320.6%20462.1%20326.7%20C%20452.7%20332.7%20428.8%20336.0%20C%20417.4%20336.9%20404.9%20334.7%20393.6%20332.1%20C%20382.3%20329.4%20369.0%20323.1%20353.1%20320.1%20C%20346.0%20312.0%22%20/%3E%3Cpath%20d%3D%22M%20310.0%20303.0%20C%20311.1%20308.7%20315.4%20325.9%20316.8%20337.4%20C%20318.1%20349.0%20319.1%20360.6%20318.0%20372.1%20C%20316.8%20383.7%20313.7%20395.6%20309.9%20406.8%20C%20306.1%20418.1%20300.9%20429.2%20295.1%20439.5%20C%20289.3%20449.9%20283.2%20458.2%20275.0%20469.1%20C%20266.9%20480.1%20250.8%20499.0%20246.0%20505.0%22%20/%3E%3C/svg%3E">
|
|
8
8
|
<link rel="stylesheet" href="/style.css">
|
|
9
|
-
<style>
|
|
10
|
-
main { max-width: 860px; margin: 0 auto; padding: 24px 20px 60px; }
|
|
11
|
-
.page-title { font-size: 22px; font-weight: 700; color: #111; margin: 0 0 18px; }
|
|
12
|
-
table.practices { width: 100%; border-collapse: collapse; }
|
|
13
|
-
.practices th { text-align: left; font-size: 12px; font-weight: 500; color: #57606a; padding: 8px 10px; border-bottom: 1px solid #d0d7de; }
|
|
14
|
-
.practices td { padding: 10px; border-bottom: 1px solid #eaeef2; font-size: 14px; color: #111; }
|
|
15
|
-
.practices td.name a { font-weight: 600; color: #111827; text-decoration: none; }
|
|
16
|
-
.practices td.name a:hover { text-decoration: underline; }
|
|
17
|
-
.practices td.msg { color: #57606a; }
|
|
18
|
-
.practices td.msg .none { color: #9ca3af; }
|
|
19
|
-
.practices .num { text-align: right; font-variant-numeric: tabular-nums; }
|
|
20
|
-
.practices .time { text-align: right; color: #57606a; white-space: nowrap; font-variant-numeric: tabular-nums; }
|
|
21
|
-
.empty { color: #57606a; padding: 24px 0; }
|
|
22
|
-
</style>
|
|
23
9
|
</head>
|
|
24
10
|
<body>
|
|
25
11
|
<header>
|
|
26
12
|
<a class="brand-link" href="/" aria-label="practi">
|
|
27
|
-
|
|
13
|
+
<svg class="logo" viewBox="67.5 75 459 459" fill="none" stroke="currentColor" stroke-width="27" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true">
|
|
14
|
+
<path d="M 301.0 252.0 C 300.5 246.2 299.6 228.7 298.0 217.2 C 296.4 205.7 294.8 194.1 291.4 183.0 C 287.9 171.8 283.5 160.2 277.3 150.3 C 271.1 140.4 263.1 130.9 254.1 123.7 C 245.1 116.5 234.0 110.2 223.1 107.1 C 212.2 104.1 199.5 103.2 188.5 105.4 C 177.5 107.5 165.6 112.8 157.2 119.9 C 148.8 127.1 142.8 137.8 138.0 148.2 C 133.3 158.7 129.8 171.1 128.8 182.7 C 127.7 194.3 127.4 208.0 131.8 218.0 C 136.2 228.0 145.9 236.1 155.2 242.8 C 164.4 249.6 176.1 254.3 187.3 258.4 C 198.4 262.5 210.4 264.9 222.0 267.2 C 233.7 269.5 256.5 269.2 257.2 272.3 C 257.8 275.5 236.5 281.6 225.8 286.2 C 215.0 290.7 203.3 294.4 192.6 299.5 C 181.8 304.7 171.2 310.6 161.2 317.1 C 151.2 323.6 140.8 330.3 132.6 338.6 C 124.3 346.9 115.6 356.3 111.5 366.7 C 107.4 377.1 103.6 391.8 107.9 400.9 C 112.1 410.0 126.3 418.0 137.0 421.5 C 147.7 425.0 160.5 423.7 172.0 422.0 C 183.5 420.2 195.4 416.3 206.0 411.3 C 216.6 406.2 226.8 399.5 235.6 391.8 C 244.4 384.1 251.5 374.1 259.0 365.0 C 266.5 355.9 274.3 345.5 280.7 337.4 C 287.0 329.2 294.3 319.6 297.0 316.0" />
|
|
15
|
+
<path d="M 381.0 210.0 C 386.8 209.4 404.2 205.8 415.6 206.3 C 426.9 206.8 438.9 208.3 449.1 212.9 C 459.2 217.4 469.8 224.7 476.4 233.4 C 483.1 242.2 487.7 254.4 489.1 265.4 C 490.6 276.5 489.7 289.4 485.2 299.6 C 480.7 309.8 471.5 320.6 462.1 326.7 C 452.7 332.7 440.2 335.1 428.8 336.0 C 417.4 336.9 404.9 334.7 393.6 332.1 C 382.3 329.4 369.0 323.4 361.0 320.1 C 353.1 316.7 348.5 313.3 346.0 312.0" />
|
|
16
|
+
<path d="M 310.0 303.0 C 311.1 308.7 315.4 325.9 316.8 337.4 C 318.1 349.0 319.1 360.6 318.0 372.1 C 316.8 383.7 313.7 395.6 309.9 406.8 C 306.1 418.1 300.9 429.2 295.1 439.5 C 289.3 449.9 283.2 458.2 275.0 469.1 C 266.9 480.1 250.8 499.0 246.0 505.0" />
|
|
17
|
+
</svg>
|
|
18
|
+
<span class="brand">practi</span>
|
|
28
19
|
</a>
|
|
29
20
|
</header>
|
|
30
|
-
|
|
31
|
-
|
|
21
|
+
<!-- 二级 tab 行(hub /u/ ProfileTabs 位):灰底与页眉无缝合并;文案由 home.js 按 i18n 填 -->
|
|
22
|
+
<div class="tab-row">
|
|
23
|
+
<nav class="tabs" aria-label="tabs">
|
|
24
|
+
<button type="button" class="tab" data-tab="overview" aria-current="page">
|
|
25
|
+
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M12 7v14"/><path d="M3 18a1 1 0 0 1-1-1V4a1 1 0 0 1 1-1h5a4 4 0 0 1 4 4 4 4 0 0 1 4-4h5a1 1 0 0 1 1 1v13a1 1 0 0 1-1 1h-6a3 3 0 0 0-3 3 3 3 0 0 0-3-3z"/></svg>
|
|
26
|
+
<span data-i18n="tabOverview"></span>
|
|
27
|
+
</button>
|
|
28
|
+
<button type="button" class="tab" data-tab="practices">
|
|
29
|
+
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M15 6a9 9 0 0 0-9 9V3"/><circle cx="18" cy="6" r="3"/><circle cx="6" cy="18" r="3"/></svg>
|
|
30
|
+
<span data-i18n="tabPractices"></span>
|
|
31
|
+
<span class="tab-count" id="practice-count" hidden>0</span>
|
|
32
|
+
</button>
|
|
33
|
+
</nav>
|
|
34
|
+
</div>
|
|
35
|
+
<main id="app" class="u-main">
|
|
36
|
+
<div class="empty"><p class="lead">…</p></div>
|
|
32
37
|
</main>
|
|
33
38
|
<script src="/lang.js" defer></script>
|
|
34
39
|
<script src="/home.js" defer></script>
|
package/web-default/home.js
CHANGED
|
@@ -1,5 +1,8 @@
|
|
|
1
|
-
// practices
|
|
2
|
-
//
|
|
1
|
+
// practices 总览页:hub /u/ 个人页同构——二级 tab 行(总览/实践)+ [16rem_1fr] 栅格
|
|
2
|
+
// (左栏=用户名占位留空)。总览=最近 6 张实践卡双列网格+查看全部(GitHub Popular
|
|
3
|
+
// repositories 同构;贡献热力图无本地数据源不设);实践=查找框+全量堆叠列表(hub
|
|
4
|
+
// MyInstances 同构,纯前端过滤)。数据窗 /api/practices 家目录现扫清单;卡点击直达
|
|
5
|
+
// wizard(head 的向导页),无修订的实例回落链页。tab 态走 ?tab=practices(hub 同款 URL)。
|
|
3
6
|
'use strict';
|
|
4
7
|
|
|
5
8
|
(function () {
|
|
@@ -9,41 +12,151 @@
|
|
|
9
12
|
});
|
|
10
13
|
}
|
|
11
14
|
|
|
15
|
+
var all = []; // /api/practices 全量(updated 降序,服务端已排)
|
|
16
|
+
var query = ''; // 实践档查找词(纯前端过滤,hub MyInstances 同口径)
|
|
17
|
+
var tab = 'overview';
|
|
18
|
+
try {
|
|
19
|
+
if (new URLSearchParams(location.search).get('tab') === 'practices') tab = 'practices';
|
|
20
|
+
} catch (e) { /* 老浏览器:停在总览 */ }
|
|
21
|
+
|
|
12
22
|
function target(p) {
|
|
13
23
|
return p.head
|
|
14
24
|
? '/p/' + encodeURIComponent(p.name) + '/pop/' + encodeURIComponent(p.head.root)
|
|
15
25
|
: '/p/' + encodeURIComponent(p.name) + '/';
|
|
16
26
|
}
|
|
17
27
|
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
var
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
+ '<
|
|
24
|
-
+ '<
|
|
25
|
-
+ '<
|
|
26
|
-
+ '</
|
|
28
|
+
// 实践卡(hub InstanceCard 解剖:标题 / 摘录 line-clamp-2 / meta 沉底;无头像与徽章)
|
|
29
|
+
function card(p) {
|
|
30
|
+
var excerpt = p.head ? esc(p.head.message) : '<span class="none">' + esc(POP_I18N.t('homeNoRevisions')) + '</span>';
|
|
31
|
+
var date = p.updated ? esc(p.updated.slice(0, 10)) : '';
|
|
32
|
+
return '<a class="card" href="' + target(p) + '">'
|
|
33
|
+
+ '<p class="card-title">' + esc(p.name) + '</p>'
|
|
34
|
+
+ '<p class="card-excerpt">' + excerpt + '</p>'
|
|
35
|
+
+ '<p class="card-meta">' + esc(POP_I18N.t('commitCount', p.commits)) + (date ? ' · ' + date : '') + '</p>'
|
|
36
|
+
+ '</a>';
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
// 空态图标=hub GitBranch(lucide v1.24 重设计版,与 hub 同形)
|
|
40
|
+
var EMPTY_ICON = '<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M15 6a9 9 0 0 0-9 9V3"/><circle cx="18" cy="6" r="3"/><circle cx="6" cy="18" r="3"/></svg>';
|
|
41
|
+
|
|
42
|
+
function emptyHtml() {
|
|
43
|
+
return '<div class="empty">' + EMPTY_ICON
|
|
44
|
+
+ '<p class="lead">' + esc(POP_I18N.t('homeEmptyLead')) + '</p>'
|
|
45
|
+
+ '<p class="hint">' + POP_I18N.t('homeEmptyHint') + '</p></div>';
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
// ── 总览档:标题行(我的实践 + 截后计数 + 查看全部)+ 前 6 张双列网格(hub OverviewGrid)──
|
|
49
|
+
function overviewHtml() {
|
|
50
|
+
var list = all.slice(0, 6);
|
|
51
|
+
if (!list.length) return emptyHtml();
|
|
52
|
+
return '<div class="sec-head"><h2 class="sec-title">' + esc(POP_I18N.t('pageTitle'))
|
|
53
|
+
+ '<span class="sec-count">' + list.length + '</span></h2>'
|
|
54
|
+
+ '<button type="button" class="view-all" data-act="view-all">' + esc(POP_I18N.t('viewAll')) + '</button></div>'
|
|
55
|
+
+ '<div class="ov-grid">' + list.map(card).join('') + '</div>';
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
// ── 实践档:查找框工具行 + 全量堆叠列表(hub MyInstances;过滤命中 name/head message)──
|
|
59
|
+
function filtered() {
|
|
60
|
+
var q = query.trim().toLowerCase();
|
|
61
|
+
if (!q) return all;
|
|
62
|
+
return all.filter(function (p) {
|
|
63
|
+
return p.name.toLowerCase().indexOf(q) !== -1
|
|
64
|
+
|| (p.head && p.head.message ? p.head.message.toLowerCase().indexOf(q) !== -1 : false);
|
|
65
|
+
});
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
function stackHtml(items) {
|
|
69
|
+
return '<div class="stack-list">' + items.map(card).join('') + '</div>';
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
function practicesHtml() {
|
|
73
|
+
if (!all.length) return emptyHtml();
|
|
74
|
+
var html = '<div class="pr-toolbar"><div class="find-box">'
|
|
75
|
+
+ '<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><circle cx="11" cy="11" r="8"/><path d="m21 21-4.34-4.34"/></svg>'
|
|
76
|
+
+ '<input type="text" id="find-input" autocomplete="off" spellcheck="false" value="' + esc(query) + '" placeholder="' + esc(POP_I18N.t('findPlaceholder')) + '" aria-label="' + esc(POP_I18N.t('findPlaceholder')) + '">'
|
|
77
|
+
+ '</div></div>'
|
|
78
|
+
+ '<div id="plist">';
|
|
79
|
+
var items = filtered();
|
|
80
|
+
if (items.length === 0) {
|
|
81
|
+
html += '<div class="find-empty">' + esc(POP_I18N.t('findPlaceholder')) + ':' + esc(query.trim()) + '</div>';
|
|
82
|
+
} else {
|
|
83
|
+
html += stackHtml(items);
|
|
84
|
+
}
|
|
85
|
+
return html + '</div>';
|
|
27
86
|
}
|
|
28
87
|
|
|
88
|
+
// ── tab 行文案与选中态(按钮骨架在 home.html,此处只填文案/徽标/高亮)──
|
|
89
|
+
function renderTabs() {
|
|
90
|
+
var ov = document.querySelector('[data-tab="overview"] [data-i18n]');
|
|
91
|
+
var pr = document.querySelector('[data-tab="practices"] [data-i18n]');
|
|
92
|
+
if (ov) ov.textContent = POP_I18N.t('tabOverview');
|
|
93
|
+
if (pr) pr.textContent = POP_I18N.t('tabPractices');
|
|
94
|
+
Array.prototype.forEach.call(document.querySelectorAll('.tab'), function (btn) {
|
|
95
|
+
var on = btn.getAttribute('data-tab') === tab;
|
|
96
|
+
btn.classList.toggle('on', on);
|
|
97
|
+
if (on) btn.setAttribute('aria-current', 'page');
|
|
98
|
+
else btn.removeAttribute('aria-current');
|
|
99
|
+
});
|
|
100
|
+
var count = document.getElementById('practice-count');
|
|
101
|
+
if (count) {
|
|
102
|
+
count.textContent = String(all.length);
|
|
103
|
+
count.hidden = all.length === 0;
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
function setTab(t) {
|
|
108
|
+
tab = t;
|
|
109
|
+
try {
|
|
110
|
+
history.replaceState(null, '', t === 'practices' ? '?tab=practices' : location.pathname);
|
|
111
|
+
} catch (e) { /* file: 等环境:只切视图不同步 URL */ }
|
|
112
|
+
renderTabs();
|
|
113
|
+
renderApp();
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
function renderApp() {
|
|
117
|
+
var app = document.getElementById('app');
|
|
118
|
+
app.innerHTML = '<div class="u-grid"><aside aria-hidden="true"></aside><div class="u-content">'
|
|
119
|
+
+ (tab === 'overview' ? overviewHtml() : practicesHtml())
|
|
120
|
+
+ '</div></div>';
|
|
121
|
+
if (tab === 'overview') {
|
|
122
|
+
var va = app.querySelector('[data-act="view-all"]');
|
|
123
|
+
if (va) va.addEventListener('click', function () { setTab('practices'); });
|
|
124
|
+
} else {
|
|
125
|
+
var input = app.querySelector('#find-input');
|
|
126
|
+
if (input) {
|
|
127
|
+
input.addEventListener('input', function () {
|
|
128
|
+
query = input.value;
|
|
129
|
+
var items = filtered();
|
|
130
|
+
var plist = app.querySelector('#plist');
|
|
131
|
+
if (!plist) return;
|
|
132
|
+
plist.innerHTML = items.length === 0
|
|
133
|
+
? '<div class="find-empty">' + esc(POP_I18N.t('findPlaceholder')) + ':' + esc(query.trim()) + '</div>'
|
|
134
|
+
: stackHtml(items);
|
|
135
|
+
});
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
Array.prototype.forEach.call(document.querySelectorAll('.tab'), function (btn) {
|
|
141
|
+
btn.addEventListener('click', function () {
|
|
142
|
+
var t = btn.getAttribute('data-tab');
|
|
143
|
+
if (t && t !== tab) setTab(t);
|
|
144
|
+
});
|
|
145
|
+
});
|
|
146
|
+
|
|
29
147
|
fetch('/api/practices')
|
|
30
148
|
.then(function (r) { return r.json(); })
|
|
31
149
|
.then(function (list) {
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
+ '<p class="hint">' + POP_I18N.t('homeEmptyHint') + '</p></div>';
|
|
36
|
-
return;
|
|
37
|
-
}
|
|
38
|
-
app.innerHTML = '<h1 class="page-title">' + esc(POP_I18N.t('pageTitle')) + '</h1>'
|
|
39
|
-
+ '<table class="practices"><thead><tr>'
|
|
40
|
-
+ '<th>' + esc(POP_I18N.t('thPractice')) + '</th>'
|
|
41
|
-
+ '<th>' + esc(POP_I18N.t('homeHead')) + '</th>'
|
|
42
|
-
+ '<th class="num">' + esc(POP_I18N.t('thCommits')) + '</th>'
|
|
43
|
-
+ '<th class="time">' + esc(POP_I18N.t('homeUpdated')) + '</th>'
|
|
44
|
-
+ '</tr></thead><tbody>' + list.map(row).join('') + '</tbody></table>';
|
|
150
|
+
all = Array.isArray(list) ? list : [];
|
|
151
|
+
renderTabs();
|
|
152
|
+
renderApp();
|
|
45
153
|
})
|
|
46
154
|
.catch(function (e) {
|
|
47
|
-
document.getElementById('app').innerHTML = '<div class="empty">' + esc((e && e.message) || String(e)) + '</div>';
|
|
155
|
+
document.getElementById('app').innerHTML = '<div class="empty"><p class="lead">' + esc((e && e.message) || String(e)) + '</p></div>';
|
|
48
156
|
});
|
|
157
|
+
|
|
158
|
+
POP_I18N.onChange(function () {
|
|
159
|
+
renderTabs();
|
|
160
|
+
renderApp();
|
|
161
|
+
});
|
|
49
162
|
})();
|