- Replace the static nginx site with a small Node server: serves public/, stores plays on a /data volume and exposes a JSON API. Writes need a shared UPLOAD_PASSWORD; unpublished plays are hidden without it. - Page photos (shrunk to <=1.15 MP JPEG in the browser) are transcribed one request per page by a Claude vision model (claude-haiku-5-5 by default, CLAUDE_MODEL to change) into the play markup, then stitched together: speaker spellings unified, gaps in page numbers marked as missing pages, failed pages flagged. DAILY_PAGE_LIMIT caps spend. - New pages: library (play menu), add (upload + progress), editor (text next to the photos, checks for [?] readings and one-off names, publish, delete). The reader loads plays from the API and remembers the chosen role per play; old /?postava= links still work. - PDF export: text now flows across original pages and prints at the on-screen size, so A4 sheets are full instead of half empty; page numbers in the footer. - docker-compose.yml + .env.example for one-click deploys; the 1931 play moves to seed/ and is copied into an empty volume on first start. - Tests: parser leniency, transcription assembly, API end to end with a stubbed Claude client. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01HA82gVRDXpoukzgMFumoJt
34 lines
1.7 KiB
JavaScript
34 lines
1.7 KiB
JavaScript
import { api, getPassword, clearPassword, esc, $ } from "./api.js";
|
|
|
|
// Old links (/?postava=Lída or /?hra=…) went straight to the reader.
|
|
const q = new URLSearchParams(location.search);
|
|
if (q.has("hra") || q.has("postava")) location.replace(`read.html${location.search}`);
|
|
|
|
const fmtDate = (iso) => new Date(iso).toLocaleDateString("cs-CZ", { day: "numeric", month: "numeric", year: "numeric" });
|
|
|
|
async function main() {
|
|
const [cfg, plays] = await Promise.all([api("config"), api("plays")]);
|
|
const loggedIn = Boolean(getPassword());
|
|
$("add").hidden = !cfg.uploads;
|
|
$("logout").hidden = !loggedIn;
|
|
$("logout").addEventListener("click", () => { clearPassword(); location.reload(); });
|
|
|
|
if (!plays.length) {
|
|
$("plays").innerHTML = `<li class="muted">Zatím tu není žádná hra.${cfg.uploads ? " Přidejte první tlačítkem nahoře." : ""}</li>`;
|
|
return;
|
|
}
|
|
$("plays").innerHTML = plays.map((p) => {
|
|
const badge = p.status === "processing" ? `<span class="badge">přepisuje se ${p.progress ? `${p.progress.done}/${p.progress.total}` : ""}</span>`
|
|
: !p.published ? `<span class="badge">koncept</span>` : "";
|
|
return `<li class="play-card">
|
|
<a class="play-main" href="read.html?hra=${encodeURIComponent(p.id)}">
|
|
<span class="play-title">${esc(p.title)} ${badge}</span>
|
|
${p.note ? `<span class="play-note">${esc(p.note)}</span>` : ""}
|
|
<span class="play-meta">upraveno ${fmtDate(p.updated)}</span>
|
|
</a>
|
|
${loggedIn ? `<a class="button" href="edit.html?id=${encodeURIComponent(p.id)}">Upravit</a>` : ""}
|
|
</li>`;
|
|
}).join("");
|
|
}
|
|
|
|
main().catch((err) => { $("plays").innerHTML = `<li class="error">Seznam her se nepodařilo načíst: ${esc(err.message)}</li>`; });
|