Skip to content

feat(ui): random recipe button scoped to the current folder #544

Closed

Description

@LeMyst

Summary

Add a small "Give me a random recipe" action to the web UI's recipe listing that opens a randomly chosen recipe from the folder currently being browsed, including its subfolders.

Motivation

When I don't know what to cook, a random pick is handy — but a pick across the whole collection is not useful: I don't want a random dessert when I'm looking for a main course. Recipes are usually already organised by folder (Mains/, Desserts/, Soups/…), so the folder I'm currently in is the natural way to narrow the pick.

Proposed behaviour

  • On / the pick comes from the whole recipe collection; on /directory/Mains it comes only from Mains/ and everything under it (e.g. Mains/Pasta/…).
  • Clicking it goes to /recipe/<picked path>.
  • If the current folder (and its subfolders) contains no recipes, the button is hidden or disabled.
  • Menus (.menu) are left out; only .cook recipes are picked.

UI

This is a minor, "nice to have" feature, so it shouldn't compete with the main actions: an icon-only button (.icon-btn, e.g. a dice/shuffle icon) placed next to the "New recipe" button in the listing header (templates/recipes.html), with a translated aria-label / title ("Random recipe") for accessibility.

Implementation notes

  • Server: a route such as GET /random / GET /random/{*path} that validates the path with is_safe_relative_path, walks the tree with cooklang_find::build_tree (already used by build_recipes_template in src/web/builders.rs), collects recipes recursively, picks one and redirects (303) to its /recipe/… URL. Keeping it server-side means no recipe list has to be sent to the page.
  • Static site mode (static_mode): there is no server to redirect, so either hide the button or embed the list of recipe paths under the current folder and pick one client-side.
  • i18n: add the label key to every locale.

Out of scope (possible follow-ups)

  • Filtering by tag / metadata (course, cuisine…) instead of folder.
  • A cook recipe --random style CLI equivalent.

Activity

  1. added a commit that references this issue on Sep 27, 2026
    73b095b
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions