Skip to content

feat(ui): show folder.jpg as a folder's picture in the recipe list - #847

Open
SebastienSyd wants to merge 1 commit into
cooklang:mainfrom
snicot:feat/folder-pictures
Open

SebastienSyd wants to merge 1 commit into
cooklang:mainfrom
snicot:feat/folder-pictures

Conversation

@SebastienSyd

Copy link
Copy Markdown

Closes #846.

A folder's card in the recipe list shows a picture in place of 📁 when the folder holds a folder.jpg. folder.jpeg, folder.png and folder.webp also work, tried in that order.

Change

  • src/web/builders.rs: a new folder_picture(dir) returns the first FOLDER_PICTURES name that is a file. Directory items in build_recipes_template get it as image_path, built through the existing get_image_path, so prefixes, URL-encoding and static mode all behave like recipe pictures. On the server, a picture that resolves outside the collection is skipped, because only_pictures would refuse to serve it (Recipe endpoints and /api/static follow symlinks out of the collection #698).
  • templates/recipes.html: the directory card renders item.image_path in the same h-48 banner as recipe_card.html, and falls back to the 📁 icon.
  • docs/server.md: a short "Folder pictures" section.

Serving needed no changes: /api/static already serves pictures, guests of --recipes-only included, and cook build already copies every picture.

No upload UI in this PR. A Picture button on the folder page could follow, re-using the title-picture dialog.

Tests

  • New unit tests in folder_picture_tests: no picture, folder.jpg, jpg preferred over png, and a directory named folder.jpg ignored.
  • Manual checks:
    • cook server: the card with folder.jpg gets <img src="/api/static/Dessert/folder.jpg"> and a folder without one keeps 📁. The picture comes back as 200 image/jpeg.
    • cook server --url-prefix /cook --recipes-only: the card links /cook/api/static/Dessert/folder.jpg, and a guest gets 200.
    • cook build web: folder.jpg is copied and index.html links ./api/static/Dessert/folder.jpg.
  • cargo fmt --all and cargo clippy --all-targets -- -D warnings are clean. cargo test passes except update::tests::release_workflow_builds_this_platform, which fails only because I ran it on aarch64 Linux, a platform the release matrix doesn't build.

🤖 Generated with Claude Code

A folder card shows `folder.jpg` (or .jpeg, .png, .webp) from the folder
in place of the 📁 icon, laid out like a recipe card's title picture.
The server already serves it through /api/static and `cook build`
already copies it. A linked picture outside the collection is skipped,
as /api/static would refuse it.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Folder cards always show 📁: let a folder have its own picture

1 participant