Category description and image (#39) #41

Merged
miko merged 1 commit from feature/39-category-description-image into development 2026-11-02 18:51:37 +01:00
Owner

Closes #39. Both fields are in v1.

Summary

 model Category
   description Json?          # now edited and rendered
-  image       String?        # unused
+  image       CategoryImage? # 4:3, like CoverImage
/admin/categories/[id]
  <CategoryForm>              # + Editor.js description (also on /new)
  <CategoryImageEditor>       # saved at once, admins only
/c/[...slug]
  <RichText description>      # own renderer (ADR-0005)
  <CategoryListing>           # tiles show the Category Image
/media/[imageId]/[file]
  categoryImageAccess         # effective visibility; original only for admins (ADR-0006)

Shared image module, now used by Cover Image and Category Image:

 src/images/
+├── components/SingleImageEditor.tsx  # was coverImages/CoverImageEditor
+├── storeImage.ts                     # storeReplacingImage, from setCoverImage
+└── tileImage.ts                      # was coverImages/tileImage

GLOSSARY gets "Category Image"; ADR-0005 and ADR-0006 get a line each.

Evidence

  • Before: no UI sets or shows Category.description / Category.image.
    After: e2e/categories.spec.ts passes:
    admin writes description, creates category, adds image (crop → upload)
    guest sees description; tile image loads, Cache-Control public
    admin makes category internal
    guest GET image → 404; viewer → 200, Cache-Control private
    
  • Unit: categoryImageAccess (4 tests), CategoryListing tiles (2 tests); 268/268 unit tests, typecheck and lint green.
  • Known flake, not from this PR: authoring.spec / access.spec sometimes fail in parallel with "Transaction failed due to a write conflict or a deadlock" on the step/guide row locks; reproduced with the new spec excluded.

Merge Danger

Door: two-way, nearly

The migration drops Category.image, which nothing ever wrote, so no data is lost; rolling back means a reverse migration.

Blast Radius: moderate

Cover image editing and upload now run through the shared SingleImageEditor / storeReplacingImage (behaviour unchanged, but no E2E covers cover images). The media route now also looks up CategoryImage. Open: submitting the category form before Editor.js has loaded saves an empty description (same as GuideForm today).

🤖 Generated with Claude Code

Closes #39. Both fields are in v1. ## Summary ```diff model Category description Json? # now edited and rendered - image String? # unused + image CategoryImage? # 4:3, like CoverImage ``` ```text /admin/categories/[id] <CategoryForm> # + Editor.js description (also on /new) <CategoryImageEditor> # saved at once, admins only /c/[...slug] <RichText description> # own renderer (ADR-0005) <CategoryListing> # tiles show the Category Image /media/[imageId]/[file] categoryImageAccess # effective visibility; original only for admins (ADR-0006) ``` Shared image module, now used by Cover Image and Category Image: ```diff src/images/ +├── components/SingleImageEditor.tsx # was coverImages/CoverImageEditor +├── storeImage.ts # storeReplacingImage, from setCoverImage +└── tileImage.ts # was coverImages/tileImage ``` GLOSSARY gets "Category Image"; ADR-0005 and ADR-0006 get a line each. ## Evidence - **Before:** no UI sets or shows `Category.description` / `Category.image`. **After:** `e2e/categories.spec.ts` passes: ```text admin writes description, creates category, adds image (crop → upload) guest sees description; tile image loads, Cache-Control public admin makes category internal guest GET image → 404; viewer → 200, Cache-Control private ``` - Unit: `categoryImageAccess` (4 tests), `CategoryListing` tiles (2 tests); 268/268 unit tests, typecheck and lint green. - Known flake, not from this PR: `authoring.spec` / `access.spec` sometimes fail in parallel with "Transaction failed due to a write conflict or a deadlock" on the step/guide row locks; reproduced with the new spec excluded. ## Merge Danger **Door:** two-way, nearly The migration drops `Category.image`, which nothing ever wrote, so no data is lost; rolling back means a reverse migration. **Blast Radius:** moderate Cover image editing and upload now run through the shared `SingleImageEditor` / `storeReplacingImage` (behaviour unchanged, but no E2E covers cover images). The media route now also looks up `CategoryImage`. Open: submitting the category form before Editor.js has loaded saves an empty description (same as `GuideForm` today). 🤖 Generated with [Claude Code](https://claude.com/claude-code)
Both fields are in v1. Admins write a category's description with
Editor.js in the category form; the category page renders it with the
own renderer (ADR-0005). The bare Category.image column becomes a
CategoryImage table modelled on CoverImage: set, re-cropped and removed
on the category's edit page, shown on its tile, and served through
/media by the category's effective visibility, its original to admins
only (ADR-0006).

The cover image editor and its upload step move into the shared image
module (SingleImageEditor, storeReplacingImage) so both owners use them.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
miko merged commit 852becc732 into development 2026-11-02 18:51:37 +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!41
No description provided.