diff --git a/site/.gitignore b/site/.gitignore index 41a257894..a28e9fc96 100644 --- a/site/.gitignore +++ b/site/.gitignore @@ -1,2 +1,5 @@ .wrangler/ node_modules/ +public/contributors.json +public/contributors.json.tmp +public/contributors/ diff --git a/site/credits-cli.mjs b/site/credits-cli.mjs index 3d942daf9..fdba09ce3 100644 --- a/site/credits-cli.mjs +++ b/site/credits-cli.mjs @@ -6,16 +6,22 @@ // Chinese on the second, nothing when no one is credited. yetone/ // magpie-releases' release run calls it for the commits since the last // tag. +// node site/credits-cli.mjs wall [out] +// public/contributors.json (or out) from every tag's commits, and the +// contributors page's table in each language beside it +// (public/contributors/en.html, zh, ja), which worker.js puts into the +// page. wrangler.jsonc's build runs it at each deploy. // // The issue and PR authors a subject's "(#N)" names are asked of GitHub's // GraphQL API with GH_TOKEN, GITHUB_TOKEN or `gh auth token`. When that -// can't be read, those people are left out; the rest still goes out. Names in +// can't be read, those people are left out (and `wall` keeps the authors +// its last output knew); the rest still goes out. Names in // contributors-exclude.txt are never given. import { execFileSync } from "node:child_process"; -import { readFileSync } from "node:fs"; +import { readFileSync, writeFileSync, renameSync, existsSync, mkdirSync } from "node:fs"; import { dirname, join } from "node:path"; import { fileURLToPath } from "node:url"; -import { credit, everyone, thanks, refKey, parse } from "./credits.mjs"; +import { credit, everyone, thanks, wall, refKey, parse, renderWall } from "./credits.mjs"; const here = dirname(fileURLToPath(import.meta.url)); const warn = (m) => process.stderr.write(`credits: ${m}\n`); @@ -101,8 +107,41 @@ async function cmdThanks(range) { if (en) process.stdout.write(en + "\n" + thanks(people, "zh") + "\n"); } +async function cmdWall(out = join(here, "public", "contributors.json")) { + let before = {}; + try { before = JSON.parse(readFileSync(out, "utf8")); } catch {} + let commits; + try { + commits = log(["--topo-order", "--reverse", "--decorate-refs=refs/tags/v*", "HEAD"]); + } catch (e) { + warn(`git log failed (${e.message.split("\n")[0]}); ${existsSync(out) ? "the last list is kept" : "no list is written"}`); + return; + } + // a commit goes out in the first tag at or after it + let pending = []; + for (const c of commits) { + pending.push(c); + if (c.tags.length) { + const v = c.tags.map((t) => t.slice(1)).sort((a, b) => a.localeCompare(b, "en", { numeric: true }))[0]; + for (const p of pending) p.v = v; + pending = []; + } + } + const released = commits.filter((c) => c.v && c.parents < 2); + const refs = released.flatMap((c) => parse(c.subject).refs); + const issueAuthors = await authors(refs, { known: before.issueAuthors || {} }); + const people = wall(released, { issueAuthors, exclude: excluded() }); + const data = { generated: new Date().toISOString(), head: commits.length ? commits.at(-1).sha : "", issueAuthors, people }; + const put = (file, text) => { writeFileSync(file + ".tmp", text); renameSync(file + ".tmp", file); }; + put(out, JSON.stringify(data) + "\n"); + const dir = join(dirname(out), "contributors"); + mkdirSync(dir, { recursive: true }); + for (const lang of ["en", "zh", "ja"]) put(join(dir, `${lang}.html`), renderWall(data, lang) + "\n"); + warn(`${people.length} people over ${released.length} released commits → ${out}`); +} + if (process.argv[1] && fileURLToPath(import.meta.url) === process.argv[1]) { const [cmd, arg] = process.argv.slice(2); - const run = cmd === "thanks" ? cmdThanks(arg) : Promise.reject(new Error("usage: credits-cli.mjs thanks ..")); - run.catch((e) => { warn(e.message); process.exit(1); }); + const run = cmd === "thanks" ? cmdThanks(arg) : cmd === "wall" ? cmdWall(arg) : Promise.reject(new Error("usage: credits-cli.mjs thanks | wall [out]")); + run.catch((e) => { warn(e.message); process.exit(cmd === "wall" ? 0 : 1); }); } diff --git a/site/credits.mjs b/site/credits.mjs index be177856d..3051c89d5 100644 --- a/site/credits.mjs +++ b/site/credits.mjs @@ -14,8 +14,9 @@ // counts only when it is shaped like a handle with digits ("mrwl666") or the // same name is credited plainly somewhere else ("axelburks on Discord"). // -// Used by credits-cli.mjs for the release notes' thanks line. It imports -// nothing, so the site's worker can use it too. +// Used by credits-cli.mjs (the release notes' thanks line, and +// public/contributors.json at deploy) and by worker.js (the contributors +// page). It imports nothing, so the worker can bundle it. export const MAINTAINERS = ["yetone"]; // agents and bots that author or co-author commits @@ -211,3 +212,79 @@ export function thanks(people, lang) { const list = names.length > 1 ? names.slice(0, -1).join(", ") + " and " + names.at(-1) : names[0]; return `Thanks to ${list}, whose reports and code went into this release. Everyone who helped: [contributors](${WALL.en}).`; } + +// The subject as the page shows it: its first part, without the brackets +// that only credit or number it. +export function what(subject) { + let s = String(subject).split(" — ")[0]; + s = s.replace(/\s*\(([^()]*)\)/g, (all, inner) => { + const one = { names: [], refs: [] }; + group(inner, one); + return one.names.length || one.refs.length ? "" : all; + }).trim(); + return s.length > 200 ? s.slice(0, 199) + "…" : s; +} + +// --- the contributors page --- + +const esc = (s) => String(s).replace(/[&<>"']/g, (c) => ({ "&": "&", "<": "<", ">": ">", '"': """, "'": "'" })[c]); +const WORDS = { + en: { name: "Who", led: "What came of it, newest first", more: (n) => `${n} more`, none: "The list isn't available right now." }, + zh: { name: "谁", led: "带来的改动,新的在前", more: (n) => `还有 ${n} 项`, none: "名单暂时无法显示。" }, + ja: { name: "誰が", led: "そこから生まれた変更(新しい順)", more: (n) => `ほか ${n} 件`, none: "一覧は今は表示できません。" }, +}; +const SHOWN = 3; +const RELEASE = (v) => `https://github.com/yetone/magpie-releases/releases/tag/v${encodeURIComponent(v)}`; + +// The table the page shows from contributors.json's data. +export function renderWall(data, lang) { + const w = WORDS[lang] || WORDS.en; + const people = data && Array.isArray(data.people) ? data.people : []; + if (!people.length) return `

