Edit plays page by page, with a review of uncertain words

The editor shows one original page next to its photo, with a page list,
page number and missing toggle, and highlights {uncertain} words. The
review dialog steps through them with the photo zoomed to about the
right line. Pages can be re-read from their photo or added from a new
photo, which fills a !N missing marker.

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-04 16:15:27 +00:00
parent 6240907809
commit debf1aa8bc
5 changed files with 679 additions and 152 deletions

View file

@ -10,15 +10,17 @@ UI language is Czech.
- `server/main.mjs`: HTTP server, routing, static files, auth (`x-upload-password` header vs `UPLOAD_PASSWORD`), daily page cap, background transcription job.
- `server/store.mjs`: plays on disk, `DATA_DIR/plays/<id>/{meta.json,play.txt,img/NNN.jpg}`. Atomic writes; per-play lock for meta updates.
- `server/providers.mjs`: `makeProvider(env)` returns `{ name, model, transcribe(jpeg) }` for OpenRouter or Anthropic. Errors become `PageError`s whose message is shown in the editor. OpenRouter retries 408/429/5xx and network errors itself.
- `server/transcribe.mjs`: `splitPage` → `normalizeSpeakers` → `assemble` turn the per-photo answers into one play file. `server/prompt.mjs` holds the prompt (shared by both providers), which teaches the markup below.
- `public/`: four pages: `index.html` library (`library.js`), `read.html` reader (`reader.js`), `add.html` upload (`add.js`: shrinks photos to ≤1.15 MP JPEG in the browser), `edit.html` editor (`edit.js`). `api.js` holds the fetch and password helpers. `parse.js` is the markup parser, shared with the server tests.
- `server/transcribe.mjs`: `splitPage` → `normalizeSpeakers` → `assemble` turn the per-photo answers into one play file: sorted by the page number read off each photo, repeats of a page dropped (kept in `meta.duplicates`), and `meta.photos` recording which photo belongs to which page marker. `server/prompt.mjs` holds the prompt (shared by both providers), which teaches the markup below.
- `public/`: four pages: `index.html` library (`library.js`), `read.html` reader (`reader.js`), `add.html` upload (`add.js`: shrinks photos to ≤1.15 MP JPEG in the browser), `edit.html` editor (`edit.js`: splits the text at page markers and edits one page at a time beside its photo; review dialog for `{uncertain}` words). `api.js` holds the fetch, password and login-button helpers, `photos.js` the in-browser JPEG shrinking and duplicate-photo fingerprint. `parse.js` is the markup parser, shared with the server tests.
- `seed/`: plays copied into an empty data volume on first start.
- `public/fonts/`: self-hosted woff2 + OFL licences, made by `tools/fetch_fonts.py` (keep its `FAMILIES` and `FONTS` in `reader.js` in step).
## API
`GET /api/config`, `POST /api/login`, `GET|POST /api/plays`, `GET|PATCH|DELETE /api/plays/:id`, `GET|PUT /api/plays/:id/text`,
`GET|PUT /api/plays/:id/images/:n` (raw `image/jpeg` body), `POST /api/plays/:id/transcribe` (202, then poll the meta's `progress`).
`GET|PUT /api/plays/:id/images/:n` (raw `image/jpeg` body), `POST /api/plays/:id/transcribe` (202, then poll the meta's `progress`),
`POST /api/plays/:id/images/:n/transcribe` (one photo, answers `{ num, body }` and leaves the text alone; the editor inserts it).
`PATCH` takes `title`, `note`, `published`, `photos` (photo number or `null` per page marker, in text order) and `duplicates`.
Everything that writes needs the password. Unpublished plays answer 404 without it. Transcription refuses once the text has been
edited by hand, so it can't overwrite corrections.
@ -49,6 +51,8 @@ One directive per line; blank lines are ignored.
The text keeps the typescript's line breaks, spelling and missing spaces ("dobře.Ale"). The "running text" mode joins
hyphenated words (`nepří-` / `jemné`, also the typist's `ne -` / `spokojenců`) and adds the missing spaces. **A dash that
really is punctuation at the end of a line must be typed as `–` (en dash)**, or it gets joined to the next word.
`[?]` after a word marks an uncertain reading. The editor lists them.
`{word}` marks an uncertain reading and `{word|other}` adds the model's alternative; the reader shows the first one, and the
editor's review dialog steps through them. (The older `word[?]` form is converted when transcribing.)
To add a missing page to a play, e.g. page 7 of the 1931 play, open it in the editor and replace `!7` with `=7` and the page's text.
To add a missing page to a play, e.g. page 7 of the 1931 play, open it in the editor and use *+ Z fotky*: the photo is
transcribed and fills the `!7` marker. Without a photo, select page 7, untick *v originále chybí* and type the text.