From 5041f87e576df01061cdfe6f48d02f20123bf195 Mon Sep 17 00:00:00 2001 From: Mikhail Yenuchenko Date: Mon, 3 Aug 2026 22:04:33 +0300 Subject: [PATCH] panel: finish the monitoring rename below the URL layer The previous two commits renamed the routes and the page titles but left every identifier underneath still called sendlog/queue/logtail, so a grep for "deliveries" found the route and nothing that serves it. Renamed together, since they have to agree for a page to render at all: the six template files, their {{define}} blocks, the pageFiles and fragmentFiles keys, the .Active values the nav compares against, the HTMX target ids, and the six page handlers. Names that describe the data rather than the page keep their old form: the send_log table and its store methods, internal/logtail, and the sendLogData/readQueue/readLogTail helpers. Co-Authored-By: Claude Opus 5 --- internal/web/handlers_monitor.go | 49 ++++++++++--------- internal/web/templates.go | 14 +++--- .../{sendlog.html => deliveries.html} | 2 +- ...sendlog_rows.html => deliveries_rows.html} | 4 +- internal/web/templates/layout.html | 6 +-- .../templates/{queue.html => mail_queue.html} | 2 +- .../{queue_body.html => mail_queue_body.html} | 4 +- .../{logtail.html => system_log.html} | 2 +- ...logtail_body.html => system_log_body.html} | 4 +- internal/web/templates_test.go | 2 +- internal/web/web.go | 12 ++--- 11 files changed, 51 insertions(+), 50 deletions(-) rename internal/web/templates/{sendlog.html => deliveries.html} (95%) rename internal/web/templates/{sendlog_rows.html => deliveries_rows.html} (87%) rename internal/web/templates/{queue.html => mail_queue.html} (74%) rename internal/web/templates/{queue_body.html => mail_queue_body.html} (55%) rename internal/web/templates/{logtail.html => system_log.html} (75%) rename internal/web/templates/{logtail_body.html => system_log_body.html} (58%) diff --git a/internal/web/handlers_monitor.go b/internal/web/handlers_monitor.go index 65fe63a..3708a0d 100644 --- a/internal/web/handlers_monitor.go +++ b/internal/web/handlers_monitor.go @@ -19,11 +19,12 @@ const ( logTailLines = 200 ) -// handleSendLog renders the send-log monitoring page: server-side filters by -// domain/application and pagination (spec 7.3.3). The row table itself is the -// "sendlog_rows" fragment, shared verbatim with handleSendLogRows so the -// initial page and its HTMX-polled refreshes never diverge. -func (s *Server) handleSendLog(w http.ResponseWriter, r *http.Request) { +// handleDeliveries renders the Deliveries page over the send log: server-side +// filters by domain/application and pagination (spec 7.3.3). The row table +// itself is the "deliveries_rows" fragment, shared verbatim with +// handleDeliveriesRows so the initial page and its HTMX-polled refreshes never +// diverge. +func (s *Server) handleDeliveries(w http.ResponseWriter, r *http.Request) { data, err := s.sendLogData(r) if err != nil { logf("panel: send log: %v", err) @@ -32,20 +33,20 @@ func (s *Server) handleSendLog(w http.ResponseWriter, r *http.Request) { } data["Title"] = "SelfPost — deliveries" data["User"] = currentUser(r) - data["Active"] = "sendlog" - s.render(w, http.StatusOK, "sendlog", data) + data["Active"] = "deliveries" + s.render(w, http.StatusOK, "deliveries", data) } -// handleSendLogRows serves the HTMX polling fragment for the send-log table +// handleDeliveriesRows serves the HTMX polling fragment for the delivery table // (spec 7.1: fragment endpoints return HTML, not JSON). -func (s *Server) handleSendLogRows(w http.ResponseWriter, r *http.Request) { +func (s *Server) handleDeliveriesRows(w http.ResponseWriter, r *http.Request) { data, err := s.sendLogData(r) if err != nil { logf("panel: send log rows: %v", err) http.Error(w, "internal error", http.StatusInternalServerError) return } - s.renderFragment(w, http.StatusOK, "sendlog_rows", data) + s.renderFragment(w, http.StatusOK, "deliveries_rows", data) } // sendLogData reads the domain/app filters and page number off the query @@ -109,22 +110,22 @@ func parsePage(v string) int { return n } -// handleQueue renders the mail-queue monitoring page (spec 7.2.11). -func (s *Server) handleQueue(w http.ResponseWriter, r *http.Request) { +// handleMailQueue renders the Mail queue page (spec 7.2.11). +func (s *Server) handleMailQueue(w http.ResponseWriter, r *http.Request) { out, errText := readQueue() - s.render(w, http.StatusOK, "queue", map[string]any{ + s.render(w, http.StatusOK, "mail_queue", map[string]any{ "Title": "SelfPost — mail queue", "User": currentUser(r), - "Active": "queue", + "Active": "mail_queue", "Output": out, "Error": errText, }) } -// handleQueueBody serves the HTMX polling fragment for the queue view. -func (s *Server) handleQueueBody(w http.ResponseWriter, r *http.Request) { +// handleMailQueueBody serves the HTMX polling fragment for the queue view. +func (s *Server) handleMailQueueBody(w http.ResponseWriter, r *http.Request) { out, errText := readQueue() - s.renderFragment(w, http.StatusOK, "queue_body", map[string]any{ + s.renderFragment(w, http.StatusOK, "mail_queue_body", map[string]any{ "Output": out, "Error": errText, }) @@ -142,22 +143,22 @@ func readQueue() (string, string) { return out, "" } -// handleLogTail renders the mail.log monitoring page (spec 7.2.13). -func (s *Server) handleLogTail(w http.ResponseWriter, r *http.Request) { +// handleSystemLog renders the System log page over mail.log (spec 7.2.13). +func (s *Server) handleSystemLog(w http.ResponseWriter, r *http.Request) { lines, errText := s.readLogTail() - s.render(w, http.StatusOK, "logtail", map[string]any{ + s.render(w, http.StatusOK, "system_log", map[string]any{ "Title": "SelfPost — system log", "User": currentUser(r), - "Active": "logtail", + "Active": "system_log", "Lines": lines, "Error": errText, }) } -// handleLogTailBody serves the HTMX polling fragment for the log-tail view. -func (s *Server) handleLogTailBody(w http.ResponseWriter, r *http.Request) { +// handleSystemLogBody serves the HTMX polling fragment for the log-tail view. +func (s *Server) handleSystemLogBody(w http.ResponseWriter, r *http.Request) { lines, errText := s.readLogTail() - s.renderFragment(w, http.StatusOK, "logtail_body", map[string]any{ + s.renderFragment(w, http.StatusOK, "system_log_body", map[string]any{ "Lines": lines, "Error": errText, }) diff --git a/internal/web/templates.go b/internal/web/templates.go index 90a9b8a..b3f43d5 100644 --- a/internal/web/templates.go +++ b/internal/web/templates.go @@ -30,19 +30,19 @@ var pageFiles = map[string][]string{ "backup": {"templates/backup.html"}, "domain_detail": {"templates/domain_detail.html"}, "domain_delete": {"templates/domain_delete.html"}, - "sendlog": {"templates/sendlog.html", "templates/sendlog_rows.html"}, - "queue": {"templates/queue.html", "templates/queue_body.html"}, - "logtail": {"templates/logtail.html", "templates/logtail_body.html"}, + "deliveries": {"templates/deliveries.html", "templates/deliveries_rows.html"}, + "mail_queue": {"templates/mail_queue.html", "templates/mail_queue_body.html"}, + "system_log": {"templates/system_log.html", "templates/system_log_body.html"}, "status": {"templates/status.html", "templates/status_body.html"}, } // fragmentFiles maps a fragment name (also its {{define}} block name) to its // template file, for standalone rendering by the HTMX polling endpoints. var fragmentFiles = map[string]string{ - "sendlog_rows": "templates/sendlog_rows.html", - "queue_body": "templates/queue_body.html", - "logtail_body": "templates/logtail_body.html", - "status_body": "templates/status_body.html", + "deliveries_rows": "templates/deliveries_rows.html", + "mail_queue_body": "templates/mail_queue_body.html", + "system_log_body": "templates/system_log_body.html", + "status_body": "templates/status_body.html", } func loadTemplates() (*templates, error) { diff --git a/internal/web/templates/sendlog.html b/internal/web/templates/deliveries.html similarity index 95% rename from internal/web/templates/sendlog.html rename to internal/web/templates/deliveries.html index d85a162..a4b341b 100644 --- a/internal/web/templates/sendlog.html +++ b/internal/web/templates/deliveries.html @@ -19,6 +19,6 @@
- {{template "sendlog_rows" .}} + {{template "deliveries_rows" .}}
{{end}} diff --git a/internal/web/templates/sendlog_rows.html b/internal/web/templates/deliveries_rows.html similarity index 87% rename from internal/web/templates/sendlog_rows.html rename to internal/web/templates/deliveries_rows.html index acef430..a7f5455 100644 --- a/internal/web/templates/sendlog_rows.html +++ b/internal/web/templates/deliveries_rows.html @@ -1,5 +1,5 @@ -{{define "sendlog_rows"}} -
{{if .Rows}} diff --git a/internal/web/templates/layout.html b/internal/web/templates/layout.html index 2e6d6d5..808a40f 100644 --- a/internal/web/templates/layout.html +++ b/internal/web/templates/layout.html @@ -38,9 +38,9 @@
diff --git a/internal/web/templates/queue.html b/internal/web/templates/mail_queue.html similarity index 74% rename from internal/web/templates/queue.html rename to internal/web/templates/mail_queue.html index 5fd1c8a..39ba7cf 100644 --- a/internal/web/templates/queue.html +++ b/internal/web/templates/mail_queue.html @@ -3,6 +3,6 @@

