ZDDC/bootstrap/level1.html.tmpl
ZDDC ea385b5366 Initial commit
ZDDC — Zero Day Document Control. A file-naming convention plus five
single-file HTML tools (archive, transmittal, classifier, mdedit,
landing) and an optional Go HTTP server (zddc-server) with ACL and a
virtual archive index. Self-contained, offline-capable, dependency-free.

See README.md for an overview, AGENTS.md and ARCHITECTURE.md for the
build/release/architecture detail, bootstrap/README.md for the
two-level deployment install pattern, and zddc/README.md for the
HTTP server.
2026-04-27 11:05:47 -05:00

73 lines
2.8 KiB
Cheetah

<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Loading {{TOOL_TITLE}}…</title>
<style>html,body{margin:0;font:14px system-ui,sans-serif;color:#666;padding:1rem}</style>
</head>
<body>
Loading…
<script>
// Level-1 bootstrap. Fetches the tool from the deployment root (same
// origin) and document.write()s it in place. The target may be the real
// built tool HTML or a level-2 bootstrap that fetches from upstream.
//
// URL parameter ?v= selects a specific version or channel:
// ?v=0.0.4 (or v0.0.4) tries ../{{TOOL}}_v0.0.4.html locally
// ?v=alpha|beta|latest tries ../{{TOOL}}_<channel>.html locally
// (none) fetches ../{{TOOL}}.html (default)
//
// If the requested version is not staged locally, falls back to the
// root entry (../{{TOOL}}.html) — which, if it is a level-2 stub,
// forwards the param upstream to zddc.varasys.io. So ?v=0.0.4 works
// whether admins staged it locally OR a level-2 stub is at root.
//
// To pin this single tool to a fixed version permanently, replace the
// `fallback` constant below with an absolute URL like
// https://zddc.varasys.io/releases/{{TOOL}}_v0.0.4.html.
(async function () {
const params = new URLSearchParams(location.search);
const v = params.get('v');
const tool = '{{TOOL}}';
const channels = { alpha: '_alpha', beta: '_beta', latest: '_latest', stable: '_latest' };
function suffixFor(value) {
if (!value) return '';
if (value in channels) return channels[value];
const ver = value.startsWith('v') ? value.slice(1) : value;
return '_v' + ver;
}
const versioned = '../' + tool + suffixFor(v) + '.html';
const fallback = '../' + tool + '.html';
async function fetchHTML(url) {
const resp = await fetch(url, { cache: 'no-cache', credentials: 'omit' });
if (!resp.ok) throw new Error(resp.status + ' ' + resp.statusText);
return resp.text();
}
try {
let html;
if (v && versioned !== fallback) {
try {
html = await fetchHTML(versioned);
} catch (_) {
// Versioned copy not staged locally — let the root entry forward
// the request (level-2 stub will see ?v= and fetch upstream).
html = await fetchHTML(fallback);
}
} else {
html = await fetchHTML(fallback);
}
document.open();
document.write(html);
document.close();
} catch (err) {
document.body.textContent = 'Failed to load {{TOOL_TITLE}}: ' + err.message;
}
})();
</script>
</body>
</html>