Step images: upload, crop, variants, guarded media route (#11) #25

Merged
miko merged 2 commits from feature/11-step-images into development 2026-11-02 10:12:43 +01:00
Owner

Closes #11.

Up to three 4:3 step images per step (ADR-0006).

  • Model: StepImage (stepId, position, fileKey, original size, crop rectangle) with migration.
  • Upload: browser crop dialog fixed to 4:3 (mouse and keyboard) uploads the original plus the crop rectangle. Server checks content type (JPEG/PNG/WebP) and size (≤ 20 MB; server-action body limit raised to 21 MB).
  • Processing: sharp applies EXIF orientation, strips EXIF, crops and renders thumb/medium/large WebP synchronously.
  • Storage: UPLOAD_DIR, random UUID keys, original kept, behind a read/write/delete interface that rejects path traversal.
  • /media/[imageId]/[file]: checks effective visibility. Published public guides get public, immutable; internal and draft guides get private; hidden or missing images return 404. The original is served only to editors (private, no-store) for re-cropping.
  • Re-crop: after a confirmation, the image gets a new id, so a cached URL never changes content and annotations (#12) go with the old image.
  • Editor: add, re-crop, reorder and delete images; changes are saved immediately. A step-row lock enforces the three-image limit under concurrent uploads.
  • Reading view: iFixit layout with images and thumbnails on the left, step lines on the right, content below.
  • ADR-0006: updated with the new id per crop, the original route, and the shared-cache trade-off.

Tests: crop geometry, sharp pipeline (EXIF orientation and stripping), disk storage, access and cache decision, reading-view rendering.

Note: restart the dev server after pulling. The global Prisma client predates StepImage.

🤖 Generated with Claude Code

Closes #11. Up to three 4:3 step images per step (ADR-0006). - **Model:** `StepImage` (stepId, position, fileKey, original size, crop rectangle) with migration. - **Upload:** browser crop dialog fixed to 4:3 (mouse and keyboard) uploads the original plus the crop rectangle. Server checks content type (JPEG/PNG/WebP) and size (≤ 20 MB; server-action body limit raised to 21 MB). - **Processing:** sharp applies EXIF orientation, strips EXIF, crops and renders thumb/medium/large WebP synchronously. - **Storage:** `UPLOAD_DIR`, random UUID keys, original kept, behind a read/write/delete interface that rejects path traversal. - **`/media/[imageId]/[file]`:** checks effective visibility. Published public guides get `public, immutable`; internal and draft guides get `private`; hidden or missing images return 404. The original is served only to editors (`private, no-store`) for re-cropping. - **Re-crop:** after a confirmation, the image gets a new id, so a cached URL never changes content and annotations (#12) go with the old image. - **Editor:** add, re-crop, reorder and delete images; changes are saved immediately. A step-row lock enforces the three-image limit under concurrent uploads. - **Reading view:** iFixit layout with images and thumbnails on the left, step lines on the right, content below. - **ADR-0006:** updated with the new id per crop, the original route, and the shared-cache trade-off. Tests: crop geometry, sharp pipeline (EXIF orientation and stripping), disk storage, access and cache decision, reading-view rendering. Note: restart the dev server after pulling. The global Prisma client predates `StepImage`. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
Up to three 4:3 images per step (ADR-0006). The browser crops to 4:3 and
uploads the original with the crop rectangle; sharp applies the EXIF
orientation, strips metadata and renders thumb/medium/large WebP variants.
Files live in UPLOAD_DIR behind a small storage interface. /media checks the
guide's effective visibility; re-cropping gives the image a new id so the
immutable cache stays truthful. The reading view shows the iFixit layout.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- Use glossary terms instead of "media" in identifiers.
- Lock the step row so concurrent uploads cannot exceed three images and
  re-crops keep their place during a reorder.
- Remove written files whenever rendering or saving fails.
- Answer NOT_EDITABLE consistently; share upload rules and messages
  between browser and server.
- ADR-0006: record per-crop image ids, the original route and the
  shared-cache trade-off.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
miko merged commit 7490980875 into development 2026-11-02 10:12:43 +01:00
Sign in to join this conversation.
No reviewers
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
MassiveDynamic/kataba!25
No description provided.