From fb4897ec0922d20a209498ee4cc0a35c1b893a97 Mon Sep 17 00:00:00 2001
From: Ludovic Marie <136255825+ludovic111@users.noreply.github.com>
Date: Sat, 24 Oct 2026 22:10:05 +0200
Subject: [PATCH] Website: /mods/submit, the registry's submission form
Sign in with GitHub through the registry's service (no scope), then send
the file and its page; the service checks the file, stages it and opens the
pull request, and the page links to it or says what to fix. A file named
-. fills in its kind, id and version. Shader packs are
listed and disabled until Horizon's own format exists. Caddy sends
/api/mods/* to REGISTRY_UPSTREAM (unset: the form says it isn't open), and
"Submit yours" now leads here.
Co-Authored-By: Claude Opus 5.5
---
website/Caddyfile | 7 +++-
website/README.md | 6 ++-
website/build.mjs | 9 +++--
website/src/mods-submit.js | 80 ++++++++++++++++++++++++++++++++++++++
website/src/mods.js | 67 ++++++++++++++++++++++++++++++-
website/src/mods.test.mjs | 15 ++++++-
website/src/style.css | 12 ++++++
7 files changed, 187 insertions(+), 9 deletions(-)
create mode 100644 website/src/mods-submit.js
diff --git a/website/Caddyfile b/website/Caddyfile
index 60554fd20..fb96e836d 100644
--- a/website/Caddyfile
+++ b/website/Caddyfile
@@ -35,7 +35,12 @@
rewrite /benchmarks /benchmarks.html
@doc path_regexp doc ^/docs/([a-z-]+)$
rewrite @doc /docs/{re.doc.1}.html
- # The registry: /mods, and /mods/ baked at build time, else the list page, whose script shows a project
+ # The registry's submission service (crates/horizon-mod-registry), over Railway's private network. Unset, the
+ # form says it isn't open.
+ handle /api/mods/* {
+ reverse_proxy {$REGISTRY_UPSTREAM:127.0.0.1:9}
+ }
+ # The registry: /mods, /mods/submit and /mods/ baked at build time, else the list page, whose script shows a project
# published since.
rewrite /mods /mods.html
@mod {
diff --git a/website/README.md b/website/README.md
index 52e26ec61..2813ce6dd 100644
--- a/website/README.md
+++ b/website/README.md
@@ -29,7 +29,7 @@ src/style.css every style, on top of the tokens
src/main.js the home page: download buttons, recent releases, links, contributors, nav, tabs, lightbox, motion
src/chrome.js the light/dark switch, the phone menu and GitHub fetching, shared by the pages
src/releases-page.js the Releases page: the channel filter and the refresh from GitHub
-src/mods.js the registry's markup (list, project page), shared by build and page; mods-page.js: the filter, the search, the refresh
+src/mods.js the registry's markup (list, project page, submit form), shared by build and page; mods-page.js: the filter, the search, the refresh; mods-submit.js: the form's sign-in and sending
src/benchmarks-page.js the Benchmarks page: players' results from the telemetry server, the picker
src/bench.js the Benchmarks tables, shared by build and page
src/hardware.js the spec table estimates use (GPU TFLOPS and bandwidth, CPU single-thread score)
@@ -110,7 +110,9 @@ a Caddy stage serves `dist/` on `$PORT` with compression, cache headers, a stric
Content-Security-Policy and the 404 page. Its watch patterns also redeploy when the README
or `launcher/links.json` change on main. No variables are needed; an optional
`GITHUB_TOKEN` (read-only, public repos) lets the build bake the releases even when
-GitHub's anonymous rate limit is hit.
+GitHub's anonymous rate limit is hit. `REGISTRY_UPSTREAM`
+(`horizon-mod-registry.railway.internal:8080`) sends `/api/mods/*` to the registry's submission
+service (`crates/horizon-mod-registry`); unset, `/mods/submit` says the form isn't open.
## Rules the site keeps
diff --git a/website/build.mjs b/website/build.mjs
index 0a813063b..8a6e04abe 100644
--- a/website/build.mjs
+++ b/website/build.mjs
@@ -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 { INDEX_URL, KINDS, SUBMIT, listHtml, projectHtml, readIndex } from "./src/mods.js";
+import { INDEX_URL, KINDS, SUBMIT, listHtml, projectHtml, readIndex, submitHtml } from "./src/mods.js";
const site = dirname(fileURLToPath(import.meta.url));
const dist = join(site, "dist");
@@ -186,7 +186,7 @@ await writeFile(join(dist, "favicon.ico"), Buffer.concat([ico, png32]));
const names = {};
const rewrite = (code) => code.replace(/"\.\/(\w+\.js)"/g, (all, file) => (names[file] ? `"./${names[file]}"` : all));
// Dependencies before what imports them.
-const modules = ["markdown.js", "versions.js", "chrome.js", "hardware.js", "estimate.js", "releases.js", "contributors.js", "bench.js", "main.js", "releases-page.js", "benchmarks-page.js", "mods.js", "mods-page.js"];
+const modules = ["markdown.js", "versions.js", "chrome.js", "hardware.js", "estimate.js", "releases.js", "contributors.js", "bench.js", "main.js", "releases-page.js", "benchmarks-page.js", "mods.js", "mods-page.js", "mods-submit.js"];
for (const file of modules) {
const code = rewrite(await readFile(join(site, "src", file), "utf8"));
names[file] = `${file.replace(".js", "")}.${fingerprint(code)}.js`;
@@ -401,7 +401,8 @@ ${listHtml(modProjects)}
`;
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 },
- ...modProjects.map((p) => ({ file: `mods/${p.id}.html`, path: `/mods/${p.id}`, title: p.name, description: p.summary || p.name, main: projectHtml(p) })),
+ { file: "mods/submit.html", path: "/mods/submit", title: "Submit to the registry", description: "Submit a mod, a modpack or a resource pack made for Horizon: it is checked, reviewed, then listed here and in the launcher.", main: submitHtml(), js: "mods-submit.js" },
+ ...modProjects.filter((p) => p.id !== "submit").map((p) => ({ file: `mods/${p.id}.html`, path: `/mods/${p.id}`, title: p.name, description: p.summary || p.name, main: projectHtml(p) })),
];
await mkdir(join(dist, "mods"), { recursive: true });
const modsData = JSON.stringify(modIndex && modProjects.length ? { schema: modIndex.schema, projects: modProjects } : null).replace(/ form.elements.namedItem(name);
+
+function signedOut(message) {
+ auth.innerHTML = `
It only reads your public profile: your GitHub name goes on the pull request and in the project's owners.
`;
+ form.hidden = true;
+}
+
+async function start() {
+ let me;
+ try {
+ const r = await fetch(`${API}/me`, { credentials: "same-origin" });
+ if (r.status === 401) return signedOut("Sign in to submit: reviewers and updates go through your GitHub account.");
+ if (!r.ok) throw new Error(String(r.status));
+ me = await r.json();
+ } catch {
+ auth.innerHTML = `
${escape(json.error || `The service answered ${r.status}.`)}
`;
+ }
+ } catch {
+ result.innerHTML = `
The service didn't answer. Try again in a minute.
`;
+ } finally {
+ send.disabled = false;
+ }
+});
+
+setUpTheme();
+setUpMenu();
+start();
diff --git a/website/src/mods.js b/website/src/mods.js
index 236a376ab..4819af374 100644
--- a/website/src/mods.js
+++ b/website/src/mods.js
@@ -5,7 +5,9 @@ import { markdown, escape } from "./markdown.js";
export const INDEX_URL = "https://ludovic111.github.io/horizon-mods/index.json";
const REGISTRY = "https://github.com/ludovic111/horizon-mods";
-export const SUBMIT = `${REGISTRY}#submit`;
+export const SUBMIT = "/mods/submit";
+// The submission form's service (crates/horizon-mod-registry), behind the site's own address.
+export const API = "/api/mods";
export const SCHEMA = 1;
// The kinds the site shows, in the filter's order. Kinds a newer index adds are left out until the site knows them.
@@ -108,3 +110,66 @@ export function projectHtml(p) {
Report it→
`;
}
+
+// /mods/submit: the form. Its script (mods-submit.js) signs in, then sends the page and the file to the service, which
+// checks the file and opens the pull request the reviewers read.
+const field = (name, label, input, hint = "") =>
+ ``;
+const text = (name, attrs = "") => ``;
+
+export function submitHtml() {
+ return `
ModsSubmit
+
Submit to the registry
+
A mod, a modpack of registry mods, or a resource pack made for Horizon. The form checks the file and opens a pull request; a reviewer reads it, its source and the checks' report, and merging publishes it to this site and the launcher.