diff --git a/docs/mods.md b/docs/mods.md
index 0d26978dc..470c8aad8 100644
--- a/docs/mods.md
+++ b/docs/mods.md
@@ -515,6 +515,10 @@ published. Players find them at [playhorizon.dev/mods](https://playhorizon.dev/m
5. A reviewer merges it: within minutes the file is a release of horizon-mods, and the project is on the site and in
the launcher.
+Once it is published, its page and its card in the launcher show its downloads (GitHub's counts of its files,
+refreshed every hour) and its rating: players signed in with GitHub on its page give it 1 to 5 stars, one rating per
+account, which they can change. Its owners can't rate it, and nobody sees who rated.
+
An update is the same form with a new version; only the project's `owners` can publish one, signed with its key if it
has one. A published file never changes. Without the form, open the pull request by hand (the repository's README
says how). The formats: [api/mod-index.md](api/mod-index.md).
diff --git a/website/build.mjs b/website/build.mjs
index b979f83f8..8e93c82b4 100644
--- a/website/build.mjs
+++ b/website/build.mjs
@@ -18,7 +18,7 @@ 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, 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";
+import { INDEX_URL, KINDS, SORTS, SUBMIT, listHtml, projectHtml, readIndex, sorted, submitHtml } from "./src/mods.js";
const site = dirname(fileURLToPath(import.meta.url));
const dist = join(site, "dist");
@@ -484,10 +484,11 @@ const modsList = `
ModsMade for Horizon, r
${KINDS.map(([k, label]) => ` `).join("\n")}
+
`;
const modPages = [
{ file: "mods.html", path: "/mods", title: "Mods", description: "Mods, modpacks and resource packs made for Horizon, reviewed, each with what it may do and how to install it.", main: modsList },
diff --git a/website/src/mods-page.js b/website/src/mods-page.js
index 121ba8067..335e863bd 100644
--- a/website/src/mods-page.js
+++ b/website/src/mods-page.js
@@ -1,32 +1,47 @@
-// /mods and /mods/: the registry's list (kind filter, search) and a project's page. The pages are baked from
-// the index at build time; this fetches the published index again so a project merged since shows at once.
-import { INDEX_URL, KINDS, listHtml, matches, projectHtml, readIndex } from "./mods.js";
+// /mods and /mods/: the registry's list (kind filter, search, order) and a project's page. The pages are baked
+// from the index at build time; this fetches the published index again so a project merged since shows at once,
+// the ratings (crates/horizon-mod-registry), and on a project's page the signed-in player's own rating to change.
+import { API, INDEX_URL, KINDS, RATINGS, SORTS, listHtml, matches, projectHtml, rateHtml, ratingOf, readIndex, sorted, starsHtml } from "./mods.js";
import { cached, setUpMenu, setUpTheme } from "./chrome.js";
+import { escape } from "./markdown.js";
const root = document.getElementById("mods");
const baked = readIndex(JSON.parse(document.getElementById("mods-index").textContent || "null")) || [];
let projects = baked;
+// Every project's ratings, once the service answered.
+let ratings = null;
let kind = "all";
let text = "";
+let order = "downloads";
+// On a project's page: the signed-in account ({login, csrf}) or null, and its own rating of the project.
+let me;
+let mine = null;
const id = (location.pathname.match(/^\/mods\/([a-z0-9_]+)\/?$/) || [])[1];
function showList() {
const list = root.querySelector("#mod-list");
if (!list) return;
- const shown = projects.filter((p) => matches(p, kind, text));
- list.innerHTML = listHtml(shown);
+ const shown = sorted(projects.filter((p) => matches(p, kind, text)), order, ratings);
+ list.innerHTML = listHtml(shown, ratings);
root.querySelector("[data-mod-count]").textContent = `${shown.length} of ${projects.length}`;
root.querySelectorAll("[data-kind-filter]").forEach((b) => b.setAttribute("aria-pressed", String(b.dataset.kindFilter === kind)));
}
+function showRate(p, message = "") {
+ const rate = root.querySelector("#mod-rate");
+ if (!rate || me === undefined) return;
+ rate.innerHTML = rateHtml(p, me, mine) + (message ? `
`;
}
-// One project's page.
-export function projectHtml(p) {
+// The rating control under a project's ratings: five stars to press when signed in (`mine`, the account's own
+// rating, pressed), a sign-in link when not, a note for the project's owners.
+export function rateHtml(p, me, mine) {
+ if (!me) return `Sign in with GitHub to rate`;
+ if ((p.owners || []).some((o) => o.toLowerCase() === String(me.login).toLowerCase())) return `
You publish it: players rate it.
`;
+ const stars = [1, 2, 3, 4, 5]
+ .map((n) => ``)
+ .join("");
+ return `${mine ? "Your rating" : "Rate it"}${stars}`;
+}
+
+// One project's page; `rating` is its ratings (null: none yet), left out when they aren't known.
+export function projectHtml(p, rating) {
const v = p.versions[0];
const caps = v.capabilities || [];
const capsHtml = caps.length
@@ -108,7 +166,9 @@ export function projectHtml(p) {
return `${icon(p)}