feat(server): add federation search page to discover and save recipes
I maintainer di solito rispondono entro 1 giorno
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 4/5
- Tempo stimato
- 3-5 giorni
- Idoneità per principianti
- 48/100
- Tipo di issue
- Funzionalità
- Chiarezza
- Abbastanza chiara
- Stato di attività
- Attiva
- Stack tecnologico
- rust
- Ambito
- full-stack
Direzione di ricerca
Inizia da src/server/ui.rs, soprattutto dal router ui() e dal flusso create_recipe esistente, quindi esamina src/server/templates.rs, templates/base.html e i template discover proposti. Segui la configurazione Fluent esistente ed esegui i test cargo pertinenti prima di aggiungere la coverage. Il lavoro è completato quando i criteri di accettazione sono soddisfatti, inclusi le modalità disabled/static, la gestione degli errori, i salvataggi sicuri e cargo fmt, cargo clippy e cargo test.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
Summary
Add a "Discover" page to the CookCLI web UI that searches the Cooklang Federation over its HTTP API, previews a result, and saves the .cook file into the user's local recipe collection.
Today the server's search box only covers recipes already on disk. The federation is where recipes from other people's published feeds are indexed, and there is currently no path from "someone published a recipe" to "it's in my collection" other than copy-paste.
Federation API used
Public instance: https://recipes.cooklang.org (see cooklang/federation).
GET /api/search?q=<query>&locale=<lang>— Tantivy query syntax: bare terms, field-scoped (title:,tags:,ingredients:,difficulty:,servings:,total_time:), booleanAND/OR, negation-tags:dessert, rangestotal_time:[0 TO 30], quoted multi-word values.GET /api/recipes/:id— recipe details, includinglocaleandlocale_source.GET /api/recipes/:id/download— the raw.cookfile.
Proposed UI
GET /discover— search form plus results list. Query and locale round-trip through URL params (/discover?q=...&locale=...) so results are linkable and back/forward work. Empty state explains what the federation is; no-results and API-error states are distinct.- Result card — title, summary, tags, time/servings/difficulty badges, source feed, and a link to the recipe on
recipes.cooklang.org. Reuse the existing.recipe-card/.metadata-pill/ badge component classes. GET /discover/:id— preview a single federation recipe rendered with the normal recipe view (ingredients, steps, metadata), with a "Save to my recipes" form.POST /discover/:id/save— fetches/api/recipes/:id/download, writes it underbase_pathat a user-supplied (sanitised) filename, redirects to the local recipe page. Reuse the path sanitisation and CSRF same-origin check already increate_recipe(src/server/ui.rs); refuse to overwrite an existing file and surface that as a form error.
Nav entry sits next to Shopping List / Pantry, hidden in static_mode (no writes, and outbound calls don't belong in a statically exported site).
Configuration
--federation-urlflag oncook server(andCOOK_FEDERATION_URLenv), defaulting tohttps://recipes.cooklang.org, so self-hosted federation instances work.--no-federation(or the URL set empty) hides the page entirely, for offline/air-gapped use.- Reasonable client timeout on federation calls; a slow or down federation must degrade to an error banner, never hang a request.
Details / edge cases
- All federation-supplied text is untrusted: escape it, and validate that the downloaded body parses as Cooklang before writing it to disk.
- Cap the response size accepted from
/download(the federation itself caps recipes at 1 MB). - Locale filter defaults to the UI language, with an "any language" option.
- New user-facing strings go through the existing Fluent setup — add keys to
locales/en-US/(newdiscover.ftl), leaving other locales to fall back.
Out of scope
- A
cook search --federationCLI command (worth a separate ticket). - Publishing local recipes to the federation as a feed.
- Adding federation recipes straight to the shopping list without saving.
Implementation notes
- Routes:
src/server/ui.rs(ui()router). - Templates: new
templates/discover.html+templates/discover_recipe.html, data structs insrc/server/templates.rs. - Nav:
templates/base.html, gated the same way as shopping list / pantry. - HTTP client:
reqwestis already in the dependency tree viacooklang-import.
Acceptance criteria
-
/discover?q=pastareturns federation results rendered in the CookCLI UI. - Field-scoped and boolean queries (
tags:italian AND total_time:[0 TO 30]) reach the API unmangled. - A result can be previewed and saved to the local collection, then opens as a normal local recipe.
- Federation unreachable → clear error banner, page still renders, no panic and no hung request.
- Page and nav entry are absent in
static_modeand when federation is disabled. -
cargo fmt,cargo clippy,cargo testclean.
- Lingua principale
- Rust
- Stelle
- 1.4k
- Fork
- 120
- Merge medio
- 1g 22h
- PR unite (30g)
- 128
Preparare l'ambiente
- Include un Dockerfile o un file Docker Compose
- Nessun modello di pull request
- Leggi la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di cooklang/cookcli
-
Editor save status and save errors are in English whatever the site's languageForse già presa @LeMyst l’ha presa oggi. Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
I maintainer di solito rispondono entro 1 giorno
-
Shopping list counts a recipe twice when three or more menus reference each other in a ringForse già presa @LeMyst l’ha presa oggi. Aperta
Difficoltà 4/5 3-5 giorni Idoneità per principianti 55/100
I maintainer di solito rispondono entro 1 giorno
-
feat(server): tag pages, so a recipe can belong to several collectionsForse già presa @LeMyst l’ha presa 2 giorni fa. Apertaarea: server feature request
Difficoltà 4/5 3-5 giorni Idoneità per principianti 35/100
I maintainer di solito rispondono entro 1 giorno
-
wontfix
Difficoltà 3/5 1-2 giorni Idoneità per principianti 55/100
cooklang/cookcli#784 · 4 commenti ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 5/5 Più di una settimana Idoneità per principianti 35/100
cooklang/cookcli#763 · 1 commento · 1 reazione ·
I maintainer di solito rispondono entro 1 giorno
Tutte le issue di cooklang/cookcli
Issue simili
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
BurntSushi/jiff#668 ·
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 68/100
router-for-me/EasyCLIProxyAPI#534 ·
I maintainer di solito rispondono entro 1 giorno
-
bug
Difficoltà 2/5 1-3 ore Idoneità per principianti 74/100
astral-sh/astral-codec#244 ·
I maintainer di solito rispondono entro 1 giorno
-
ready-for-agent
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
I maintainer di solito rispondono entro 1 giorno
-
bug dependencies kind:fix priority: P3 ready-for-agent
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
shep-pm/shep#1318 · 1 commento ·
I maintainer di solito rispondono entro 1 giorno