Files
threshing-atlas/site/build.js
T
ekcSchianoandClaude Opus 5.5 614bfcda7c Host on Gitea: forge.yaml, Gitea workflows, host-neutral links
- forge.yaml: the repository's host (Gitea at git.kenschiano.net, limited visibility);
  the "Report a run" collector, the page's links (data/public/links.json, filled in by
  site/build.js) and the dataset metadata read it
- collection/etl/forge.py: issues, pull requests (merge when checks succeed) and labels
  for Gitea and GitHub; `python -m collection forge ...`
- .gitea/workflows: CI and the daily update (pushes a branch, opens a pull request that
  merges itself, opens an issue when a source breaks); .github/workflows kept for GitHub
- docs: Gitea setup (REPO_SETTINGS), the bot reading atlas files from the repository

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01UCzTd31GphpMXDhQqWrCMQ
2026-11-12 02:46:17 +00:00

40 lines
2.2 KiB
JavaScript

// Assemble the static Atlas site into dist/ (no dependencies).
// node site/build.js [outDir]
const fs = require("fs");
const path = require("path");
const root = path.resolve(__dirname, "..");
const out = path.resolve(root, process.argv[2] || "dist");
const copy = (from, to) => {
fs.mkdirSync(path.dirname(path.join(out, to)), { recursive: true });
fs.copyFileSync(path.join(root, from), path.join(out, to));
};
fs.rmSync(out, { recursive: true, force: true });
for (const f of fs.readdirSync(path.join(root, "site/atlas"))) copy(`site/atlas/${f}`, f);
// The page is written as an Artifact body (the artifact host adds the document skeleton). For GitHub Pages and
// local serving, give it its own doctype, charset and viewport.
{
const p = path.join(out, "index.html");
// links from forge.yaml (data/public/links.json, written by `python -m collection build`)
const links = JSON.parse(fs.readFileSync(path.join(root, "data/public/links.json"), "utf8"));
const html = fs.readFileSync(p, "utf8").replace(/\{\{(\w+)\}\}/g, (m, k) => (k in links ? links[k] : m));
fs.writeFileSync(p, html);
if (!/^\s*<!doctype/i.test(html))
fs.writeFileSync(p, `<!doctype html>\n<meta charset="utf-8">\n<meta name="viewport" content="width=device-width, initial-scale=1">\n${html}`);
}
// The route advisor and the bot's text mapping (Ken's bot downloads these two from the published site)
copy("core/graph.js", "graph.js");
copy("core/solver.js", "solver.js");
// The numbers the page shows (all computed in Python) and the published data
for (const f of ["stats.json", "register.json", "graph.json", "policy.json"]) copy(`data/public/${f}`, `data/${f}`);
copy("data/public/runs_clean.csv", "data/runs_clean.csv");
for (const f of ["croissant.json", "dictionary.yaml"]) copy(`data/${f}`, `data/${f}`);
// Source files shown in the page's "view the code" panel
copy("core/atlas/coding.py", "python/coding.py");
copy("core/spec/form.yaml", "python/form.yaml");
for (const f of ["measures.yaml", "site_stats.py", "stats_core.py"]) copy(`analysis/stats/${f}`, `python/${f}`);
copy("README.md", "README.md");
fs.writeFileSync(path.join(out, ".nojekyll"), "");
console.log(`Site built in ${path.relative(root, out) || "."}`);