From ae1a31f226de5701683231afaabf0f66503ca17d Mon Sep 17 00:00:00 2001 From: xengineering Date: Mon, 8 Jan 2024 19:36:01 +0100 Subject: Implement recipe editing --- view/common.go | 18 ++++++++++++++++++ view/html/recipe-edit.html | 40 ++++++++++++++++++++++++++++++++++++++++ 2 files changed, 58 insertions(+) create mode 100644 view/html/recipe-edit.html (limited to 'view') diff --git a/view/common.go b/view/common.go index c371fa0..b4df532 100644 --- a/view/common.go +++ b/view/common.go @@ -62,3 +62,21 @@ func HandlerHTML(prototype model.ReadableData) http.HandlerFunc { } } } + +func RecipeEditHandler(w http.ResponseWriter, r *http.Request) { + var recipe model.Recipe + var err error + + vars := mux.Vars(r) + recipe.Id = vars[`id`] + + err = recipe.FromDB() + if err != nil { + http.Error(w, err.Error(), http.StatusInternalServerError) + } + + err = html.ExecuteTemplate(w, `recipe-edit`, recipe) + if err != nil { + http.Error(w, err.Error(), http.StatusInternalServerError) + } +} diff --git a/view/html/recipe-edit.html b/view/html/recipe-edit.html new file mode 100644 index 0000000..b4d6da5 --- /dev/null +++ b/view/html/recipe-edit.html @@ -0,0 +1,40 @@ +{{define "recipe-edit"}} + + {{ template "head" }} +
+ +

Recipe editor

+
+ +
+
+

+ + +

+ +

+ + +

+ +

+ + +

+ +

+ + +

+ + + +
+
+ {{ template "footer" }} + + +{{end}} -- cgit v1.2.3-70-g09d2