From 68234ac4075d4e55b2b5ee5f3acc5d5e9136b08e Mon Sep 17 00:00:00 2001 From: Ludovic Marie <136255825+ludovic111@users.noreply.github.com> Date: Sun, 25 Oct 2026 15:59:31 +0100 Subject: [PATCH] Hub: the roadmap at /data/roadmap.json and items at hub#, as Kira reads them Kira (kira #10-#14) fetches https://playhorizon.dev/data/roadmap.json and links items as #: the JSON moves there (readable from any origin) with the announce flag, and each item's anchor is its id. Ids the page uses itself (tabs, sections, headings) are refused by the check; a test keeps every id of the page unique, which caught the overview's headings sharing ids with the roadmap's. Co-Authored-By: Claude Opus 5.5 --- tests/test_roadmap.py | 4 ++++ tools/roadmap.py | 10 ++++++++-- website/Caddyfile | 5 ++++- website/README.md | 2 +- website/build.mjs | 6 +++--- website/data/roadmap.json | 15 ++++++++++----- website/src/hub-page.js | 6 +++--- website/src/hub.js | 22 +++++++++++----------- website/src/hub.test.mjs | 11 +++++++++-- 9 files changed, 53 insertions(+), 28 deletions(-) diff --git a/tests/test_roadmap.py b/tests/test_roadmap.py index 641d4e11b..605843f25 100644 --- a/tests/test_roadmap.py +++ b/tests/test_roadmap.py @@ -121,6 +121,10 @@ class Rules(unittest.TestCase): self.assertTrue(any("link" in p for p in self.problems(links=["docs/nothing-here.md"]))) self.assertTrue(any("link" in p for p in self.problems(links=["http://example.com"]))) + def test_ids_are_free_anchors_of_the_hub(self): + for taken in ("roadmap", "now", "h-next", "tab-board"): + self.assertTrue(any("taken by the hub page" in p for p in self.problems(id=taken)), taken) + def test_flags_are_true_or_false(self): self.assertEqual(self.problems(announce=True), []) self.assertTrue(any("announce is true or false" in p for p in self.problems(announce="yes"))) diff --git a/tools/roadmap.py b/tools/roadmap.py index 1a4f58136..f09224147 100644 --- a/tools/roadmap.py +++ b/tools/roadmap.py @@ -28,7 +28,7 @@ from pathlib import Path ROOT = Path(__file__).resolve().parent.parent SOURCE = ROOT / "roadmap" / "roadmap.toml" OUTPUT = ROOT / "ROADMAP.md" -# What the website's hub reads (website/build.mjs), and serves at /hub/roadmap.json for Kira and others. +# What the website's hub reads (website/build.mjs), and serves at /data/roadmap.json for Kira and others. SITE_DATA = ROOT / "website" / "data" / "roadmap.json" REPO = "ludovic111/horizon" SITE = "https://playhorizon.dev/hub" @@ -52,6 +52,9 @@ ITEM_KEYS = {"id", "title", "status", "area", "plain", "dev", "links", "focus", ISSUE = re.compile(r"#(\d+)$") ID = re.compile(r"[a-z0-9]+(-[a-z0-9]+)*$") +# An item is the anchor playhorizon.dev/hub#: it can't take the name of a tab, a section or a heading. +RESERVED = {"main", "overview", "roadmap", "board", "journal", "contribute", "hub-data", *STATUSES} +RESERVED_PREFIXES = ("h-", "tab-", "week-") RELEASE = re.compile(r"(v\d[\w.]*|launcher@\d[\w.]*|launcher-v\d[\w.]*|website)$") MONTHS = ("January|February|March|April|June|July|August|September|October|November|December") # Kira's rule: no dates and no promises of when. "Coming soon" is the one allowed phrase. @@ -105,6 +108,8 @@ def validate(data, root=ROOT): ident = item.get("id", "") if ident and not ID.match(ident): problems.append(f"{where}: ids are lowercase words joined by dashes") + if ident in RESERVED or ident.startswith(RESERVED_PREFIXES): + problems.append(f"{where}: the id is taken by the hub page (hub#{ident} is a tab, a section or a heading)") if ident in seen: problems.append(f"{where}: the id appears twice") seen.add(ident) @@ -231,7 +236,8 @@ def render(data): def site_data(data): """website/data/roadmap.json: the items as the hub and Kira read them, in the file's order.""" - keys = ("id", "title", "status", "area", "plain", "dev", "links", "focus", "ongoing", "shipped_in", "post") + keys = ("id", "title", "status", "area", "plain", "dev", "links", "focus", "ongoing", "shipped_in", "post", + "announce") out = { "format": "horizon-roadmap", "version": 1, diff --git a/website/Caddyfile b/website/Caddyfile index 50ba44381..a160f2259 100644 --- a/website/Caddyfile +++ b/website/Caddyfile @@ -38,8 +38,11 @@ redir /roadmap /hub#roadmap permanent @doc path_regexp doc ^/docs/([a-z-]+)$ rewrite @doc /docs/{re.doc.1}.html - @pages path / /index.html /404.html /privacy.html /releases /releases.html /benchmarks /benchmarks.html /benchmarks.json /hub /hub.html /hub/* /docs /docs/* /sitemap.xml + @pages path / /index.html /404.html /privacy.html /releases /releases.html /benchmarks /benchmarks.html /benchmarks.json /hub /hub.html /data/* /docs /docs/* /sitemap.xml header @pages Cache-Control "no-cache" + # The hub's data for Kira and anyone else: readable from any origin. + @data path /data/* + header @data Access-Control-Allow-Origin "*" @legal path /LEGAL.md /fonts/*.txt header @legal Content-Type "text/plain; charset=utf-8" diff --git a/website/README.md b/website/README.md index c73683c73..8f35fbcf4 100644 --- a/website/README.md +++ b/website/README.md @@ -42,7 +42,7 @@ src/releases.js the home page's "Recently added" and the Releases page's mark src/contributors.js the contributors' filtering and markup, shared by build and page src/hub.js the hub's markup from data/roadmap.json and GitHub's issue states, shared by build and page src/hub-page.js the hub page: tabs by #hash, the Simple / Technical switch (localStorage), the area filter, live states -data/roadmap.json the roadmap, generated by tools/roadmap.py from roadmap/roadmap.toml (do not edit); served at /hub/roadmap.json +data/roadmap.json the roadmap, generated by tools/roadmap.py from roadmap/roadmap.toml (do not edit); served at /data/roadmap.json public/ fonts, screenshots, icons, og.png, robots.txt, benchmarks.json: copied as is (sitemap.xml is written by the build) data/benchmarks/ our raw benchmark reports (tools/perf_bench.py) and fleet.json, the list scripts/benchmarks.mjs reads scripts/benchmarks.mjs benchmark reports -> public/benchmarks.json (ours, and players' groups of 3+ installs) diff --git a/website/build.mjs b/website/build.mjs index b36e0e103..563bc6fa4 100644 --- a/website/build.mjs +++ b/website/build.mjs @@ -428,9 +428,9 @@ for (const { file, values: own } of docPages) { docPageFiles.push(file); } -// The roadmap for other readers (Kira, scripts): /hub/roadmap.json, as tools/roadmap.py wrote it. -await mkdir(join(dist, "hub"), { recursive: true }); -await cp(join(site, "data", "roadmap.json"), join(dist, "hub", "roadmap.json")); +// The roadmap for other readers (Kira, scripts): /data/roadmap.json, as tools/roadmap.py wrote it. +await mkdir(join(dist, "data"), { recursive: true }); +await cp(join(site, "data", "roadmap.json"), join(dist, "data", "roadmap.json")); // The pages' inline scripts (they mark the page as scripted and apply the saved theme before CSS // applies) and the inlined stylesheet: the Content-Security-Policy in the Caddyfile allows them by hash. diff --git a/website/data/roadmap.json b/website/data/roadmap.json index 142b27011..d4124e534 100644 --- a/website/data/roadmap.json +++ b/website/data/roadmap.json @@ -116,7 +116,8 @@ "#1757", "docs/modpacks.md" ], - "focus": true + "focus": true, + "announce": true }, { "id": "server-clients", @@ -175,7 +176,8 @@ "#1640", "docs/mods.md" ], - "focus": true + "focus": true, + "announce": true }, { "id": "server-dialogs", @@ -232,7 +234,8 @@ "links": [ "#1787", "#1788" - ] + ], + "announce": true }, { "id": "lean-code", @@ -262,7 +265,8 @@ "links": [ "docs/microsoft-account.md", "#1270" - ] + ], + "announce": true }, { "id": "curseforge", @@ -274,7 +278,8 @@ "links": [ "docs/mod-browser.md", "docs/modpacks.md" - ] + ], + "announce": true }, { "id": "benchmarks", diff --git a/website/src/hub-page.js b/website/src/hub-page.js index 039e98826..97d6f3d60 100644 --- a/website/src/hub-page.js +++ b/website/src/hub-page.js @@ -1,4 +1,4 @@ -// The hub page (/hub): its tabs (one per #hash, so /hub#roadmap and /hub#item- can be linked), the +// The hub page (/hub): its tabs (one per #hash, so /hub#roadmap and /hub# can be linked), the // Simple / Technical switch (remembered in localStorage), the area filter, and the live state of every // linked issue and pull request, refreshed from GitHub's public API. Without JavaScript, every tab reads // one after the other with what was baked at build time. @@ -30,7 +30,7 @@ function choose(tab, { focus = false, push = false } = {}) { if (focus) tab.focus(); if (push && location.hash !== `#${panelOf(tab).id}`) history.replaceState(null, "", `#${panelOf(tab).id}`); } -// "#roadmap" opens its tab; "#item-x" or "#help-wanted" opens the tab holding it and scrolls there. +// "#roadmap" opens its tab; "#" or "#help-wanted" opens the tab holding it and scrolls there. function follow() { const target = location.hash && document.getElementById(decodeURIComponent(location.hash.slice(1))); const tab = tabs.find((t) => target && (panelOf(t) === target || panelOf(t).contains(target))) || tabs[0]; @@ -116,4 +116,4 @@ async function refresh() { setUpTheme(); setUpMenu(); follow(); -refresh().then(() => location.hash.startsWith("#item-") && follow()); +refresh().then(() => data.roadmap.items.some((i) => `#${i.id}` === location.hash) && follow()); diff --git a/website/src/hub.js b/website/src/hub.js index 37e26738c..ecfb4da80 100644 --- a/website/src/hub.js +++ b/website/src/hub.js @@ -86,7 +86,7 @@ const areaName = (roadmap, id) => roadmap.areas.find((a) => a.id === id)?.name | export function itemHtml(item, roadmap, live) { const done = item.status === "shipped"; const state = done ? "" : progress(item, live); - return `
+ return `

${escape(areaName(roadmap, item.area))}${done ? `${escape(item.shipped_in)}` : ""}${item.ongoing ? `Ongoing` : ""}

${escape(item.title)}

${inline(item.plain)}

@@ -137,25 +137,25 @@ export function overviewHtml(roadmap, live = new Map()) { const focus = roadmap.items.filter((i) => i.focus); const next = roadmap.items.filter((i) => i.status === "next"); const shipped = roadmap.items.filter((i) => i.status === "shipped").slice(0, 3); - const row = (item, i, meta) => `
  • ${String(i + 1).padStart(2, "0")}${escape(item.title)}${inline(item.plain)}${inline(item.dev)}${escape(meta(item))}
  • `; + const row = (item, i, meta) => `
  • ${String(i + 1).padStart(2, "0")}${escape(item.title)}${inline(item.plain)}${inline(item.dev)}${escape(meta(item))}
  • `; return `

    ${inline(o.today_plain)}

    ${inline(o.today_dev)}

    -
    -

    Being done now

    +
    +

    Being done now

      ${focus.map((item, i) => row(item, i, (x) => progress(x, live))).join("")}
    -
    -

    Next

    +
    +

    Next

      ${next.map((item, i) => row(item, i, (x) => areaName(roadmap, x.area))).join("")}
    -
    -

    Recently shipped

    +
    +

    Recently shipped

      ${shipped.map((item, i) => row(item, i, (x) => `In ${x.shipped_in}`)).join("")}
    -
    -

    How to help

    +
    +

    How to help

    ${inline(o.help_plain)}

    ${inline(o.help_dev)}

    ContributeHelp wanted

    @@ -168,7 +168,7 @@ export function helpWantedHtml(roadmap) { .filter((i) => i.status === "help-wanted") .map((item, i) => { const first = (item.links || []).map(number).find(Boolean); - const href = first ? issueUrl(first) : `#item-${item.id}`; + const href = first ? issueUrl(first) : `#${item.id}`; return `
  • ${String(i + 1).padStart(2, "0")}${escape(item.title)}${inline(item.plain)}${inline(item.dev)}${first ? `#${first}` : ""}
  • `; }) .join(""); diff --git a/website/src/hub.test.mjs b/website/src/hub.test.mjs index e73c9a8af..eb9b8a087 100644 --- a/website/src/hub.test.mjs +++ b/website/src/hub.test.mjs @@ -33,7 +33,7 @@ test("an item's progress counts its pull requests and issues", () => { test("the roadmap renders every item once, with both texts, in its status's section", () => { const html = roadmapHtml(roadmap); for (const item of roadmap.items) { - assert.equal(html.split(`id="item-${item.id}"`).length, 2, item.id); + assert.equal(html.split(`id="${item.id}"`).length, 2, item.id); } assert.ok(html.indexOf('id="now"') < html.indexOf('id="next"')); assert.ok(html.includes('class="hub-plain"') && html.includes('class="hub-dev"')); @@ -41,8 +41,15 @@ test("the roadmap renders every item once, with both texts, in its status's sect assert.ok(html.includes(`>${roadmap.items.find((i) => i.status === "shipped").shipped_in}<`)); }); +test("an item is its own anchor (hub#, as Kira links it) and takes no other id of the page", () => { + const page = readFileSync(new URL("./hub.html", import.meta.url), "utf8") + roadmapHtml(roadmap) + overviewHtml(roadmap); + const ids = [...page.matchAll(/ id="([^"]+)"/g)].map((m) => m[1]); + assert.deepEqual(ids.filter((id, i) => ids.indexOf(id) !== i), []); + for (const item of roadmap.items) assert.ok(ids.includes(item.id), item.id); +}); + test("the overview lists the focus items and never nests links", () => { const html = overviewHtml(roadmap); - for (const item of roadmap.items.filter((i) => i.focus)) assert.ok(html.includes(`href="#item-${item.id}"`), item.id); + for (const item of roadmap.items.filter((i) => i.focus)) assert.ok(html.includes(`href="#${item.id}"`), item.id); for (const row of html.match(/
  • [\s\S]*?<\/li>/g)) assert.equal(row.split("