Pending messages

- {{template "queue_body" .}} + {{template "mail_queue_body" .}}
{{end}} diff --git a/internal/web/templates/queue_body.html b/internal/web/templates/mail_queue_body.html similarity index 55% rename from internal/web/templates/queue_body.html rename to internal/web/templates/mail_queue_body.html index 29ece73..b8ffd17 100644 --- a/internal/web/templates/queue_body.html +++ b/internal/web/templates/mail_queue_body.html @@ -1,5 +1,5 @@ -{{define "queue_body"}} -
+{{define "mail_queue_body"}} +
{{if .Error}}

{{.Error}}

{{end}} {{if .Output}}{{.Output}}{{else}}Queue is empty.{{end}}
diff --git a/internal/web/templates/logtail.html b/internal/web/templates/system_log.html similarity index 75% rename from internal/web/templates/logtail.html rename to internal/web/templates/system_log.html index aa4a26b..fec9be9 100644 --- a/internal/web/templates/logtail.html +++ b/internal/web/templates/system_log.html @@ -3,6 +3,6 @@

Recent log entries

- {{template "logtail_body" .}} + {{template "system_log_body" .}}
{{end}} diff --git a/internal/web/templates/logtail_body.html b/internal/web/templates/system_log_body.html similarity index 58% rename from internal/web/templates/logtail_body.html rename to internal/web/templates/system_log_body.html index 3a4fc10..b97c1fe 100644 --- a/internal/web/templates/logtail_body.html +++ b/internal/web/templates/system_log_body.html @@ -1,5 +1,5 @@ -{{define "logtail_body"}} -
+{{define "system_log_body"}} +
{{if .Error}}

