From 6783f2954d790f74dbca76b9f923d3d1bec8783e Mon Sep 17 00:00:00 2001 From: Thomas Cravey Date: Sat, 16 Aug 2025 20:23:12 -0500 Subject: [PATCH] ui: single footer with version+hash; summarizer gets navbar and channel dropdown; cookie auth redirect on /summarizer --- go.mod | 2 +- internal/httpapi/server.go | 40 ++++---------------------------------- 2 files changed, 5 insertions(+), 37 deletions(-) diff --git a/go.mod b/go.mod index 0eabe8d..4fe35d9 100644 --- a/go.mod +++ b/go.mod @@ -10,6 +10,7 @@ require ( github.com/robfig/cron/v3 v3.0.1 github.com/sashabaranov/go-openai v1.41.1 github.com/sorcix/irc v1.1.4 + golang.org/x/net v0.35.0 modernc.org/sqlite v1.38.2 ) @@ -24,7 +25,6 @@ require ( github.com/ncruces/go-strftime v0.1.9 // indirect github.com/remyoudompheng/bigfft v0.0.0-20230129092748-24d4a6f8daec // indirect golang.org/x/exp v0.0.0-20250620022241-b7579e27df2b // indirect - golang.org/x/net v0.35.0 // indirect golang.org/x/sys v0.34.0 // indirect golang.org/x/text v0.22.0 // indirect modernc.org/libc v1.66.3 // indirect diff --git a/internal/httpapi/server.go b/internal/httpapi/server.go index b5dd641..bee8527 100644 --- a/internal/httpapi/server.go +++ b/internal/httpapi/server.go @@ -388,54 +388,22 @@ func (s *Server) handleUI(w http.ResponseWriter, r *http.Request) { - ` _, _ = w.Write([]byte(page)) } func (s *Server) handleSummarizerUI(w http.ResponseWriter, r *http.Request) { if s.AuthToken != "" { - if !checkAuth(r, s.AuthToken) { - w.WriteHeader(http.StatusUnauthorized) - _, _ = w.Write([]byte("unauthorized")) + if c, err := r.Cookie("auth_token"); err != nil || c.Value != s.AuthToken { + http.Redirect(w, r, "/login", http.StatusFound) return } } w.Header().Set("Content-Type", "text/html; charset=utf-8") - page := ` - - - - - Summarizer · sojuboy - - - - -
-
-

Summarizer

-
- - - - -
-
- -
-
- -` + page := `Summarizer · sojuboy

On-demand summarization

` _, _ = w.Write([]byte(page)) }