Let people add plays from photos; library, editor, compose; full-page PDF

- 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
This commit is contained in:
agent 2026-11-03 09:43:32 +00:00
parent 2608d10dd2
commit 46aa1236ed
32 changed files with 1761 additions and 160 deletions

View file

@ -33,7 +33,7 @@ export function parsePlay(source) {
close();
continue;
}
if (!page) throw new Error(`Text before the first page marker: ${raw}`);
if (!page) { page = { num: "?", missing: false, blocks: [] }; pages.push(page); }
if (raw.startsWith("@")) {
lastSpeaker = raw.slice(1).trim();
@ -63,8 +63,8 @@ export function parsePlay(source) {
} else {
// dialogue; after a page break or a standalone direction it belongs to the last speaker
if (!block || block.type !== "speech") {
if (!lastSpeaker) throw new Error(`Dialogue without a speaker on page ${page.num}`);
block = { type: "speech", speaker: lastSpeaker, cont: true, parts: [] };
// speaker "" = we don't know who says it (e.g. the first page is missing)
block = { type: "speech", speaker: lastSpeaker || "", cont: true, parts: [] };
page.blocks.push(block);
}
addPart("text", raw, false);
@ -78,7 +78,7 @@ export function speakers(pages) {
const counts = new Map();
for (const p of pages)
for (const b of p.blocks)
if (b.type === "speech" && !b.cont) counts.set(b.speaker, (counts.get(b.speaker) || 0) + 1);
if (b.type === "speech" && !b.cont && b.speaker) counts.set(b.speaker, (counts.get(b.speaker) || 0) + 1);
return [...counts].sort((a, b) => b[1] - a[1]).map(([name, count]) => ({ name, count }));
}
@ -106,3 +106,22 @@ export function tidySpacing(text) {
.replace(/\( +/g, "(")
.replace(/\s{2,}/g, " ");
}
// Problems worth showing in the editor: [{ page, message }].
export function lint(pages) {
const out = [];
const seen = new Set();
for (const p of pages) {
if (p.num === "?") out.push({ page: p.num, message: "Text před první značkou strany (=číslo)." });
if (seen.has(p.num)) out.push({ page: p.num, message: `Strana ${p.num} je v textu dvakrát.` });
seen.add(p.num);
for (const b of p.blocks) {
if (b.type === "speech" && !b.speaker) out.push({ page: p.num, message: "Replika bez postavy (chybí řádek @Jméno)." });
if (!b.parts) continue;
for (const part of b.parts)
for (const line of part.lines)
if (line.includes("[?]")) out.push({ page: p.num, message: `Nejisté čtení: „${line.trim()}“` });
}
}
return out;
}