{{.Error}}

{{end}} {{if .Lines}}{{range .Lines}}{{.}} {{end}}{{else}}No log lines yet.{{end}} diff --git a/internal/web/templates_test.go b/internal/web/templates_test.go index 9f7d7d5..7db70c0 100644 --- a/internal/web/templates_test.go +++ b/internal/web/templates_test.go @@ -99,7 +99,7 @@ func TestNavMarksActivePage(t *testing.T) { var buf bytes.Buffer err = tmpl.pages["dashboard"].ExecuteTemplate(&buf, "nav", map[string]any{ "User": "admin", - "Active": "queue", + "Active": "mail_queue", }) if err != nil { t.Fatalf("execute nav: %v", err) diff --git a/internal/web/web.go b/internal/web/web.go index 8741720..ae0ae63 100644 --- a/internal/web/web.go +++ b/internal/web/web.go @@ -185,12 +185,12 @@ func (s *Server) Handler() http.Handler { // Monitoring screens (spec 7.2.11-13): each page and its HTMX polling // fragment (spec 7.1 — the /rows and /body endpoints return HTML, not JSON). - authed.HandleFunc("GET /deliveries", s.handleSendLog) - authed.HandleFunc("GET /deliveries/rows", s.handleSendLogRows) - authed.HandleFunc("GET /mail-queue", s.handleQueue) - authed.HandleFunc("GET /mail-queue/body", s.handleQueueBody) - authed.HandleFunc("GET /system-log", s.handleLogTail) - authed.HandleFunc("GET /system-log/body", s.handleLogTailBody) + authed.HandleFunc("GET /deliveries", s.handleDeliveries) + authed.HandleFunc("GET /deliveries/rows", s.handleDeliveriesRows) + authed.HandleFunc("GET /mail-queue", s.handleMailQueue) + authed.HandleFunc("GET /mail-queue/body", s.handleMailQueueBody) + authed.HandleFunc("GET /system-log", s.handleSystemLog) + authed.HandleFunc("GET /system-log/body", s.handleSystemLogBody) mux.Handle("/", s.requireAuth(authed))