From 628dcb814ece6335667e2b719049728aa161d8c9 Mon Sep 17 00:00:00 2001 From: grm Date: Tue, 15 Sep 2026 23:17:17 +0300 Subject: Make the post form's tag input a box with a folded list of chips A checkbox per existing tag stops working once a blog has dozens of them. The form is now one comma-separated box, prefilled with the post's tags, and the blog's tags sit folded under it as chips; a small script toggles a clicked chip in the box, and without it the chips are a plain list to copy from. Co-Authored-By: Claude Opus 5 Claude-Session: https://claude.ai/code/session_01Sd8UPWrvyYCLj97JexNw3A --- internal/web/handlers_posts.go | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) (limited to 'internal/web/handlers_posts.go') diff --git a/internal/web/handlers_posts.go b/internal/web/handlers_posts.go index 16d9cf2..ad0a241 100644 --- a/internal/web/handlers_posts.go +++ b/internal/web/handlers_posts.go @@ -69,7 +69,7 @@ func (s *Server) handlePostForm(w http.ResponseWriter, r *http.Request) { } else if hp, err := blogStore(r).HomePage(r.Context()); err == nil { p.PageID = hp.ID } - s.render(w, r, "dashboard/post_form.html", map[string]any{"post": p, "pages": pages, "allTags": allTags, "tagged": tagSet(p.Tags), "newTags": ""}) + s.render(w, r, "dashboard/post_form.html", map[string]any{"post": p, "pages": pages, "allTags": allTags, "tagsText": tagsText(p.Tags)}) } func (s *Server) handlePostSave(w http.ResponseWriter, r *http.Request) { @@ -95,8 +95,7 @@ func (s *Server) handlePostSave(w http.ResponseWriter, r *http.Request) { p.BodyMD = strings.ReplaceAll(r.FormValue("body"), "\r\n", "\n") p.Published = r.FormValue("published") == "on" p.PageID, _ = strconv.ParseInt(r.FormValue("page_id"), 10, 64) - // The ticked existing tags and the comma-separated new ones are one list. - tags, tagsOK := parseTags(append(r.Form["tag"], strings.Split(r.FormValue("new_tags"), ",")...)) + tags, tagsOK := parseTags(strings.Split(r.FormValue("tags"), ",")) p.Tags = tags autoSlug := p.Slug == "" if autoSlug { @@ -104,7 +103,7 @@ func (s *Server) handlePostSave(w http.ResponseWriter, r *http.Request) { } fail := func(status int, msg string) { s.renderStatus(w, r, status, "dashboard/post_form.html", map[string]any{"post": p, "pages": pages, "error": msg, - "allTags": allTags, "tagged": tagSet(p.Tags), "newTags": r.FormValue("new_tags")}) + "allTags": allTags, "tagsText": r.FormValue("tags")}) } if at := strings.TrimSpace(r.FormValue("posted_at")); at != "" { // blank keeps the current date var ok bool -- cgit v1.2.3