Files
soleprint/soleprint/station/tools/histgen/templates/index.html

78 lines
3.1 KiB
HTML

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>histgen — station</title>
<link rel="stylesheet" href="/theme.css">
<style>
body { font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
background: var(--surface-0, #101418); color: var(--text-0, #d8dee4);
margin: 0; padding: 2rem; line-height: 1.55; }
h1 { margin: 0 0 .25rem; font-size: 1.4rem; }
p.lede { margin: 0 0 1.5rem; color: var(--text-1, #8b98a5); }
form { display: flex; gap: .5rem; margin-bottom: 1.5rem; }
input, button { font: inherit; padding: .45rem .7rem;
background: var(--surface-1, #161c22); color: inherit;
border: 1px solid var(--border, #2a333d); border-radius: 4px; }
button { cursor: pointer; }
.group { border: 1px solid var(--border, #2a333d); border-radius: 4px;
padding: .6rem .9rem; margin-bottom: .5rem;
background: var(--surface-1, #161c22); }
.n { color: var(--accent, #4fb3a6); }
.title { font-weight: 600; }
.untitled { color: var(--text-1, #8b98a5); font-style: italic; }
.paths { margin: .4rem 0 0; padding-left: 1.1rem; color: var(--text-1, #8b98a5);
font-size: .87rem; }
#summary { color: var(--text-1, #8b98a5); margin-bottom: 1rem; }
.err { color: #e08a5c; }
</style>
</head>
<body>
<h1>histgen</h1>
<p class="lede">A proposed history, before it is a history. Read-only —
<code>python -m station.tools.histgen apply &lt;repo&gt;</code> is what commits.</p>
<form onsubmit="load(event)">
<input id="repo" placeholder="path to a repo, e.g. rig" size="40" autofocus>
<button type="submit">Show plan</button>
</form>
<div id="summary"></div>
<div id="groups"></div>
<script>
async function load(event) {
event.preventDefault();
const repo = document.getElementById('repo').value.trim();
const summary = document.getElementById('summary');
const groups = document.getElementById('groups');
groups.innerHTML = ''; summary.textContent = 'Loading…';
try {
const res = await fetch(`/station/tools/histgen/api/plan?repo=${encodeURIComponent(repo)}`);
const data = await res.json();
if (!res.ok) throw new Error(data.detail || res.statusText);
summary.textContent =
`${data.commits} commits over ${data.files} files` +
(data.untitled.length ? `${data.untitled.length} still without a message` : '');
for (const g of data.groups) {
const el = document.createElement('div');
el.className = 'group';
const title = g.title
? `<span class="title">${escapeHtml(g.title)}</span>`
: `<span class="untitled">${escapeHtml(g.slug)} — no message yet</span>`;
el.innerHTML = `<span class="n">${String(g.n).padStart(2,'0')}</span> ${title}
<ul class="paths">${g.paths.map(p => `<li>${escapeHtml(p)}</li>`).join('')}</ul>`;
groups.appendChild(el);
}
} catch (e) {
summary.innerHTML = `<span class="err">${escapeHtml(e.message)}</span>`;
}
}
function escapeHtml(s) {
return String(s).replace(/[&<>"']/g, c =>
({'&':'&amp;','<':'&lt;','>':'&gt;','"':'&quot;',"'":'&#39;'}[c]));
}
</script>
</body>
</html>