Enable editing of titles

This commit is contained in:
Maximilian Friedersdorff 2025-06-18 21:51:46 +01:00
parent e2c59d5f28
commit fd8e140897
2 changed files with 12 additions and 2 deletions

View file

@ -80,10 +80,17 @@ func delete(w http.ResponseWriter, r *http.Request) {
}
func save(w http.ResponseWriter, r *http.Request) {
title := r.PathValue("note")
oldTitle := r.PathValue("note")
title := r.FormValue("title")
body := r.FormValue("body")
note := &notes.Note{Title: title, Body: []byte(body)}
note.Save()
if oldTitle != title {
notes.DeleteNote(oldTitle)
}
http.Redirect(w, r, myurls.Reverse("view", urls.Repl{"note": title}), http.StatusFound)
}