Repository navigation
feat(server): search results page with recipe cards and pictures - #829
Merged
Merged
Conversation
The search box's dropdown shows names only. `GET /search?q=…` lists every hit as the recipe index's cards, pictures and tags included, in the order `cook search` and `/api/search` give them. The nav search box is now a GET form on the server, so Enter opens the page (a highlighted row still opens its recipe), and the dropdown ends with a sticky "See all results" row. An empty query goes back to the recipes. The card markup moved to `recipe_card.html`, shared by both pages. `/search` is a recipe read for `--recipes-only` guests. A static `cook build web` site keeps the dropdown only. Closes cooklang#828 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 #828.
The search box's dropdown shows names only. This adds a results page that shows every hit as the recipe index's cards, pictures and tags included, for when the picture is what helps you choose.
What changes
GET /search?q=…(ui::search_page) lists the hits ofcookcli_core::search::search, filtered withinside_collectionlike/api/search. The page, the dropdown andcook searchfind the same recipes in the same order. Each hit's picture and tags come from its front matter (RecipeEntry::from_path), and pictures are served by/api/static, like the index.GET /searchform on the server, so Enter opens the page, with or without JS. Enter on a row highlighted with the arrow keys still opens that recipe.autocomplete="off"stops the browser's own history list from covering the dropdown./search,?q=, blanks) redirects to the recipe index. The existing "should clear search" spec already expected Enter in an emptied box to go back there.templates/recipe_card.html, which bothrecipes.htmlandsearch.htmlinclude, so the two can't drift. The index renders exactly as before.--recipes-only:/searchis inRECIPE_READS, so guests can use it.search-titleandsearch-see-all, in all ten locales. The count reusesrecipes-count. Translations other than English and French are mine; corrections welcome.Card links keep the file extension (
/recipe/Breakfast/Easy Pancakes.cook), as the dropdown's do, so a recipe and a menu with the same name stay apart.Not in this PR
cook build webkeeps only the dropdown: a static site has no server to answer/search, so its search box isn't a form. The page could be rendered in the browser fromsearch-index.jslater if someone wants it there.Tests
tests/search_page_test.rs, 8 tests throughcommon::with_isolated_config: cards with picture and tags, same hits as/api/search(every term must match), no-hit message, empty-query redirect, the query escaped, the nav form,--recipes-onlyguests, and--url-prefixon links, pictures and the redirect.tests/e2e/search.spec.ts, 4 new specs: Enter opens the page with cards and keeps the query in the box, "See all results" opens it, Enter on a highlighted row still opens that recipe, and the no-hit page. The 5 existing search specs pass unchanged.--workers=1after a server restart, exceptsign-in-notice.spec.ts, which fails about 1 run in 6 on a shopping-list tick ("Clicking the checkbox did not change its state"). That page's code isn't touched here.cargo fmt,cargo clippy --all-targets(no warnings),cargo test --workspace(1887 passed)Test image:
registry.favier.io/cookcli:pr-829🤖 Generated with Claude Code