${esc(w.none)}

`; + const line = (r) => r.what.map((t) => `
  • v${esc(r.v)} ${esc(t)}
  • `).join(""); + const rows = people.map((p) => { + const name = p.github ? `${esc(p.name)}` : esc(p.name); + const via = (p.via || []).length ? `
    ${p.via.map(esc).join(" · ")}` : ""; + const items = []; + for (const r of p.releases || []) for (const t of r.what || []) items.push({ v: r.v, what: [t] }); + const head = items.slice(0, SHOWN).map(line).join(""); + const rest = items.slice(SHOWN); + const more = rest.length ? `
    ${esc(w.more(rest.length))}
      ${rest.map(line).join("")}
    ` : ""; + return `${name}${via}
      ${head}
    ${more}`; + }).join(""); + return `
    ${rows}
    ${esc(w.name)}${esc(w.led)}
    `; +} + +const vnum = (v) => String(v).split(".").map((x) => parseInt(x, 10) || 0); +export function newer(a, b) { + const x = vnum(a), y = vnum(b); + for (let i = 0; i < Math.max(x.length, y.length); i++) if ((x[i] || 0) !== (y[i] || 0)) return (x[i] || 0) > (y[i] || 0); + return false; +} + +// contributors.json's people from released commits ({ ...commit, v }): +// each person with the versions their reports led to, newest first. +export function wall(commits, opts) { + const per = credit(commits, opts); + const all = new Map(); + commits.forEach((c, i) => { + if (!c.v) return; + for (const p of per[i]) { + let e = all.get(p.key); + if (!e) all.set(p.key, (e = { name: p.name, via: [], github: "", byV: new Map() })); + for (const v of p.via) if (!e.via.includes(v)) e.via.push(v); + if (p.github) e.github = p.github; + if (!e.byV.has(c.v)) e.byV.set(c.v, []); + const t = what(c.subject); + if (t && !e.byV.get(c.v).includes(t)) e.byV.get(c.v).push(t); + } + }); + const people = [...all.values()].map((e) => { + const releases = [...e.byV.entries()].map(([v, w]) => ({ v, what: w })).sort((a, b) => (newer(a.v, b.v) ? -1 : newer(b.v, a.v) ? 1 : 0)); + const out = { name: e.name, via: e.via, releases }; + if (e.github) out.github = e.github; + return out; + }); + people.sort((a, b) => (newer(a.releases[0].v, b.releases[0].v) ? -1 : newer(b.releases[0].v, a.releases[0].v) ? 1 : lower(a.name) < lower(b.name) ? -1 : 1)); + return people; +} diff --git a/site/credits.test.mjs b/site/credits.test.mjs index b040bac17..d3f4464ab 100644 --- a/site/credits.test.mjs +++ b/site/credits.test.mjs @@ -2,7 +2,7 @@ // one from yetone/magpie's own history, word for word. import test from "node:test"; import assert from "node:assert/strict"; -import { parse, credit, everyone, thanks } from "./credits.mjs"; +import { parse, credit, everyone, thanks, what, wall, renderWall } from "./credits.mjs"; import { authors, excluded } from "./credits-cli.mjs"; import { mkdtempSync, writeFileSync, rmSync } from "node:fs"; import { tmpdir } from "node:os"; @@ -91,6 +91,8 @@ test("commit authors and co-authors are credited, agents and machines not, and n test("the exclusion list leaves a person out everywhere", () => { const s = "library: an MCP router says which computer it is, so an agent can pick between two (packinggoodsllc_07668 on Discord)"; assert.deepEqual(names(s, { exclude: ["PackingGoodsLLC_07668"] }), []); + const commits = [{ subject: s, v: "0.1.2569" }]; + assert.deepEqual(wall(commits, { exclude: ["packinggoodsllc_07668"] }), []); assert.deepEqual(excluded(), []); // the checked-in list has comments only const dir = mkdtempSync(join(tmpdir(), "credits-")); try { @@ -113,6 +115,25 @@ test("the release notes' thanks line, in English and Chinese", () => { assert.equal(thanks([], "en"), ""); }); +test("the page shows what each person's reports led to, newest first", () => { + assert.equal(what("redact: a decimal's digits are not masked as a number of their own (willz, Discord)"), "redact: a decimal's digits are not masked as a number of their own"); + assert.equal(what("plugin: gateway key limits are the Key limits plugin on the gateway's budget point (P3)"), "plugin: gateway key limits are the Key limits plugin on the gateway's budget point (P3)"); + const people = wall([ + { subject: "search: searchers picked to follow the one named, tried in their order when it fails (axelburks on Discord)", v: "0.1.2561" }, + { subject: "gui: Busy models last takes a custom threshold, 1 to 9999 (axelburks)", v: "0.1.2564" }, + { subject: "redact: a decimal's digits are not masked as a number of their own (willz, Discord)", v: "0.1.2560" }, + ]); + assert.deepEqual(people.map((p) => [p.name, p.releases.map((r) => r.v)]), [["axelburks", ["0.1.2564", "0.1.2561"]], ["willz", ["0.1.2560"]]]); + const html = renderWall({ people: [{ name: "x", via: ["Discord"], github: "x", releases: [{ v: "0.1.1", what: ["a & b"] }] }] }, "zh"); + assert.match(html, /<b>x<\/b>/); + assert.match(html, /a & b/); + assert.match(html, /releases\/tag\/v0\.1\.1/); + assert.match(html, /新的在前/); + assert.match(renderWall({}, "ja"), /一覧/); + const many = renderWall({ people: [{ name: "n", releases: [1, 2, 3, 4, 5].map((i) => ({ v: `0.1.${i}`, what: ["w"] })) }] }, "en"); + assert.match(many, /2 more<\/summary>/); +}); + test("issue authors GitHub can't give are left out, not guessed", async () => { const refs = [{ repo: "yetone/magpie", n: 1 }, { repo: "yetone/magpie", n: 2 }]; const ok = async () => ({ ok: true, json: async () => ({ data: { repository: { i1: { author: { login: "alice", __typename: "User" } }, i2: { author: { login: "dependabot", __typename: "Bot" } } } } }) }); diff --git a/site/i18n.js b/site/i18n.js index 62aff26ce..947dd0c1a 100644 --- a/site/i18n.js +++ b/site/i18n.js @@ -138,6 +138,7 @@ const zh = { "plat.win": "10 及以上", "foot.start": "快速上手", "foot.feed": "更新源", + "foot.contrib": "贡献墙", "foot.apache": "与 Apache Magpie 及 Apache 软件基金会没有隶属关系。", "nav.masking": "脱敏", @@ -288,6 +289,7 @@ const ja = { "plat.win": "10 以降", "foot.start": "はじめに", "foot.feed": "更新フィード", + "foot.contrib": "コントリビューター", "foot.apache": "Apache Magpie および Apache Software Foundation とは関係ありません。", "nav.masking": "マスク", @@ -438,6 +440,7 @@ const de = { "plat.win": "10 oder neuer", "foot.start": "Erste Schritte", "foot.feed": "Update-Feed", + "foot.contrib": "Mitwirkende", "foot.apache": "Nicht verbunden mit Apache Magpie oder der Apache Software Foundation.", "nav.masking": "Maskierung", diff --git a/site/public/docs.css b/site/public/docs.css index d11408586..fa80843bf 100644 --- a/site/public/docs.css +++ b/site/public/docs.css @@ -154,6 +154,13 @@ pre .s { color: var(--ink2); } .url .v { color: var(--ink2); } .table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: 12px; margin: 0 0 20px; background: var(--card); } +/* the contributors page's list (credits.mjs renderWall) */ +.cw td:first-child { min-width: 8em; white-space: normal; overflow-wrap: anywhere; } +.cw ul { margin: 0; padding: 0; list-style: none; } +.cw li { margin: 0 0 4px; } +.cw details summary { cursor: pointer; color: var(--ink2); font-size: 13px; } +.cw details ul { margin-top: 4px; } +.cw-via { color: var(--ink3); font-size: 12px; font-weight: 400; } table { width: 100%; border-collapse: collapse; font-size: 14.5px; } th, td { text-align: left; padding: 11px 16px; border-bottom: 1px solid var(--line); vertical-align: top; } tr:last-child td { border-bottom: 0; } diff --git a/site/public/docs/contributors.html b/site/public/docs/contributors.html new file mode 100644 index 000000000..4b9ea79fc --- /dev/null +++ b/site/public/docs/contributors.html @@ -0,0 +1,143 @@ + + + + + +Contributors · magpie docs + + + + + + + + + + + + + + + + + + + + + +
    + + +
    +

    Docs · Contributors

    +

    Contributors

    +

    magpie is shaped by the people who tell us what broke and ask for what is missing. Everyone below is credited in magpie’s history, with the releases their reports, ideas or code went into, newest first. Thank you.

    + +

    The list

    +

    The list is built from git history when the site is deployed, and isn’t here right now. Each release’s notes on GitHub end with the people it thanks.

    + +

    How names are found

    +

    A name is listed when one of these is true of a commit that went out in a release:

    +
      +
    • its subject credits the person, as in (name on Discord) or (spotted by @login);
    • +
    • it names an issue or pull request (#1234, plugins#56) the person opened on GitHub;
    • +
    • the person wrote it, or is a co-author on it.
    • +
    +

    Only names already public in magpie’s history are used, as they are written there; no email address is shown. The maintainer, coding agents and bots aren’t listed. A name that links to GitHub is that account; a platform under a name is where the report came from. The list is brought up to date each time the site is deployed, and each release’s notes thank its own people the same way.

    + +

    To be left off

    +

    If you don’t want your name here or in release notes, say so on Discord, open an issue, or send a pull request adding it to site/contributors-exclude.txt. It is left out from the next deploy and the next release. The same goes for a name that is wrong or missing.

    +
    +
    + + + + + + + diff --git a/site/public/docs/docker.html b/site/public/docs/docker.html index fe123d377..a1ca1d5e6 100644 --- a/site/public/docs/docker.html +++ b/site/public/docs/docker.html @@ -227,6 +227,7 @@ docker logs magpie Integrate GitHub Discord + Contributors Releases diff --git a/site/public/docs/import.html b/site/public/docs/import.html index 7b0b2a791..2ad3bb39c 100644 --- a/site/public/docs/import.html +++ b/site/public/docs/import.html @@ -269,6 +269,7 @@ href = "https://usemagpie.ai/import#" + urlencode({ MCP router GitHub Discord + Contributors Releases diff --git a/site/public/docs/integrate.html b/site/public/docs/integrate.html index 9a9a8c8cb..6757c4112 100644 --- a/site/public/docs/integrate.html +++ b/site/public/docs/integrate.html @@ -162,6 +162,7 @@ curl -s http://127.0.0.1:3425/v1/models -H "Authorization: Bearer magpie-acme"Integrate GitHub Discord + Contributors Releases diff --git a/site/public/docs/intent.html b/site/public/docs/intent.html index 8a25e3b1e..0ec1586e0 100644 --- a/site/public/docs/intent.html +++ b/site/public/docs/intent.html @@ -334,6 +334,7 @@ The number of its kind (0 for none): Integrate GitHub Discord + Contributors Releases diff --git a/site/public/docs/ja/contributors.html b/site/public/docs/ja/contributors.html new file mode 100644 index 000000000..6a348efdd --- /dev/null +++ b/site/public/docs/ja/contributors.html @@ -0,0 +1,143 @@ + + + + + +コントリビューター · magpie ドキュメント + + + + + + + + + + + + + + + + + + + + + +
    + + +
    +

    ドキュメント · コントリビューター

    +

    コントリビューター

    +

    magpie は、何が壊れたか、何が足りないかを教えてくれる人たちによって形作られています。以下の全員が magpie の履歴に名前が記されており、その報告やアイデア、コードが入ったリリースを新しい順に並べています。ありがとうございます。

    + +

    一覧

    +

    一覧はサイトをデプロイするたびに git の履歴から作られますが、今はここにありません。GitHub の各リリースノートの最後に、そのリリースで感謝する人が載っています。

    + +

    名前の集め方

    +

    リリースに入ったコミットが次のどれかに当てはまると、その名前が載ります。

    +
      +
    • コミットの件名にその人の名前がある((name on Discord)、(spotted by @login) など)。
    • +
    • コミットが挙げる issue や pull request(#1234、plugins#56)をその人が GitHub で開いた。
    • +
    • その人がコミットを書いた、または共同作者である。
    • +
    +

    magpie の履歴ですでに公開されている名前だけを、そこでの表記のまま使います。メールアドレスは表示しません。メンテナー、コーディングエージェント、ボットは載せません。GitHub へのリンクがある名前はそのアカウントで、名前の下のプラットフォームは報告が来た場所です。一覧はサイトをデプロイするたびに更新され、各リリースノートも同じ方法でそのリリースの人に感謝します。

    + +

    載せないでほしいとき

    +

    ここやリリースノートに名前を載せたくない場合は、Discord で伝えるか、issue を開くか、site/contributors-exclude.txt に名前を加える pull request を送ってください。次のデプロイと次のリリースから載らなくなります。名前の間違いや漏れも同じように教えてください。

    +
    +
    + + + + + + + diff --git a/site/public/docs/ja/docker.html b/site/public/docs/ja/docker.html index f68156848..3fe04e155 100644 --- a/site/public/docs/ja/docker.html +++ b/site/public/docs/ja/docker.html @@ -227,6 +227,7 @@ docker logs magpie アプリ連携 GitHub Discord + コントリビューター リリース diff --git a/site/public/docs/ja/import.html b/site/public/docs/ja/import.html index 58bebb127..813ac48fe 100644 --- a/site/public/docs/ja/import.html +++ b/site/public/docs/ja/import.html @@ -269,6 +269,7 @@ href = "https://usemagpie.ai/import#" + urlencode({ MCP ルーター GitHub Discord + コントリビューター リリース diff --git a/site/public/docs/ja/intent.html b/site/public/docs/ja/intent.html index fb69c2148..c7db79cda 100644 --- a/site/public/docs/ja/intent.html +++ b/site/public/docs/ja/intent.html @@ -334,6 +334,7 @@ The number of its kind (0 for none): アプリ連携 GitHub Discord + コントリビューター リリース diff --git a/site/public/docs/ja/masking.html b/site/public/docs/ja/masking.html index 02a1b4ac7..a4856bf1a 100644 --- a/site/public/docs/ja/masking.html +++ b/site/public/docs/ja/masking.html @@ -178,6 +178,7 @@ アプリ連携 GitHub Discord + コントリビューター リリース diff --git a/site/public/docs/ja/mcp-router.html b/site/public/docs/ja/mcp-router.html index e3f1f6fc6..b8ceb440a 100644 --- a/site/public/docs/ja/mcp-router.html +++ b/site/public/docs/ja/mcp-router.html @@ -141,6 +141,7 @@ magpie library mcp router off アプリ連携 GitHub Discord + コントリビューター リリース diff --git a/site/public/docs/ja/plugins.html b/site/public/docs/ja/plugins.html index 0a0495994..f0ac1425e 100644 --- a/site/public/docs/ja/plugins.html +++ b/site/public/docs/ja/plugins.html @@ -1027,6 +1027,7 @@ document.getElementById("calls").textContent = `${s.calls アプリ連携 GitHub Discord + コントリビューター リリース diff --git a/site/public/docs/ja/privacy.html b/site/public/docs/ja/privacy.html index 875d48ffe..757fa6f3d 100644 --- a/site/public/docs/ja/privacy.html +++ b/site/public/docs/ja/privacy.html @@ -223,6 +223,7 @@ アプリ連携 GitHub Discord + コントリビューター リリース diff --git a/site/public/docs/ja/remote.html b/site/public/docs/ja/remote.html index a7cb98052..9a81eb51b 100644 --- a/site/public/docs/ja/remote.html +++ b/site/public/docs/ja/remote.html @@ -237,6 +237,7 @@ curl -s http://127.0.0.1:3425/v1/magpie/concurrency アプリ連携 GitHub Discord + コントリビューター リリース diff --git a/site/public/docs/ja/start.html b/site/public/docs/ja/start.html index 0b913c953..a285813db 100644 --- a/site/public/docs/ja/start.html +++ b/site/public/docs/ja/start.html @@ -350,6 +350,7 @@ IP-CIDR6,::1/128,DIRECT,no-resolve アプリ連携 GitHub Discord + コントリビューター リリース diff --git a/site/public/docs/masking.html b/site/public/docs/masking.html index b7715eadf..00a078afe 100644 --- a/site/public/docs/masking.html +++ b/site/public/docs/masking.html @@ -178,6 +178,7 @@ Integrate GitHub Discord + Contributors Releases diff --git a/site/public/docs/mcp-router.html b/site/public/docs/mcp-router.html index 01405f469..b9c95b5cd 100644 --- a/site/public/docs/mcp-router.html +++ b/site/public/docs/mcp-router.html @@ -141,6 +141,7 @@ magpie library mcp router off Integrate GitHub Discord + Contributors Releases diff --git a/site/public/docs/plugins.html b/site/public/docs/plugins.html index c6d4f6e05..10cf14380 100644 --- a/site/public/docs/plugins.html +++ b/site/public/docs/plugins.html @@ -1027,6 +1027,7 @@ document.getElementById("calls").textContent = `${s.calls Integrate GitHub Discord + Contributors Releases diff --git a/site/public/docs/privacy.html b/site/public/docs/privacy.html index 82d6366a5..db0c2e976 100644 --- a/site/public/docs/privacy.html +++ b/site/public/docs/privacy.html @@ -223,6 +223,7 @@ Integrate GitHub Discord + Contributors Releases diff --git a/site/public/docs/remote.html b/site/public/docs/remote.html index 1076c282f..147423f8a 100644 --- a/site/public/docs/remote.html +++ b/site/public/docs/remote.html @@ -237,6 +237,7 @@ curl -s http://127.0.0.1:3425/v1/magpie/concurrency Integrate GitHub Discord + Contributors Releases diff --git a/site/public/docs/start.html b/site/public/docs/start.html index f3e9ae3bb..bf1c876bf 100644 --- a/site/public/docs/start.html +++ b/site/public/docs/start.html @@ -350,6 +350,7 @@ IP-CIDR6,::1/128,DIRECT,no-resolve Integrate GitHub Discord + Contributors Releases diff --git a/site/public/docs/zh/contributors.html b/site/public/docs/zh/contributors.html new file mode 100644 index 000000000..718ed685f --- /dev/null +++ b/site/public/docs/zh/contributors.html @@ -0,0 +1,143 @@ + + + + + +贡献墙 · magpie 文档 + + + + + + + + + + + + + + + + + + + + + +
    + + +
    +

    文档 · 贡献墙

    +

    贡献墙

    +

    magpie 是被告诉我们哪里坏了、还缺什么的人塑造出来的。下面每个人都在 magpie 的历史里被记了名,后面是他们的反馈、建议或代码进入的版本,新的在前。谢谢你们。

    + +

    名单

    +

    名单在每次部署网站时从 git 历史生成,现在暂时不在这里。GitHub 上每个版本的更新说明末尾都列出了这次感谢的人。

    + +

    名单怎么来的

    +

    进入某个已发布版本的提交满足下面任意一条,就会列出这个名字:

    +
      +
    • 提交标题里记了这个人,比如 (name on Discord) 或 (spotted by @login);
    • +
    • 提交提到的 issue 或 pull request(#1234、plugins#56)是这个人在 GitHub 上开的;
    • +
    • 提交是这个人写的,或者这个人是共同作者。
    • +
    +

    只用 magpie 历史里本来就公开的名字,按那里的写法;不显示任何邮箱。维护者、编码代理和机器人不列出。带 GitHub 链接的名字就是那个账号;名字下面的平台是反馈的来源。每次部署网站时名单会更新,每个版本的更新说明也按同样的方式感谢这次的人。

    + +

    不想被列出

    +

    如果不想出现在这里或更新说明里,在 Discord 说一声、开一个 issue,或者发 pull request 把名字加进 site/contributors-exclude.txt。下次部署和下个版本起就不再列出。名字写错或漏了,也一样告诉我们。

    +
    +
    + + + + + + + diff --git a/site/public/docs/zh/docker.html b/site/public/docs/zh/docker.html index 089613ac6..04b624308 100644 --- a/site/public/docs/zh/docker.html +++ b/site/public/docs/zh/docker.html @@ -227,6 +227,7 @@ docker logs magpie 接入应用 GitHub Discord + 贡献墙 版本发布 diff --git a/site/public/docs/zh/import.html b/site/public/docs/zh/import.html index 769ab5eba..a6d4d11e3 100644 --- a/site/public/docs/zh/import.html +++ b/site/public/docs/zh/import.html @@ -269,6 +269,7 @@ href = "https://usemagpie.ai/import#" + urlencode({ MCP 路由 GitHub Discord + 贡献墙 版本发布 diff --git a/site/public/docs/zh/integrate.html b/site/public/docs/zh/integrate.html index 000436172..9b7e516af 100644 --- a/site/public/docs/zh/integrate.html +++ b/site/public/docs/zh/integrate.html @@ -162,6 +162,7 @@ curl -s http://127.0.0.1:3425/v1/models -H "Authorization: Bearer magpie-acme"接入应用 GitHub Discord + 贡献墙 版本发布 diff --git a/site/public/docs/zh/intent.html b/site/public/docs/zh/intent.html index 54b739885..1ccddbc65 100644 --- a/site/public/docs/zh/intent.html +++ b/site/public/docs/zh/intent.html @@ -334,6 +334,7 @@ The number of its kind (0 for none): 接入应用 GitHub Discord + 贡献墙 版本发布 diff --git a/site/public/docs/zh/masking.html b/site/public/docs/zh/masking.html index 3d8eae645..9e7eb52df 100644 --- a/site/public/docs/zh/masking.html +++ b/site/public/docs/zh/masking.html @@ -178,6 +178,7 @@ 接入应用 GitHub Discord + 贡献墙 版本发布 diff --git a/site/public/docs/zh/mcp-router.html b/site/public/docs/zh/mcp-router.html index 4b96db3cf..ee8306327 100644 --- a/site/public/docs/zh/mcp-router.html +++ b/site/public/docs/zh/mcp-router.html @@ -141,6 +141,7 @@ magpie library mcp router off 接入应用 GitHub Discord + 贡献墙 版本发布 diff --git a/site/public/docs/zh/plugins.html b/site/public/docs/zh/plugins.html index 6a7c0979f..55d0de926 100644 --- a/site/public/docs/zh/plugins.html +++ b/site/public/docs/zh/plugins.html @@ -1027,6 +1027,7 @@ document.getElementById("calls").textContent = `${s.calls 接入应用 GitHub Discord + 贡献墙 版本发布 diff --git a/site/public/docs/zh/privacy.html b/site/public/docs/zh/privacy.html index d7affa466..4195f639a 100644 --- a/site/public/docs/zh/privacy.html +++ b/site/public/docs/zh/privacy.html @@ -223,6 +223,7 @@ 接入应用 GitHub Discord + 贡献墙 版本发布 diff --git a/site/public/docs/zh/remote.html b/site/public/docs/zh/remote.html index 33a58681b..bca091bbf 100644 --- a/site/public/docs/zh/remote.html +++ b/site/public/docs/zh/remote.html @@ -237,6 +237,7 @@ curl -s http://127.0.0.1:3425/v1/magpie/concurrency 接入应用 GitHub Discord + 贡献墙 版本发布 diff --git a/site/public/docs/zh/start.html b/site/public/docs/zh/start.html index 5b4bf9227..4befc3c5d 100644 --- a/site/public/docs/zh/start.html +++ b/site/public/docs/zh/start.html @@ -350,6 +350,7 @@ IP-CIDR6,::1/128,DIRECT,no-resolve 接入应用 GitHub Discord + 贡献墙 版本发布 diff --git a/site/public/index.html b/site/public/index.html index 82480e892..7c44cbb80 100644 --- a/site/public/index.html +++ b/site/public/index.html @@ -741,6 +741,7 @@ magpie tui # t GitHub Discord Releases + Contributors Update feed @yetone diff --git a/site/worker.js b/site/worker.js index 5dd7c293c..cb8d7fbe9 100644 --- a/site/worker.js +++ b/site/worker.js @@ -23,6 +23,10 @@ // a picture a plugin, market or import link names, // fetched here so its host sees Cloudflare, not the // user (the app fetches every remote icon this way) +// /docs/contributors, /docs/zh/contributors, /docs/ja/contributors +// the contributors page, its table put in from +// public/contributors/.html (credits-cli.mjs +// wall, at each deploy) // /download the Apple Silicon dmg // /download/mac-arm64 the same; /download/mac-intel the Intel dmg // /download/windows the Windows app (x64); /download/windows-arm64 @@ -146,7 +150,7 @@ export default { // a page not written in that language yet stays English if (DOC_LANGS.includes(lang) && (await env.ASSETS.fetch(new Request(new URL(there, url), { method: "HEAD" }))).ok) return new Response(null, { status: 302, headers: { Location: there + url.search, ...vary } }); - const res = beacon(await env.ASSETS.fetch(req)); + const res = beacon(await withWall(await env.ASSETS.fetch(req), env, url)); const out = new Response(res.body, res); out.headers.append("Vary", "Accept-Language, Cookie"); out.headers.set("Cache-Control", "no-cache"); @@ -171,7 +175,7 @@ export default { } if (url.pathname === "/install.sh" && req.method === "GET") ctx.waitUntil(capture("magpie site install script", { client: client(req), country: country(req) })); - return beacon(await env.ASSETS.fetch(req)); + return beacon(await withWall(await env.ASSETS.fetch(req), env, url)); }, // the cron (wrangler.jsonc's triggers) keeps the ledger the Stable // channel is chosen from @@ -362,6 +366,22 @@ export async function relay(req, url) { const WEB_ANALYTICS = ``; const BEACON = `` + WEB_ANALYTICS; +// The contributors page: its #wall gets the table credits-cli.mjs rendered +// for that language at deploy. Without it (a deploy that couldn't build +// it) the page keeps the line it is written with. +const WALL_PAGE = /^\/docs\/(?:(zh|ja)\/)?contributors(?:\.html)?$/; +export async function withWall(res, env, url) { + const m = url.pathname.match(WALL_PAGE); + if (!m || !res.ok || !(res.headers.get("Content-Type") || "").startsWith("text/html")) return res; + let table = ""; + try { + const got = await env.ASSETS.fetch(new Request(new URL(`/contributors/${m[1] || "en"}.html`, url))); + if (got.ok) table = await got.text(); + } catch {} + if (!table.includes(" el.setInnerContent(table, { html: true }) }).transform(res); +} + function beacon(res) { if (!(res.headers.get("Content-Type") || "").startsWith("text/html")) return res; return new HTMLRewriter().on("body", { element: (el) => el.append(BEACON, { html: true }) }).transform(res); diff --git a/site/worker.test.mjs b/site/worker.test.mjs index 2d51e4d0b..ce83717d7 100644 --- a/site/worker.test.mjs +++ b/site/worker.test.mjs @@ -580,3 +580,88 @@ test("sponsors: the home page and the READMEs link every sponsor through /go", a const home = readFileSync(pages.home[0], "utf8"); for (const s of SPONSORS.filter((s) => s.home)) assert.ok(home.includes(`href="/go/${s.id}/home"`), s.id); }); + +// HTMLRewriter is Cloudflare's; this stands in for the two uses here: a +// selector's inner content set, and the body appended to +class FakeRewriter { + constructor() { this.h = []; } + on(sel, h) { this.h.push([sel, h]); return this; } + transform(res) { + const hs = this.h; + return new Response(new ReadableStream({ + async start(c) { + let t = await res.text(); + for (const [sel, h] of hs) { + let inner, tail = ""; + h.element({ setInnerContent: (x) => (inner = x), append: (x) => (tail += x) }); + if (sel === "#wall" && inner !== undefined) t = t.replace(/(
    )[\s\S]*?(<\/div>)/, (_, a, b) => a + inner + b); + if (sel === "body") t = t.replace("", tail + ""); + } + c.enqueue(new TextEncoder().encode(t)); + c.close(); + }, + }), res); + } +} + +test("contributors: each language's page gets its own table, and keeps its line without one", async () => { + const { readFileSync } = await import("node:fs"); + const { renderWall } = await import("./credits.mjs"); + const data = { people: [{ name: "packinggoodsllc_07668", via: ["Discord"], releases: [{ v: "0.1.2581", what: ["a contributors page"] }] }] }; + const page = (p) => new URL(`./public${p}.html`, import.meta.url); + let fragments = true; + const asked = []; + const env = { + ASSETS: { + fetch: async (r) => { + const p = new URL(r.url).pathname.replace(/\.html$/, ""); + asked.push(p); + const m = p.match(/^\/contributors\/(en|zh|ja)$/); + if (m) return fragments ? new Response(renderWall(data, m[1]), { headers: { "Content-Type": "text/html" } }) : new Response("nf", { status: 404 }); + try { return new Response(readFileSync(page(p), "utf8"), { headers: { "Content-Type": "text/html; charset=utf-8" } }); } catch { return new Response("nf", { status: 404 }); } + }, + }, + }; + const was = globalThis.HTMLRewriter; + globalThis.HTMLRewriter = FakeRewriter; + try { + const get = async (path) => (await worker.fetch(new Request(`https://usemagpie.ai${path}`, { headers: { Cookie: "lang=en" } }), env, ctx)).text(); + for (const [path, lang, head] of [["/docs/contributors", "en", "What came of it"], ["/docs/zh/contributors", "zh", "带来的改动"], ["/docs/ja/contributors.html", "ja", "そこから生まれた"]]) { + const html = await get(path); + assert.match(html, /
    /, path); + assert.ok(html.includes(head), `${path} has the ${lang} table`); + assert.ok(html.includes("packinggoodsllc_07668") && html.includes("v0.1.2581"), path); + assert.match(html, /static\.cloudflareinsights\.com/, `${path} keeps the beacon`); + } + fragments = false; + const bare = await get("/docs/zh/contributors"); + assert.ok(!bare.includes('
    ')); + assert.match(bare, /

    名单在每次部署网站时/); + // no other page asks for a table + asked.length = 0; + await get("/docs/start"); + assert.deepEqual(asked, ["/docs/start"]); + } finally { + globalThis.HTMLRewriter = was; + } +}); + +test("contributors: the pages say how to be left off, and every docs footer links them", async () => { + const { readFileSync, readdirSync } = await import("node:fs"); + const dir = (d) => new URL(`./public/docs/${d}`, import.meta.url); + for (const [pre, file] of [["/docs/", "contributors.html"], ["/docs/zh/", "zh/contributors.html"], ["/docs/ja/", "ja/contributors.html"]]) { + const html = readFileSync(dir(file), "utf8"); + assert.match(html, /

    /, file); + assert.ok(html.includes("site/contributors-exclude.txt"), file); + for (const l of ["en", "zh", "ja"]) assert.ok(html.includes(`hreflang="${l}" href="https://usemagpie.ai/docs/${l === "en" ? "" : l + "/"}contributors"`), `${file} ${l}`); + assert.ok(!/privacy" hreflang=|og:url" content="[^"]*privacy/.test(html), `${file} still points at the page it was made from`); + } + for (const sub of ["", "zh/", "ja/"]) { + const pre = `/docs/${sub}`; + for (const f of readdirSync(dir(sub)).filter((f) => f.endsWith(".html"))) { + const foot = readFileSync(dir(sub + f), "utf8").split("`), `${sub}${f}'s footer`); + } + } + assert.ok(readFileSync(new URL("./public/index.html", import.meta.url), "utf8").includes('')); +}); diff --git a/site/wrangler.jsonc b/site/wrangler.jsonc index 9ffaf5161..cd340a1c9 100644 --- a/site/wrangler.jsonc +++ b/site/wrangler.jsonc @@ -4,6 +4,9 @@ "name": "usemagpie", "main": "worker.js", "compatibility_date": "2026-09-01", + // the contributors page's list, from git history (credits-cli.mjs); a + // build that can't read git or GitHub keeps the last list, or none + "build": { "command": "node credits-cli.mjs wall" }, "assets": { "directory": "./public", "binding": "ASSETS",