Skip to content

feat(server): search results page with recipe cards and pictures - #829

Merged
LeMyst merged 1 commit into
cooklang:mainfrom
LeMyst:feat/search-results-page
Nov 7, 2026
Merged

LeMyst merged 1 commit into
cooklang:mainfrom
LeMyst:feat/search-results-page

Conversation

@LeMyst

@LeMyst LeMyst commented Nov 7, 2026

Copy link
Copy Markdown
Collaborator

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.

Results page On a phone The dropdown's new row

What changes

  • GET /search?q=… (ui::search_page) lists the hits of cookcli_core::search::search, filtered with inside_collection like /api/search. The page, the dropdown and cook search find 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.
  • The nav search box is a GET /search form 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.
  • "See all results" sits at the bottom of the dropdown, sticky so a long list doesn't hide it. It's the way in for mouse and touch users.
  • An empty query (/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.
  • The card markup moved to templates/recipe_card.html, which both recipes.html and search.html include, so the two can't drift. The index renders exactly as before.
  • --recipes-only: /search is in RECIPE_READS, so guests can use it.
  • Two new messages, search-title and search-see-all, in all ten locales. The count reuses recipes-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 web keeps 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 from search-index.js later if someone wants it there.

Tests

  • tests/search_page_test.rs, 8 tests through common::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-only guests, and --url-prefix on 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.
  • Full chromium Playwright run: the 10 failures from the parallel run (editor completion, shopping-list ticks) pass with --workers=1 after a server restart, except sign-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

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]>
@LeMyst
LeMyst marked this pull request as ready for review November 7, 2026 05:38
@LeMyst
LeMyst merged commit d94b10f into cooklang:main Nov 7, 2026
6 checks passed
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.

feat(server): search results page with recipe cards and pictures

1 participant