Repository navigation
feat(server): upload step pictures from the web editor - #584
Merged
Merged
Conversation
LeMyst
marked this pull request as ready for review
September 29, 2026 18:21
The editor's Picture dialog handled only the title picture (cooklang#533), so a step's picture still had to be dropped into the recipe folder by hand. `/api/recipe_image/{*path}` now takes `?section=S&step=N` (section defaults to 1). PUT stores the upload as `Recipe.S.N.jpg` through the same pipeline as the title picture (10 MB, Exif orientation, 2048 px, re-encoded, HEIC explained) and removes the step's older files in both conventions and every extension (`Recipe.S.N.png`, `Recipe.G.jpg`, ...) so none can come back when the new one is removed. DELETE removes them all. A step or section the saved recipe does not have is a 400. The title picture and other steps are never touched. GET without a step also lists every section's steps with their text and picture. The lookup the recipe page uses for a step's picture moves to `builders::step_image`, so the API reports what the page shows. UI: a "Picture for" list in the dialog (Title / Section > Step N: text, marked with a camera once a step has a picture). The dialog saves the editor's text first, so steps are numbered as the page numbers them. On the recipe page, editors get a camera button on each step that opens the editor with that step picked (`#picture=S.N`, a fragment so it survives the /edit redirect). Strings are translated for every locale. Closes cooklang#562 Co-Authored-By: Claude Opus 5.5 <[email protected]>
LeMyst
force-pushed
the
feat/step-pictures
branch
from
September 30, 2026 06:40
fcc8daf to
8fb19be
Compare
4 tasks done
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #562
Follow-up to #533, which let the web editor set a recipe's title picture. A step's picture still had to be copied into the recipe folder by hand. This PR adds it to the same dialog and the same endpoint.
API
/api/recipe_image/{*path}takes?section=S&step=N. Both are one-based andsectiondefaults to 1. Withoutstep, the route behaves as before.?step=GET{ path, image, source, sections }. New:sectionslists each section that has steps, with each step's number, its text as plain words, and its picture URL. The editor's picker is built from this one request.{ path, section, step, image, source }PUTRecipe.jpgRecipe.S.N.jpg. The step's older files are removed in both conventions and every extension (Recipe.S.N.{jpeg,png,webp},Recipe.G.{jpg,jpeg,png,webp}, where G is the step counted across all sections).DELETERecipe.{jpg,jpeg,png,webp}404if there was none.title_imagepipeline: 10 MB route limit, Exif orientation, 2048 px, always re-encoded, and the415 heifmessage.400. So dostep=0, a non-number, andsectionwithoutstep. Nothing is written.Recipe.S.N, thenRecipe.G) moved intobuilders::step_image, and both the page and the API use it, so the API reports what the page shows.alice set the picture of step 1 in section 2 of recipe "Pizza.cook". It contains only numbers and the quoted file name.UI
viewer.can_edit_recipes(), hidden in the static export) get a cameraicon-btnon each step. It links to/edit/…#picture=S.N, which opens the dialog on that step. I used a fragment rather than a query because the extensionless/edit/Recipe→/edit/Recipe.cookredirect drops the query, while browsers keep the fragment.Tr::tprenders a message with{step}/{text}left in, and the script fills them in.Screenshots
These use the seed's Easy Pancakes, whose step 3 picture is the older
Easy Pancakes.3.jpgfile. The dialog and the recipe page find it all the same.Recipe page: a camera button on each step, for people who can edit recipes:
Editor: the camera button on step 3 opens the Picture dialog on that step:
Phone, dark mode:
Choices open to review
Recipe.S.N.jpg, including for recipes with a single section. The recipe page looks for this name first and the iOS app writes it. WritingRecipe.N.jpgfor single-section recipes would also work; switching is a one-line change inpicture_files.is_menuhides it, and menu pages don't show step pictures.Tests
tests/recipe_image_api_test.rs: 7 new tests. They cover the stored name, the reply and the recipe page HTML;sectiondefaulting to 1; cleanup of both conventions plus 5 untouched decoys; delete then404; 7 invalid queries across GET/PUT/DELETE with nothing written; HEIC, an empty body and a 2.4 MB body on the step route; and thesectionslisting with pictures in both conventions.tests/e2e/editor.spec.ts: 3 new Playwright tests: camera button → dialog on that step → upload (📷 marker, JPEG on disk, shown on the recipe page) → change → remove; the picker's grouped options; unsaved text saved before listing.Tr::tpunit test (fr-FR).cargo fmt,cargo clippy --all-targets(no warnings),cargo test(all pass),docs/api.mdregenerated, full Playwright chromium project: 246 passed, 5 skipped.🤖 Generated with Claude Code