aboutsummaryrefslogtreecommitdiffstats
path: root/internal/web/handlers_dashboard.go
diff options
context:
space:
mode:
authorgramanas <grm@eyesin.space>2026-09-12 11:24:17 +0300
committergramanas <grm@eyesin.space>2026-09-12 11:24:17 +0300
commit3eb04b1a2bdf9e53231fe862cfd76327371a9741 (patch)
treeb38b2d82a47233fd8e0bb18c59e4a8f3dd2412d7 /internal/web/handlers_dashboard.go
downloadblogspace-3eb04b1a2bdf9e53231fe862cfd76327371a9741.tar.gz
blogspace-3eb04b1a2bdf9e53231fe862cfd76327371a9741.tar.bz2
blogspace-3eb04b1a2bdf9e53231fe862cfd76327371a9741.zip
Initial multi-tenant blog host
Go + Postgres application serving a management dashboard on the base domain and one public blog per subdomain. Markdown posts organised in pages, form-based theme customisation, image uploads stored in Postgres, JWT cookie sessions with CSRF, superadmin user management, RSS feeds. Docker/compose deployment and a Makefile-driven dev environment with seed data. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Sd8UPWrvyYCLj97JexNw3A
Diffstat (limited to 'internal/web/handlers_dashboard.go')
-rw-r--r--internal/web/handlers_dashboard.go43
1 files changed, 43 insertions, 0 deletions
diff --git a/internal/web/handlers_dashboard.go b/internal/web/handlers_dashboard.go
new file mode 100644
index 0000000..f210891
--- /dev/null
+++ b/internal/web/handlers_dashboard.go
@@ -0,0 +1,43 @@
+package web
+
+import (
+ "net/http"
+ "strings"
+)
+
+func (s *Server) handleBlogOverview(w http.ResponseWriter, r *http.Request) {
+ blog := currentBlog(r)
+ pages, err := s.st.ListPages(r.Context(), blog.ID)
+ if err != nil {
+ s.serverError(w, err)
+ return
+ }
+ posts, err := s.st.ListPosts(r.Context(), blog.ID, 0)
+ if err != nil {
+ s.serverError(w, err)
+ return
+ }
+ if len(posts) > 5 {
+ posts = posts[:5]
+ }
+ s.render(w, r, "dashboard/overview.html", map[string]any{"pages": pages, "posts": posts})
+}
+
+func (s *Server) handleSettingsForm(w http.ResponseWriter, r *http.Request) {
+ s.render(w, r, "dashboard/settings.html", nil)
+}
+
+func (s *Server) handleSettings(w http.ResponseWriter, r *http.Request) {
+ blog := currentBlog(r)
+ title := strings.TrimSpace(r.FormValue("title"))
+ tagline := strings.TrimSpace(r.FormValue("tagline"))
+ if title == "" || len(title) > 120 || len(tagline) > 300 {
+ s.renderStatus(w, r, http.StatusBadRequest, "dashboard/settings.html", map[string]any{"error": "Title is required (max 120 chars); tagline max 300."})
+ return
+ }
+ if err := s.st.UpdateBlogSettings(r.Context(), blog.ID, title, tagline); err != nil {
+ s.serverError(w, err)
+ return
+ }
+ redirectOK(w, r, "/b/"+blog.Subdomain+"/settings", "Saved. Refresh your blog to see it.")
+}