Merge pull request #1851 from ludovic111/feat/hub-forms
🤖 Agent: merged after verify passed (hub: website tests 30/30, roadmap tests + sync check, telemetry server 35 tests; local end-to-end run by roadmap-1).
This commit is contained in:
+27
-2
@@ -54,8 +54,8 @@ Whoever moves the work (the orchestrator on each heartbeat, or anyone in their p
|
||||
`2026-43.md`): `# Title`, a paragraph or two for players, then `## Technical` and the same week for
|
||||
contributors, with its pull requests. `build` puts it into website/data/roadmap.json; the hub's Journal tab
|
||||
shows it among the releases, and `/data/journal.json` carries it to Kira's #updates and to X.
|
||||
6. Suggestions from the website and Discord are read and triaged by the maintainers. A good one becomes an
|
||||
item in a normal pull request; none is published automatically.
|
||||
6. Suggestions from the website and Discord reach the maintainers' private channel through Kira (below). A good
|
||||
one becomes an item in a normal pull request; none is published automatically.
|
||||
|
||||
CI runs `tests/test_roadmap.py` (in the Python tests), which fails when ROADMAP.md is not what `build` writes
|
||||
or when the file breaks a rule; `python3 tools/roadmap.py check --offline` runs the same rules without GitHub.
|
||||
@@ -89,3 +89,28 @@ merged pull request, release, shipped item and weekly summary, newest first, the
|
||||
- `announce: true` (the item's `announce` key) asks Kira to post the shipped item on X too, with `post`.
|
||||
- `https://playhorizon.dev/data/roadmap.json` is `roadmap.toml` as JSON (`areas`, `items` with every key above,
|
||||
`overview`, the weekly summaries); an item's page is `https://playhorizon.dev/hub#<id>`.
|
||||
|
||||
## The intake: votes, bug reports, suggestions
|
||||
|
||||
The hub's forms and vote buttons talk to the telemetry server (`https://telemetry.playhorizon.dev`,
|
||||
`crates/horizon-telemetry-server`, `src/hub.rs` and `src/intake.rs`; its README lists the limits and settings).
|
||||
Kira uses the same endpoints, so a bug or an idea goes the same way from the site and from Discord.
|
||||
|
||||
| Endpoint | Body | Answer |
|
||||
| --- | --- | --- |
|
||||
| `POST /hub/vote` | `{"item": "<roadmap id>", "voter": "<random id, 16 to 64 characters>", "up": true}` | `{"item", "votes"}`; `"up": false` takes the vote back |
|
||||
| `GET /hub/votes` | | `{"votes": {"<item>": n}}`, a minute old at most |
|
||||
| `POST /hub/report` | `{"title", "did", "happened", "expected", "version"?, "system", "name"?}` | 201 `{"id", "issue": "<GitHub URL>"}`; 202 `{"id", "issue": null}` when GitHub was down (opened later) |
|
||||
| `POST /hub/suggest` | `{"text", "item"?, "name"?}` | 202 `{"id"}` |
|
||||
| `GET /hub/suggestions?after=<id>` | `Authorization: Bearer <HORIZON_TELEMETRY_HUB_TOKEN>` | `{"suggestions": [{"id", "text", "item"?, "name"?, "created_at"}]}`, oldest first |
|
||||
|
||||
- A report becomes an issue at once, labels `bug` and `from-website`, in the `#horizon-bugs` template (What I did,
|
||||
What happened, What I expected, Horizon version, OS, CPU, GPU) with "Reported on playhorizon.dev". Every field
|
||||
but the version and the name is required; mentions, `#123` references and HTML in people's text are made inert.
|
||||
- Suggestions are never published. Kira polls `/hub/suggestions` with the last id it relayed and posts each one
|
||||
to `#roadmap-suggestions`.
|
||||
- Errors are `{"error": "…"}`: 400 names the field (`"did: 3 to 2000 characters"`), 429 means too many from that
|
||||
address, 503 a full day or reports turned off (no GitHub token on the server).
|
||||
- The page shows the forms and the buttons only once `GET /hub/votes` answers. Until then it points to GitHub and
|
||||
Discord. It keeps a random voter id and the items it voted for in `localStorage` (`hub:voter`, `hub:voted`).
|
||||
|
||||
|
||||
+2
-1
@@ -56,7 +56,8 @@ 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 = {"main", "overview", "roadmap", "board", "journal", "contribute", "report", "suggest", "contributors",
|
||||
"hub-data", *STATUSES}
|
||||
RESERVED_PREFIXES = ("h-", "tab-", "col-", "week-", "journal-")
|
||||
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")
|
||||
|
||||
+17
-2
@@ -16,7 +16,7 @@ import { machinesHtml, playersHtml } from "./src/bench.js";
|
||||
import { CPUS, GPUS, singleThread } from "./src/hardware.js";
|
||||
import { isGame, isLauncher, launcherVersion, newestFirst } from "./src/versions.js";
|
||||
import { contributorsFrom, contributorsHtml } from "./src/contributors.js";
|
||||
import { areaFilterHtml, boardFilterHtml, boardFrom, boardHtml, helpWantedHtml, journalFrom, journalHtml, journalJson, overviewHtml, roadmapHtml, slimIssue } from "./src/hub.js";
|
||||
import { areaFilterHtml, boardFilterHtml, boardFrom, boardHtml, creditFrom, creditHtml, helpWantedHtml, journalFrom, journalHtml, journalJson, overviewHtml, roadmapHtml, slimIssue, suggestItemsHtml } from "./src/hub.js";
|
||||
import { INDEX_URL, KINDS, SUBMIT, listHtml, projectHtml, readIndex, submitHtml } from "./src/mods.js";
|
||||
|
||||
const site = dirname(fileURLToPath(import.meta.url));
|
||||
@@ -135,6 +135,18 @@ const hubLinked = new Map(hubLive.filter((i) => linked.has(i.n)).map((i) => [i.n
|
||||
const board = boardFrom(hubLive, roadmap);
|
||||
const journal = journalFrom(releases, hubLive, roadmap);
|
||||
|
||||
// The hub's server (crates/horizon-telemetry-server: votes, bug reports, suggestions), and Kira's list of the
|
||||
// contributors who linked their Discord account and agreed to be credited (kira's /contributors.json).
|
||||
const hubApi = process.env.HUB_API_URL || "https://telemetry.playhorizon.dev";
|
||||
let kiraCredit = {};
|
||||
try {
|
||||
const res = await fetch(process.env.KIRA_CONTRIBUTORS_URL || "https://kira-production-500e.up.railway.app/contributors.json", { signal: AbortSignal.timeout(10000) });
|
||||
if (!res.ok) throw new Error(`${res.status} from Kira`);
|
||||
kiraCredit = await res.json();
|
||||
} catch (e) {
|
||||
console.warn(`hub: contributors' Discord names: ${e.message}`);
|
||||
}
|
||||
|
||||
// --- The parity table ------------------------------------------------------------------
|
||||
|
||||
const status = section(readme, "Project status") ?? "";
|
||||
@@ -348,7 +360,10 @@ const values = {
|
||||
HUB_BOARD: hubLive.length ? boardHtml(board, roadmap) : `<p class="lede">The board could not be loaded here.</p>`,
|
||||
HUB_BOARD_FILTER: boardFilterHtml(board, roadmap),
|
||||
HUB_JOURNAL: journalHtml(journal, roadmap) || unavailable,
|
||||
HUB_DATA: JSON.stringify({ roadmap, live: [...hubLinked.values()] }).replace(/</g, "\\u003c"),
|
||||
HUB_DATA: JSON.stringify({ roadmap, live: [...hubLinked.values()], api: hubApi }).replace(/</g, "\\u003c"),
|
||||
HUB_SUGGEST_ITEMS: suggestItemsHtml(roadmap),
|
||||
HUB_VERSION: escape(game[0]?.tag_name || ""),
|
||||
HUB_CREDIT: creditHtml(creditFrom(contributors, kiraCredit)),
|
||||
YEAR: String(new Date().getUTCFullYear()),
|
||||
};
|
||||
|
||||
|
||||
@@ -21,7 +21,7 @@ export function contributorsFrom(list) {
|
||||
}
|
||||
|
||||
// GitHub serves avatars at any size: 96 px is twice what the page draws, for sharp screens.
|
||||
function avatar(url) {
|
||||
export function avatar(url) {
|
||||
if (!url.startsWith(AVATARS)) return "";
|
||||
const u = new URL(url);
|
||||
u.searchParams.set("s", "96");
|
||||
|
||||
@@ -132,6 +132,7 @@ async function refresh() {
|
||||
document.querySelector("[data-overview]").innerHTML = overviewHtml(data.roadmap, live);
|
||||
document.querySelector("[data-roadmap]").innerHTML = roadmapHtml(data.roadmap, live);
|
||||
filter(area);
|
||||
showVotes();
|
||||
const board = boardFrom(fresh, data.roadmap);
|
||||
const chosen = boardSelect.value;
|
||||
boardSelect.innerHTML = boardFilterHtml(board, data.roadmap);
|
||||
@@ -144,7 +145,126 @@ async function refresh() {
|
||||
if (note) note.textContent = "Pull request and issue states are live from GitHub.";
|
||||
}
|
||||
|
||||
// --- Votes, bug reports and suggestions: the hub's server (crates/horizon-telemetry-server) --------------------
|
||||
|
||||
const saved = (key, fallback) => {
|
||||
try {
|
||||
return JSON.parse(localStorage.getItem(key)) ?? fallback;
|
||||
} catch {
|
||||
return fallback;
|
||||
}
|
||||
};
|
||||
const save = (key, value) => {
|
||||
try {
|
||||
localStorage.setItem(key, JSON.stringify(value));
|
||||
} catch {}
|
||||
};
|
||||
const post = (path, body) => fetch(`${data.api}${path}`, { method: "POST", headers: { "content-type": "application/json" }, body: JSON.stringify(body) });
|
||||
|
||||
// This browser's random id (one vote per item per browser) and the items it voted for. Nothing else identifies it.
|
||||
function voter() {
|
||||
let id = saved("hub:voter", "");
|
||||
if (typeof id !== "string" || id.length < 16) {
|
||||
id = crypto.randomUUID ? crypto.randomUUID() : [...crypto.getRandomValues(new Uint8Array(16))].map((b) => b.toString(16).padStart(2, "0")).join("");
|
||||
save("hub:voter", id);
|
||||
}
|
||||
return id;
|
||||
}
|
||||
const mine = new Set(saved("hub:voted", []));
|
||||
let counts = null; // { item: votes } once the server answered; until then the buttons stay hidden
|
||||
|
||||
function showVotes() {
|
||||
if (!counts) return;
|
||||
for (const button of document.querySelectorAll("[data-vote]")) {
|
||||
const id = button.dataset.vote;
|
||||
button.hidden = false;
|
||||
button.setAttribute("aria-pressed", String(mine.has(id)));
|
||||
button.querySelector(".hub-vote-label").textContent = mine.has(id) ? "Wanted" : "Want it";
|
||||
button.querySelector("[data-votes]").textContent = counts[id] ? String(counts[id]) : "";
|
||||
}
|
||||
}
|
||||
|
||||
async function vote(id) {
|
||||
const up = !mine.has(id);
|
||||
const apply = (on, step) => {
|
||||
if (on) mine.add(id);
|
||||
else mine.delete(id);
|
||||
counts[id] = Math.max(0, (counts[id] || 0) + step);
|
||||
save("hub:voted", [...mine]);
|
||||
showVotes();
|
||||
};
|
||||
apply(up, up ? 1 : -1);
|
||||
try {
|
||||
const res = await post("/hub/vote", { item: id, voter: voter(), up });
|
||||
if (!res.ok) throw new Error(res.status);
|
||||
counts[id] = (await res.json()).votes;
|
||||
showVotes();
|
||||
} catch {
|
||||
apply(!up, up ? -1 : 1);
|
||||
}
|
||||
}
|
||||
document.addEventListener("click", (e) => {
|
||||
const button = e.target.closest("[data-vote]");
|
||||
if (button && counts) vote(button.dataset.vote);
|
||||
});
|
||||
|
||||
const LABELS = { title: "the title", did: "what you did", happened: "what happened", expected: "what you expected", version: "the version", system: "OS, CPU, GPU", text: "your idea", name: "your name" };
|
||||
// The server's answer in words: "did: 3 to 2000 characters" becomes "Check what you did: 3 to 2000 characters."
|
||||
function trouble(code, answer) {
|
||||
if (code === 429) return "Too many sent from your connection: try again in a few minutes.";
|
||||
const said = typeof answer.error === "string" ? answer.error : "";
|
||||
const field = said.match(/^(\w+): (.+)$/);
|
||||
if (code === 400 && field) return `Check ${LABELS[field[1]] || field[1]}: ${field[2]}.`;
|
||||
return said ? `${said[0].toUpperCase()}${said.slice(1)}.` : "That didn't go through: try again in a moment.";
|
||||
}
|
||||
|
||||
function setUpForm(form, path, thanks) {
|
||||
const status = form.querySelector("[data-status]");
|
||||
form.hidden = false;
|
||||
form.parentElement.querySelector("[data-closed]").hidden = true;
|
||||
form.addEventListener("submit", async (e) => {
|
||||
e.preventDefault();
|
||||
if (!form.reportValidity()) return;
|
||||
const button = form.querySelector('[type="submit"]');
|
||||
button.disabled = true;
|
||||
status.textContent = "Sending…";
|
||||
try {
|
||||
const res = await post(path, Object.fromEntries(new FormData(form)));
|
||||
const answer = await res.json().catch(() => ({}));
|
||||
if (res.ok) {
|
||||
thanks(status, answer);
|
||||
// A new report starts with the version filled in again; the name stays for the next one.
|
||||
for (const field of form.querySelectorAll("textarea, input:not([name='version']):not([name='name'])")) field.value = "";
|
||||
} else status.textContent = trouble(res.status, answer);
|
||||
} catch {
|
||||
status.textContent = "Couldn't reach the server: try again, or use GitHub or Discord.";
|
||||
}
|
||||
button.disabled = false;
|
||||
});
|
||||
}
|
||||
|
||||
// The forms and the votes show once the server answers; without it the page points to GitHub and Discord.
|
||||
async function connect() {
|
||||
try {
|
||||
// Revalidated: the server keeps the counts a minute, a browser's copy would miss this browser's own vote.
|
||||
const res = await fetch(`${data.api}/hub/votes`, { cache: "no-cache" });
|
||||
if (!res.ok) return;
|
||||
counts = (await res.json()).votes || {};
|
||||
} catch {
|
||||
return;
|
||||
}
|
||||
showVotes();
|
||||
setUpForm(document.querySelector('[data-form="report"]'), "/hub/report", (status, answer) => {
|
||||
const issue = typeof answer.issue === "string" && answer.issue.match(/^https:\/\/github\.com\/ludovic111\/horizon\/issues\/(\d+)$/);
|
||||
status.innerHTML = issue ? `Thanks! It's <a href="${issue[0]}">issue #${issue[1]}</a> on GitHub: follow it there.` : "Thanks! It will be on GitHub in a few minutes.";
|
||||
});
|
||||
setUpForm(document.querySelector('[data-form="suggest"]'), "/hub/suggest", (status) => {
|
||||
status.textContent = "Thanks! The maintainers read every suggestion.";
|
||||
});
|
||||
}
|
||||
|
||||
setUpTheme();
|
||||
setUpMenu();
|
||||
connect();
|
||||
follow();
|
||||
refresh().then(() => data.roadmap.items.some((i) => `#${i.id}` === location.hash) && follow());
|
||||
|
||||
+42
-1
@@ -90,7 +90,7 @@
|
||||
<article class="highlight">
|
||||
<h3>Tell us what differs</h3>
|
||||
<p>Something that doesn't play like vanilla is a bug. Say what you did, what happened and what vanilla does, with your Horizon version and system.</p>
|
||||
<p class="hub-actions"><a class="button secondary small" href="{{DISCORD}}">Discord</a><a class="button secondary small" href="https://github.com/ludovic111/horizon/issues/new">GitHub issue</a></p>
|
||||
<p class="hub-actions"><a class="button secondary small" href="#report">Report a bug</a><a class="button secondary small" href="#suggest">Suggest something</a></p>
|
||||
</article>
|
||||
<article class="highlight">
|
||||
<h3>Take a task</h3>
|
||||
@@ -109,6 +109,41 @@
|
||||
</article>
|
||||
</div>
|
||||
</section>
|
||||
<section class="hub-block" id="report" aria-labelledby="h-report">
|
||||
<h2 class="title" id="h-report">Report a bug</h2>
|
||||
<p class="hub-intro">One bug per report: something that breaks, or doesn't play like vanilla. It becomes an issue on GitHub, public, and you get its link to follow it. Search the <a href="https://github.com/ludovic111/horizon/issues?q=is%3Aissue+label%3Abug">open bugs</a> first.</p>
|
||||
<form class="hub-form" data-form="report" hidden>
|
||||
<label class="hub-field"><span>Title: what is broken, in a few words</span><input name="title" required minlength="5" maxlength="120" autocomplete="off" placeholder="Water looks black on AMD graphics"></label>
|
||||
<label class="hub-field"><span>What did you do? The steps, one per line</span><textarea name="did" required minlength="3" maxlength="2000" rows="4"></textarea></label>
|
||||
<div class="hub-form-pair">
|
||||
<label class="hub-field"><span>What happened?</span><textarea name="happened" required minlength="3" maxlength="2000" rows="3"></textarea></label>
|
||||
<label class="hub-field"><span>What did you expect? What vanilla does</span><textarea name="expected" required minlength="3" maxlength="2000" rows="3"></textarea></label>
|
||||
</div>
|
||||
<div class="hub-form-pair">
|
||||
<label class="hub-field"><span>Horizon version</span><input name="version" maxlength="60" value="{{HUB_VERSION}}" autocomplete="off"></label>
|
||||
<label class="hub-field"><span>OS, CPU, GPU</span><input name="system" required minlength="3" maxlength="200" placeholder="Windows 11, Ryzen 5 5600, RX 6600"></label>
|
||||
</div>
|
||||
<label class="hub-field"><span>Your name, shown on the issue (optional)</span><input name="name" maxlength="64" autocomplete="nickname"></label>
|
||||
<label class="hub-trap" aria-hidden="true">Leave this empty <input name="website" tabindex="-1" autocomplete="off"></label>
|
||||
<p class="hub-form-foot"><button type="submit" class="button primary">Send the report</button><span class="meta" data-status role="status"></span></p>
|
||||
<p class="meta">What you write is public on GitHub: no passwords or personal details. A screenshot or the log file helps: add it to the issue once it's open.</p>
|
||||
</form>
|
||||
<p class="hub-form-closed" data-closed>Report it on <a href="https://github.com/ludovic111/horizon/issues/new">GitHub</a> or in <a href="{{DISCORD}}">#horizon-bugs on Discord</a>, where Kira turns your post into an issue.</p>
|
||||
</section>
|
||||
<section class="hub-block" id="suggest" aria-labelledby="h-suggest">
|
||||
<h2 class="title" id="h-suggest">Suggest something</h2>
|
||||
<p class="hub-intro">An idea for Horizon, or about something on the roadmap. The maintainers read every one, and the good ones become roadmap items. Nothing you send here is published.</p>
|
||||
<form class="hub-form" data-form="suggest" hidden>
|
||||
<label class="hub-field"><span>Your idea</span><textarea name="text" required minlength="10" maxlength="1000" rows="4"></textarea></label>
|
||||
<div class="hub-form-pair">
|
||||
<label class="hub-field"><span>About</span><select name="item">{{HUB_SUGGEST_ITEMS}}</select></label>
|
||||
<label class="hub-field"><span>Your name (optional)</span><input name="name" maxlength="64" autocomplete="nickname"></label>
|
||||
</div>
|
||||
<label class="hub-trap" aria-hidden="true">Leave this empty <input name="website" tabindex="-1" autocomplete="off"></label>
|
||||
<p class="hub-form-foot"><button type="submit" class="button primary">Send the idea</button><span class="meta" data-status role="status"></span></p>
|
||||
</form>
|
||||
<p class="hub-form-closed" data-closed>Post it in <a href="{{DISCORD}}">#horizon-ideas on Discord</a>, or send it to Kira with <code>/suggest</code>.</p>
|
||||
</section>
|
||||
<section class="hub-block" aria-labelledby="h-rules">
|
||||
<h2 class="title" id="h-rules">The rules</h2>
|
||||
<ol class="hub-rules">
|
||||
@@ -119,6 +154,12 @@
|
||||
</ol>
|
||||
<p class="hub-actions"><a class="button primary" href="/docs/contributing">The contributing guide</a><a class="button secondary" href="https://github.com/ludovic111/horizon/blob/main/CONTRIBUTING.md">CONTRIBUTING.md</a></p>
|
||||
</section>
|
||||
<section class="hub-block" id="contributors" aria-labelledby="h-contributors">
|
||||
<h2 class="title" id="h-contributors">Contributors</h2>
|
||||
<p class="hub-intro">Everyone with commits in Horizon. On Discord, <code>/link-github <your login> credit:True</code> adds your Discord name next to yours.</p>
|
||||
<ul class="contributors-list hub-people">{{HUB_CREDIT}}</ul>
|
||||
<p class="meta"><a href="https://github.com/ludovic111/horizon/graphs/contributors">All contributors on GitHub</a></p>
|
||||
</section>
|
||||
</div>
|
||||
<p class="disclaimer">Not an official Minecraft product. Not approved by or associated with Mojang or Microsoft.</p>
|
||||
</div>
|
||||
|
||||
+39
-2
@@ -6,6 +6,7 @@
|
||||
import { escape, inline } from "./markdown.js";
|
||||
import { parts, plainItem, sections } from "./releases.js";
|
||||
import { isGame, isLauncher } from "./versions.js";
|
||||
import { avatar } from "./contributors.js";
|
||||
|
||||
export const REPO = "ludovic111/horizon";
|
||||
const issueUrl = (n) => `https://github.com/${REPO}/issues/${n}`;
|
||||
@@ -85,11 +86,16 @@ export function progress(item, live) {
|
||||
|
||||
const areaName = (roadmap, id) => roadmap.areas.find((a) => a.id === id)?.name || id;
|
||||
|
||||
// An item's vote button: hidden until the page has the counts from the hub's server (hub-page.js).
|
||||
export function voteHtml(item) {
|
||||
return `<button type="button" class="button secondary small hub-vote" data-vote="${escape(item.id)}" aria-pressed="false" hidden><span class="hub-vote-label">Want it</span><span class="hub-vote-count" data-votes></span></button>`;
|
||||
}
|
||||
|
||||
export function itemHtml(item, roadmap, live) {
|
||||
const done = item.status === "shipped";
|
||||
const state = done ? "" : progress(item, live);
|
||||
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>
|
||||
<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>` : ""}${done ? "" : voteHtml(item)}</p>
|
||||
<h3 class="hub-item-title">${escape(item.title)}</h3>
|
||||
<p class="hub-plain">${inline(item.plain)}</p>
|
||||
<p class="hub-dev">${devHtml(item)}</p>
|
||||
@@ -160,7 +166,7 @@ export function overviewHtml(roadmap, live = new Map()) {
|
||||
<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>
|
||||
<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><a class="button secondary" href="#report">Report a bug</a><a class="button secondary" href="#suggest">Suggest something</a></p>
|
||||
</section>`;
|
||||
}
|
||||
|
||||
@@ -418,3 +424,34 @@ export function journalHtml(entries, roadmap) {
|
||||
})
|
||||
.join("\n");
|
||||
}
|
||||
|
||||
// --- Contribute: the suggestion form's items and the contributors ------------------------------------------------
|
||||
|
||||
// The suggestion form's "About" choices: the items still to come.
|
||||
export function suggestItemsHtml(roadmap) {
|
||||
const open = roadmap.items.filter((i) => i.status !== "shipped");
|
||||
return [`<option value="">Something new</option>`]
|
||||
.concat(open.map((i) => `<option value="${escape(i.id)}">${escape(i.title)}</option>`))
|
||||
.join("");
|
||||
}
|
||||
|
||||
// The contributors, from GitHub (contributors.js's list), with the Discord name of those who linked their accounts
|
||||
// on Kira and agreed to be credited (Kira's /contributors.json: { contributors: [{ github, discord }] }).
|
||||
export function creditFrom(github, kira) {
|
||||
const discord = new Map(
|
||||
(Array.isArray(kira?.contributors) ? kira.contributors : [])
|
||||
.filter((c) => c && typeof c.github === "string" && typeof c.discord === "string")
|
||||
.map((c) => [c.github.toLowerCase(), c.discord]),
|
||||
);
|
||||
return github.map((c) => ({ ...c, discord: discord.get(c.login.toLowerCase()) || "" }));
|
||||
}
|
||||
|
||||
export function creditHtml(list) {
|
||||
return list
|
||||
.map((c) => {
|
||||
const src = avatar(c.avatar_url);
|
||||
const count = `${c.contributions.toLocaleString("en-US")} ${c.contributions === 1 ? "commit" : "commits"}`;
|
||||
return `<li><a class="contributor" href="${escape(c.html_url)}">${src ? `<img class="contributor-avatar" loading="lazy" decoding="async" src="${escape(src)}" width="48" height="48" alt="">` : `<span class="contributor-avatar" aria-hidden="true"></span>`}<span class="contributor-name">${escape(c.login)}</span><span class="contributor-count">${count}${c.discord ? ` · ${escape(c.discord)} on Discord` : ""}</span></a></li>`;
|
||||
})
|
||||
.join("");
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import { test } from "node:test";
|
||||
import assert from "node:assert/strict";
|
||||
import { readFileSync } from "node:fs";
|
||||
import { boardFrom, boardHtml, fixesIn, itemOf, journalFrom, journalHtml, journalJson, overviewHtml, progress, roadmapHtml, slimIssue } from "./hub.js";
|
||||
import { boardFrom, boardHtml, creditFrom, creditHtml, fixesIn, itemOf, journalFrom, journalHtml, journalJson, overviewHtml, progress, roadmapHtml, slimIssue, suggestItemsHtml } from "./hub.js";
|
||||
|
||||
const roadmap = JSON.parse(readFileSync(new URL("../data/roadmap.json", import.meta.url), "utf8"));
|
||||
|
||||
@@ -137,3 +137,23 @@ test("journal.json is the flat feed Kira reads: merges, releases, shipped items,
|
||||
assert.match(e.url, /^https:\/\/(github\.com|playhorizon\.dev)\//, e.id);
|
||||
}
|
||||
});
|
||||
|
||||
test("items still to come take votes and suggestions; shipped ones don't", () => {
|
||||
const html = roadmapHtml(roadmap);
|
||||
for (const item of roadmap.items) {
|
||||
assert.equal(html.includes(`data-vote="${item.id}"`), item.status !== "shipped", item.id);
|
||||
assert.equal(suggestItemsHtml(roadmap).includes(`value="${item.id}"`), item.status !== "shipped", item.id);
|
||||
}
|
||||
// Hidden until the hub's server answers.
|
||||
assert.ok(html.includes('aria-pressed="false" hidden>'));
|
||||
});
|
||||
|
||||
test("the contributors carry the Discord name of those who agreed on Kira", () => {
|
||||
const github = [{ login: "Alex", html_url: "https://github.com/Alex", avatar_url: "", contributions: 3 }, { login: "sam", html_url: "https://github.com/sam", avatar_url: "", contributions: 1 }];
|
||||
const kira = { contributors: [{ github: "alex", discord: "Alex <b>" }, { github: 5 }, null] };
|
||||
const credit = creditFrom(github, kira);
|
||||
assert.deepEqual(credit.map((c) => c.discord), ["Alex <b>", ""]);
|
||||
const html = creditHtml(credit);
|
||||
assert.ok(html.includes("3 commits · Alex <b> on Discord") && html.includes("1 commit</span>"));
|
||||
assert.deepEqual(creditFrom(github, "not json").map((c) => c.discord), ["", ""]);
|
||||
});
|
||||
|
||||
+24
-1
@@ -645,7 +645,7 @@ code { border-radius: 0; background: var(--well); box-shadow: 0 0 0 1px var(--ou
|
||||
|
||||
/* Releases: a filter, then every release as a panel that opens. */
|
||||
.release-filter { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 32px; }
|
||||
.release-filter .button[aria-pressed="true"], .hub-detail .button[aria-pressed="true"] { background: var(--face); color: var(--on-face); box-shadow: inset 0 var(--block-bevel) 0 var(--face-bevel), inset 0 calc(-1 * var(--block-lip)) 0 var(--face-lip); }
|
||||
.release-filter .button[aria-pressed="true"], .hub-detail .button[aria-pressed="true"], .button.hub-vote[aria-pressed="true"] { background: var(--face); color: var(--on-face); box-shadow: inset 0 var(--block-bevel) 0 var(--face-bevel), inset 0 calc(-1 * var(--block-lip)) 0 var(--face-lip); }
|
||||
.release-count { margin: 16px 0 12px; }
|
||||
.release-list { display: grid; gap: 8px; }
|
||||
.release-list .release + .release { margin-top: 0; }
|
||||
@@ -827,6 +827,29 @@ code { border-radius: 0; background: var(--well); box-shadow: 0 0 0 1px var(--ou
|
||||
.hub-rows .row-meta { grid-column: 2; text-align: left; }
|
||||
}
|
||||
|
||||
/* --- Hub: votes, the report and suggestion forms, the contributors ---------------------- */
|
||||
.hub-vote { margin-left: auto; }
|
||||
.hub-vote-count { margin-left: -2px; }
|
||||
.hub-vote-count:empty { display: none; }
|
||||
.hub-form { display: grid; gap: 16px; max-width: 46rem; margin-top: 8px; }
|
||||
.hub-form-pair { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
|
||||
.hub-field { display: grid; gap: 6px; font-size: var(--text-label); color: var(--ink-soft); }
|
||||
.hub-field input, .hub-field textarea, .hub-field select {
|
||||
width: 100%; min-height: 36px; padding: 8px 10px; font: var(--text-ui) / 1.4 var(--font); color: var(--ink);
|
||||
background: var(--well); border: 0; box-shadow: 0 0 0 var(--block-outline) var(--outline);
|
||||
}
|
||||
.hub-field textarea { resize: vertical; }
|
||||
.hub-field input:focus-visible, .hub-field textarea:focus-visible, .hub-field select:focus-visible { outline: 1px solid var(--accent); outline-offset: 2px; }
|
||||
.hub-field input::placeholder, .hub-field textarea::placeholder { color: var(--muted); }
|
||||
.hub-trap { position: absolute; left: -10000px; width: 1px; height: 1px; overflow: hidden; }
|
||||
.hub-form-foot { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 16px; }
|
||||
.hub-form-foot [data-status] { color: var(--ink); }
|
||||
.hub-form-foot .button:disabled { opacity: 0.4; cursor: default; }
|
||||
.hub-form-closed { color: var(--ink-soft); }
|
||||
@media (max-width: 720px) {
|
||||
.hub-form-pair { grid-template-columns: minmax(0, 1fr); }
|
||||
}
|
||||
|
||||
/* The registry (/mods): a search and the kind filter, rows as panels, then a page per project. */
|
||||
.mod-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 24px; }
|
||||
.mod-tools { display: flex; flex-wrap: wrap; align-items: center; gap: 16px; margin-top: 32px; }
|
||||
|
||||
Reference in New Issue
Block a user