From 9caaf92fb7663c8361b584e2833a88c7ded45bd9 Mon Sep 17 00:00:00 2001 From: Alexey Dubovskoy Date: Fri, 15 May 2026 16:17:04 +0100 Subject: [PATCH] fix: default new recipe path to current folder (#332) Clicking "+ New Recipe" while browsing a directory now pre-populates the filename input with that directory path so users can immediately type the recipe name instead of retyping the folder. --- src/server/templates.rs | 1 + src/server/ui.rs | 10 ++++++++++ templates/recipes.html | 2 +- 3 files changed, 12 insertions(+), 1 deletion(-) diff --git a/src/server/templates.rs b/src/server/templates.rs index e4e7aad..c7c590d 100644 --- a/src/server/templates.rs +++ b/src/server/templates.rs @@ -59,6 +59,7 @@ pub struct RecipesTemplate { pub breadcrumbs: Vec, pub items: Vec, pub todays_menu: Option, + pub new_recipe_url: String, pub tr: Tr, pub prefix: String, } diff --git a/src/server/ui.rs b/src/server/ui.rs index 9bb7d59..afa6b1a 100644 --- a/src/server/ui.rs +++ b/src/server/ui.rs @@ -167,12 +167,22 @@ async fn recipes_handler( crate::server::i18n::LOCALES.lookup(&lang, "recipes-title") }; + let new_recipe_url = match &path { + Some(p) => format!( + "{}/new?filename={}%2F", + state.url_prefix, + urlencoding::encode(p) + ), + None => format!("{}/new", state.url_prefix), + }; + let template = RecipesTemplate { active: "recipes".to_string(), current_name, breadcrumbs, items, todays_menu, + new_recipe_url, tr: Tr::new(lang), prefix: state.url_prefix.clone(), }; diff --git a/templates/recipes.html b/templates/recipes.html index 4f4ea59..457e199 100644 --- a/templates/recipes.html +++ b/templates/recipes.html @@ -22,7 +22,7 @@

{{ current_name }}

- +