Hub: the roadmap at /data/roadmap.json and items at hub#<id>, as Kira reads them

Kira (kira #10-#14) fetches https://playhorizon.dev/data/roadmap.json and links
items as <hub>#<id>: 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 <noreply@anthropic.com>
This commit is contained in:
Ludovic Marie
2026-10-25 15:59:31 +01:00
parent e936e412ba
commit 68234ac407
9 changed files with 53 additions and 28 deletions
+4
View File
@@ -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")))
+8 -2
View File
@@ -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#<id>: 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,
+4 -1
View File
@@ -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"
+1 -1
View File
@@ -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)
+3 -3
View File
@@ -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.
+10 -5
View File
@@ -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",
+3 -3
View File
@@ -1,4 +1,4 @@
// The hub page (/hub): its tabs (one per #hash, so /hub#roadmap and /hub#item-<id> can be linked), the
// The hub page (/hub): its tabs (one per #hash, so /hub#roadmap and /hub#<item id> 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; "#<item id>" 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());
+11 -11
View File
@@ -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 `<article class="hub-item" id="item-${escape(item.id)}" data-area="${escape(item.area)}" data-item="${escape(item.id)}">
return `<article class="hub-item" id="${escape(item.id)}" data-area="${escape(item.area)}" data-item="${escape(item.id)}">
<p class="hub-item-meta"><span class="badge">${escape(areaName(roadmap, item.area))}</span>${done ? `<span class="badge badge-game">${escape(item.shipped_in)}</span>` : ""}${item.ongoing ? `<span class="hub-ongoing">Ongoing</span>` : ""}</p>
<h3 class="hub-item-title">${escape(item.title)}</h3>
<p class="hub-plain">${inline(item.plain)}</p>
@@ -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) => `<li class="row"><a href="#item-${escape(item.id)}" data-goto="roadmap"><span class="row-index">${String(i + 1).padStart(2, "0")}</span><span class="hub-row-body"><span class="hub-row-title">${escape(item.title)}</span><span class="hub-plain">${inline(item.plain)}</span><span class="hub-dev">${inline(item.dev)}</span></span><span class="row-meta">${escape(meta(item))}</span></a></li>`;
const row = (item, i, meta) => `<li class="row"><a href="#${escape(item.id)}" data-goto="roadmap"><span class="row-index">${String(i + 1).padStart(2, "0")}</span><span class="hub-row-body"><span class="hub-row-title">${escape(item.title)}</span><span class="hub-plain">${inline(item.plain)}</span><span class="hub-dev">${inline(item.dev)}</span></span><span class="row-meta">${escape(meta(item))}</span></a></li>`;
return `<div class="hub-today">
<p class="hub-plain hub-lead">${inline(o.today_plain)}</p>
<p class="hub-dev hub-lead">${inline(o.today_dev)}</p>
</div>
<section class="hub-block" aria-labelledby="h-focus">
<h2 class="title" id="h-focus">Being done now</h2>
<section class="hub-block" aria-labelledby="h-ov-focus">
<h2 class="title" id="h-ov-focus">Being done now</h2>
<ol class="index hub-rows">${focus.map((item, i) => row(item, i, (x) => progress(x, live))).join("")}</ol>
</section>
<section class="hub-block" aria-labelledby="h-next">
<h2 class="title" id="h-next">Next</h2>
<section class="hub-block" aria-labelledby="h-ov-next">
<h2 class="title" id="h-ov-next">Next</h2>
<ol class="index hub-rows">${next.map((item, i) => row(item, i, (x) => areaName(roadmap, x.area))).join("")}</ol>
</section>
<section class="hub-block" aria-labelledby="h-shipped">
<h2 class="title" id="h-shipped">Recently shipped</h2>
<section class="hub-block" aria-labelledby="h-ov-shipped">
<h2 class="title" id="h-ov-shipped">Recently shipped</h2>
<ol class="index hub-rows">${shipped.map((item, i) => row(item, i, (x) => `In ${x.shipped_in}`)).join("")}</ol>
</section>
<section class="hub-block hub-help" aria-labelledby="h-help">
<h2 class="title" id="h-help">How to help</h2>
<section class="hub-block hub-help" aria-labelledby="h-ov-help">
<h2 class="title" id="h-ov-help">How to help</h2>
<p class="hub-plain">${inline(o.help_plain)}</p>
<p class="hub-dev">${inline(o.help_dev)}</p>
<p class="hub-actions"><a class="button primary" href="#contribute" data-goto="contribute">Contribute</a><a class="button secondary" href="#help-wanted" data-goto="roadmap">Help wanted</a></p>
@@ -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 `<li class="row"><a href="${escape(href)}"><span class="row-index">${String(i + 1).padStart(2, "0")}</span><span class="hub-row-body"><span class="hub-row-title">${escape(item.title)}</span><span class="hub-plain">${inline(item.plain)}</span><span class="hub-dev">${inline(item.dev)}</span></span><span class="row-meta">${first ? `#${first}` : ""}</span></a></li>`;
})
.join("");
+9 -2
View File
@@ -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#<id>, 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(/<li class="row">[\s\S]*?<\/li>/g)) assert.equal(row.split("<a ").length, 2, row);
});