From 132e7c41d20a42db15baa58499f15645f87cb2ee Mon Sep 17 00:00:00 2001 From: Thayol Date: Sun, 13 Sep 2026 12:45:44 +0200 Subject: [PATCH] Redesign source link --- internal/server/pages.go | 2 ++ internal/server/server.go | 5 +---- internal/server/server_test.go | 38 ++++++++++++++++++---------------- web/templates/index.html | 9 ++++++++ web/templates/layout.html | 1 - 5 files changed, 32 insertions(+), 23 deletions(-) diff --git a/internal/server/pages.go b/internal/server/pages.go index b2503c5..b7e3289 100644 --- a/internal/server/pages.go +++ b/internal/server/pages.go @@ -53,6 +53,7 @@ type indexPage struct { // field wants is "never", what the list wants is "unlimited". ExpiryHint string AbsBase string + Source string // the repository this build came from, "" to say nothing AllowVanity bool MaxSizeBytes int64 // 0 when unlimited; the script checks against it Stale bool // a login whose token no longer exists @@ -83,6 +84,7 @@ func (s *Server) handleIndex(w http.ResponseWriter, r *http.Request) { DefaultExpiry: config.FormatLifetime(lim.DefaultExpiry), ExpiryHint: config.FormatDuration(lim.DefaultExpiry), AbsBase: s.absBase(r), + Source: s.cfg.SourceURL, AllowVanity: lim.AllowVanity, MaxSizeBytes: lim.MaxSize, Stale: stale, diff --git a/internal/server/server.go b/internal/server/server.go index 068e456..8aa228c 100644 --- a/internal/server/server.go +++ b/internal/server/server.go @@ -241,9 +241,6 @@ type page struct { // case the markup carries no link rather than one that 404s. Favicon string - // Source is where the footer links; empty means no footer. - Source string - // Wide widens the page for content that is a table rather than a form. // The reading measure that suits the upload page is far too narrow for a // listing, which otherwise ends up behind a horizontal scrollbar. @@ -253,7 +250,7 @@ type page struct { // page builds the common fields, resolving the session so the header can show // who is logged in and offer only the links they can use. func (s *Server) page(r *http.Request, title string, script bool) page { - p := page{Base: s.cfg.BasePath, Title: title, Script: script, Source: s.cfg.SourceURL} + p := page{Base: s.cfg.BasePath, Title: title, Script: script} if s.favicon != "" { p.Favicon = s.cfg.BasePath + "static/" + s.favicon } diff --git a/internal/server/server_test.go b/internal/server/server_test.go index 134676c..a69bd6b 100644 --- a/internal/server/server_test.go +++ b/internal/server/server_test.go @@ -1148,33 +1148,35 @@ func TestNoFaviconMeansNoLink(t *testing.T) { // --- the footer ------------------------------------------------------------ -// The footer names where the source lives, and an instance that would rather -// not say so can drop it. A fork gets to point at its own. +// The upload page says where the source is; no other page does, and an +// instance that would rather not say so drops it there too. func TestSourceLinkIsOptional(t *testing.T) { + body := func(h *harness, path string) string { + t.Helper() + resp := h.get(t, path, "") + raw, _ := io.ReadAll(resp.Body) + resp.Body.Close() + return string(raw) + } + shown := newHarness(t, nil) - resp := shown.get(t, "/", "") - page, _ := io.ReadAll(resp.Body) - resp.Body.Close() - if !strings.Contains(string(page), `