Skip to content

Rename a recipe or menu from the web editor #622

Closed

Description

@LeMyst

The web editor can create, save and delete a recipe or menu, but not rename one. Today the only way is to create a new file, paste the text, and delete the old one — which loses the title and step pictures (Recipe.jpg, Recipe.2.jpg, Recipe.1.2.jpg) and leaves every @./Old Name{} reference in other recipes and menus pointing at a file that no longer exists.

Proposal

A Rename button in the editor, next to Picture and Delete, opening a small dialog with the current name. Behind it, POST /api/recipe_rename/{*path} with { "name": "New name" }:

  • the file stays in its folder (a name, not a path);
  • its pictures are renamed with it;
  • references to it in the collection's .cook and .menu files are rewritten to the new name.

What it must never do

Renaming touches several files at once, so it needs to be stricter than the other write endpoints:

  • never overwrite anything — a name that is taken, or a picture that would land on an existing file, is refused (409), with no race between the check and the move;
  • never touch anything but .cook / .menu files and the recipe's own pictures (same resolution as the save/delete endpoints, see Recipe API reads, overwrites and deletes any file under the recipe directory #545), never a hidden file, never through a symbolic link or outside the recipe directory;
  • never change what another reference means: renaming Foo.cook to Week when Week.menu exists would make every @./Week{} reach the recipe instead of the menu (.cook is looked up first);
  • only rewrite a reference that names the file exactly, keeping every other byte of the file; report the ones it cannot rewrite exactly instead of guessing;
  • not lose an edit to the editor's autosave, which writes the old path a second after each keystroke and would recreate the old file;
  • leave .shopping-list alone (its format is shared with the apps), but say when it still names the old path.

Activity

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