Repository navigation
feat(ui): meal plans laid out as a calendar - #596
Merged
Merged
Conversation
This was referenced Oct 1, 2026
A meal plan is a `.menu` whose frontmatter frames it in time:
plan:
start: 2026-10-07
days: 10
meals: [Breakfast, Lunch, Dinner]
What is eaten each day stays in dated sections (`== Wednesday
(2026-10-07) ==`), so the shopping list, the Today's menu banner,
`cook shopping-list` and other Cooklang apps read a plan like any menu.
- New Meal Plan (`/new?kind=plan`), beside New Menu: any first day,
1 to 62 days, meals and servings. The file gets a section a day with
an empty bullet under each meal, day and meal names in the page's
language. An error sends the form back with its choices.
- A menu with a `plan:` block shows one card a day, in weekday columns
from md up (Sunday first for en-US and ja-JP) and stacked on a phone.
Each planned meal has a slot even when empty; sections with no date,
or outside the plan, are listed under "Outside this plan". The page
script marks today and the days gone by against the reader's clock.
- The menu page's line rendering is one askama macro, shared by the
section cards and the day cards.
- `extract_date` / `is_meal_header` / `extract_meal_type` move to
`web::menus` so the static build can use them.
- chrono's `unstable-locales` names weekdays and months.
Part of cooklang#385: editing inside the planner and adding a range of days to
the shopping list are left for follow-ups.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
LeMyst
marked this pull request as ready for review
October 2, 2026 19:22
Collaborator
Author
|
What do you think about @dubadub ? |
LeMyst
force-pushed
the
feat/meal-planner
branch
from
October 2, 2026 19:27
27498cc to
1561386
Compare
Member
It looks truly amazing! The only thing I'm not convinced that we need to add this extra I made menus as first class citizens in cooklang-find and we can get list of all dates and map them to calendar. What do you think @LeMyst? |
Member
|
The resistance I have with that extra |
Drop the `plan:` frontmatter block: dated sections already say which days a menu covers, and every Cooklang app reads them, so the calendar needs nothing the spec does not have. - A menu with sections on two days or more shows as a calendar, from its first dated day to its last. A day with no section still gets a cell; a week with none is left out. - Every day offers the meals the plan's days name, in the order they first appear. - A date counts anywhere in a section name, as cooklang-find's `list_menus_for_date` matches it, so `= 2026-10-08 Dinner` is a day too; the text after the date names the meal of the section's first lines. - The new-plan form keeps its fields but writes the sections only, and asks for 2 to 62 days. Co-Authored-By: Claude Opus 5.5 <[email protected]>
With a plan whose first day has only `Dinner:` and a later one `Lunch:` then `Dinner:`, every day offered Dinner before Lunch: a meal no earlier day named went last. It now goes after the meal it follows on its day, or, as that day's first, before the next meal the day has. `meal_slots` takes plain meal names, so the plan's text can be read in the same order. Co-Authored-By: Claude Opus 5.5 <[email protected]>
The menu page drops sections with nothing in them, so a plan whose last days were bare headings (`== Friday (2026-10-09) ==`) ended at the last day with something planned. Dated sections are now kept while the calendar is laid out, and dropped as before when the menu is not a plan. Co-Authored-By: Claude Opus 5.5 <[email protected]>
4 tasks
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.
Part of #385 (step 1 of the proposal).
A meal plan is any
.menuwith sections on two days or more. Nothing else marks it: the dates already in its section names are what the shopping list, the Today's menu banner,cook shopping-listand other Cooklang apps read, so the spec does not change (an earlier version of this PR used aplan:frontmatter block; it was dropped after review, see dd68344):What changes
/new?kind=plan): name, first day (Today / This week / Next week shortcuts), number of days (2–62, 1 week / 2 weeks shortcuts), meals, servings, and a preview of the dates covered. The file gets a section a day with an empty bullet under each meal, ready for the editor. Day and meal names are written in the page's language, like the editor toolbar. An error (bad date, taken name…) sends the form back with every choice kept.mdup (Sunday first foren-USandja-JP, Monday otherwise), stacked on a phone. A day with no section still gets a card; a week with none is left out. Every day has a slot for each meal the plan's days name (Breakfast:), in the order they first appear, even when empty (—, "Nothing planned" for screen readers). Recipes are named without their folders in the cards, full path in the tooltip. Sections with no date are listed under Outside this plan. A small script marks today (aria-current="date") and greys past days using the reader's clock, so static sites and servers in another time zone agree with the reader.list_menus_for_datematches it (== Wednesday (2026-10-07) ==,= 2026-10-08 Dinner). Several sections may share a day; text after the date names the meal of the section's lines before its first meal header. A menu with a single dated day (an event menu) stays an ordinary menu.Implementation notes
src/web/plan.rs:section_date(the day and meal a section name gives),build_plan_view(sorts the builder'sMenuSections into days and meals with the menu API'sis_meal_headerrule, orNoneunder two dated days),plan_starter(what the form writes, from aPlanFramethe form fills).extract_date/is_meal_header/extract_meal_type/extract_timemove fromserver::handlers::menustoweb::menus, since the calendar is also built for static sites; the API handler imports them unchanged.templates/menu.html: the line rendering (duplicated for one-item and multi-item lines) is now one askama macro,menu_item, used by the section cards and the day cards;section_cardrenders a section.NewKind::Plan; the plan's fields are one#[serde(flatten)]struct shared by the form post and the page query, so an error redirect can bring them back.new_page_errortakes the query to go back with instead of the kind.unstable-localesfeature names weekdays and months (Mer. 7 oct.).docs/server.md: a "Meal plans" section.Not in this PR (steps 2 and 3 of the proposal): editing inside the calendar, a range of days to the shopping list, a menu as a day's meal.
Screenshots
Tests
web::plan): dates anywhere in a section name, the two-day threshold, a Wednesday start's blank cells (Monday- and Sunday-first), weeks without a section left out, sections merged by date and meal, meal slots and their order, undated sections, localised day headings, a new plan reading back with its days.tests/new_menu_test.rs): the created file, French names, every error keeping the form's choices, the calendar page (including a= YYYY-MM-DD Dinnersection), a menu with one dated day unchanged, the form and the listing button.tests/e2e/meal-plan.spec.ts): create through the form (shortcuts, preview), Sunday-first columns, today and past days, stacked on a phone, axe on the calendar and the form.cargo fmt,cargo clippy --all-targets(also--no-default-features),cargo testall clean. Full chromium Playwright run at dd68344: 250 passed, 5 skipped;recipe-scaling › should send the scale when adding to shopping listfailed once and passed on re-run (intermittent on main too).🤖 Generated with Claude Code