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

@ -1,26 +1,44 @@
# Divadelní čtečka (theater reader)
A small web app for reading a play script during rehearsals. An actor can:
A small web app for reading play scripts during rehearsals.
**Reading** (anyone):
- a **library** of plays to choose from,
- choose a **font** (typewriter, Atkinson Hyperlegible, Lexend, Literata or the system font), the text size and colours (light, sepia, dark),
- pick **their character**, which highlights their lines and lets them jump from one line to the next (▲ ▼, or `J` / `K` on a keyboard),
- switch between **running text** (hyphenation joined, spacing tidied) and the **original typescript lines**,
- open **reading mode** (settings hidden, large text), or
- **export a PDF** of their own copy, one page per page of the original. This goes through the print dialog, so choose "Save as PDF".
- pick **your character**: your lines are highlighted and ▲ ▼ (or `J` / `K`) jump between them,
- **running text** (hyphenation joined, spacing tidied) or the **original typescript lines**,
- **reading mode** (settings hidden), or **export a PDF** of your own copy: A4 sheets filled edge to edge at the size you chose, your lines highlighted. It goes through the print dialog, so choose "Save as PDF".
A link like `http://localhost:3010/?postava=Lída` opens the app with that character already chosen, so a director can send each actor their own link.
A link like `read.html?hra=hra-1931&postava=Lída` opens a play with the character already chosen, so a director can send each actor their own link.
## Running it
**Adding plays** (anyone with the upload password):
1. *Přidat hru*: give the title and pick a photo of each page.
2. Each photo is read by a Claude vision model (Claude Haiku 5.5 by default) and turned into the script markup: speakers, stage directions, page numbers. Missing pages are noticed from gaps in the page numbers.
3. The editor shows the text next to the photos and lists things to check (uncertain words marked `[?]`, characters who speak only once, pages that failed). Fix, tick *Zveřejněno*, save.
## Deploying
```sh
podman build -t theater-reader .
podman run -d --name theater-reader -p 127.0.0.1:3010:8080 theater-reader
cp .env.example .env && chmod 600 .env # then fill in the two secrets
docker compose up -d # or: podman compose up -d
```
Then open <http://localhost:3010>. The Dockerfile works with `docker` as well.
The app listens on port 3010 on loopback (`PORT` and `BIND_ADDRESS` change that). Plays and photos are kept in the `plays` volume. On first start the volume is seeded with the 1931 play.
| Variable | |
|---|---|
| `ANTHROPIC_API_KEY` | API key from [platform.claude.com](https://platform.claude.com). **A Claude Pro/Max subscription can't be used for this.** The API is billed separately, pay as you go. Without a key the app still works, but uploaded pages have to be typed up by hand. |
| `UPLOAD_PASSWORD` | Shared password for adding, editing and deleting plays. Unset = uploading switched off. |
| `CLAUDE_MODEL` | `claude-haiku-5-5` (default, around $0.001 a page) or `claude-sonnet-5-5` (reads hard pages better, roughly 20× the price). |
| `DAILY_PAGE_LIMIT` | Cap on pages transcribed per day, for all users together (default 300), so a leaked password can't run up a bill. |
| `MAX_PAGES` | Maximum photos per play (default 80). |
Without compose: `docker build -t theater-reader . && docker run -d -p 127.0.0.1:3010:8080 -v plays:/data --env-file .env theater-reader`.
## The play included
`public/plays/hra.txt` is a transcription of a 1931 typescript, pages 5–27. Pages 1–4 (presumably the title page and cast list) and page 7 are missing from the original, and the text breaks off at the end of page 27. See `AGENTS.md` for the text format and how to add the missing pages.
`seed/hra-1931/play.txt` is a transcription of a 1931 typescript, pages 5–27. Pages 1–4 (probably the title page and cast list) and page 7 are missing from the original, and the text breaks off at the end of page 27. Once deployed, the play is edited in the app. The seed file is only copied into an empty volume.
Fonts are self-hosted under the SIL Open Font License (see `public/fonts/OFL-*.txt`).