aboutsummaryrefslogtreecommitdiffstats
path: root/internal/web/handlers_posts.go
diff options
context:
space:
mode:
authorgrm <grm@eyesin.space>2026-09-15 23:17:17 +0300
committergrm <grm@eyesin.space>2026-09-15 23:17:17 +0300
commit628dcb814ece6335667e2b719049728aa161d8c9 (patch)
tree8fa4654771bee0166286b32fc123beec892870bb /internal/web/handlers_posts.go
parent2c85ca1a46ddf4652f8fffc53d6bcfbe32b2b4ff (diff)
downloadblogspace-628dcb814ece6335667e2b719049728aa161d8c9.tar.gz
blogspace-628dcb814ece6335667e2b719049728aa161d8c9.tar.bz2
blogspace-628dcb814ece6335667e2b719049728aa161d8c9.zip
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 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Sd8UPWrvyYCLj97JexNw3A
Diffstat (limited to 'internal/web/handlers_posts.go')
-rw-r--r--internal/web/handlers_posts.go7
1 files changed, 3 insertions, 4 deletions
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