Repository navigation
fix(server): name shopping list entries by their recipe title - #625
Merged
Merged
Conversation
The "Selected recipes" panel named each entry by its file name: the `.shopping-list` format introduced in 7700032 (cooklang#318) stores no name, so `/api/shopping_list/items` derived one from the path. Before that the recipe page posted its title. A recipe declaring `title:` showed as `lamb-chops` instead of "Sicilian-style Scottadito Lamb Chops". `get_shopping_list_items` now reads each entry, nested menu recipe and sub-recipe reference through `cookcli_core::recipe::read` and uses its title, keeping the file name when there is none or the file can't be read. Sub-recipe names go in a new `included_reference_names`, parallel to `included_references`, which the page uses for the link labels. Resolved on the way out, so existing lists and later retitles are shown correctly too. Co-Authored-By: Claude Opus 5.5 <[email protected]>
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 #624.
The shopping list's "Selected recipes" panel named every entry by its file name. Since 7700032 (#318),
.shopping-liststores no name, soGET /api/shopping_list/itemsderived one from the path. With the seed,lamb-chops.cook(title: Sicilian-style Scottadito Lamb Chops) showed aslamb-chops.What changes
get_shopping_list_itemsresolves every entry'snamethroughcookcli_core::recipe::read. That covers recipes, menus and the recipes nested in a menu.readis the existing rulecook recipeuses: metadatatitle, else the file stem. When a file is missing, unreadable or has a path that isn't safe, the entry keeps today'srecipe_display_name().StoredEntrygets a display-onlyincluded_reference_names, in the same order asincluded_references. Each reference is resolved withresolve_referencefrom the entry's directory, so../references work. The field is never stored:Noneon load and ignored when adding.templates/shopping_list.htmluses those names for the sub-recipe links and falls back to the last path segment as before.api_docs.rs, regenerateddocs/api.md): describe the title rule and the new field. The example now uses the seed's real titles.Titles are resolved when the list is served rather than stored, so lists written before this, and recipes retitled later, show the current title.
Screenshot
Seed collection with
lamb-chops,Risotto(×2) and the2 Day Planmenu added:Tests
tests/shopping_list_titles_test.rs(server spawned viacommon::with_isolated_config) covers:../reference;cargo fmt,cargo clippy --all-targetsclean;cargo test --workspace: 1507 passed, 0 failed.🤖 Generated with Claude Code