Adopt shared credits accessibility and cache fixes
5 files changed,
+19
−12
Makefile+1 −0go.mod+3 −1go.sum+2 −4internal/sheets/credits.go+12 −6internal/sheets/credits_test.go+1 −1
CI passed — run details
diff --git a/Makefile b/Makefile| index 7d21b62..2137fe3 100644 |
| --- a/Makefile |
| +++ b/Makefile |
| @@ -1,3 +1,4 @@ |
| +export GOTOOLCHAIN := go1.26.5 |
| comma := , |
| export GOPRIVATE := $(if $(GOPRIVATE),$(GOPRIVATE)$(comma))amadan.net/oficina/estilo.git |
diff --git a/go.mod b/go.mod| index f53b4e0..3d09e85 100644 |
| --- a/go.mod |
| +++ b/go.mod |
| @@ -2,8 +2,10 @@ module amadan.net/oficina/sheets |
| go 1.25.0 |
| +toolchain go1.26.5 |
| + |
| require ( |
| - amadan.net/oficina/estilo.git v0.0.0-20260911162556-f5fa1128b794 |
| + amadan.net/oficina/estilo.git v0.0.0-20260911182719-0bcb9287988d |
| amadan.net/oficina/home/connect v0.0.0-20260910000424-5b8d8410775f |
| amadan.net/oficina/home/handoff v0.0.0-20260908102137-481d2d57f489 |
| amadan.net/rastrillo/rastrillo v0.26.1-0.20260908075707-29e4491631bd |
diff --git a/go.sum b/go.sum| index 8ac5489..e7b6b9a 100644 |
| --- a/go.sum |
| +++ b/go.sum |
| @@ -1,7 +1,5 @@ |
| -amadan.net/oficina/estilo.git v0.0.0-20260909234655-dec3908b237c h1:LgE7WLm6zMG/qZScoAHb4X2gguzorctB4XGjPYavXts= |
| -amadan.net/oficina/estilo.git v0.0.0-20260909234655-dec3908b237c/go.mod h1:0R45/vCUAT+kpS7S6K/ZxBdE8f7YxFN4HT3HyDJ3nPY= |
| -amadan.net/oficina/estilo.git v0.0.0-20260911162556-f5fa1128b794 h1:2oBeIneg/f+m3/n8qLsQGlpEhdnAfW3kOI80yRv60pw= |
| -amadan.net/oficina/estilo.git v0.0.0-20260911162556-f5fa1128b794/go.mod h1:0R45/vCUAT+kpS7S6K/ZxBdE8f7YxFN4HT3HyDJ3nPY= |
| +amadan.net/oficina/estilo.git v0.0.0-20260911182719-0bcb9287988d h1:3HsB96tGs+P0tGf2VzqpqA8yqYBhJ+apBh2txAoz9qI= |
| +amadan.net/oficina/estilo.git v0.0.0-20260911182719-0bcb9287988d/go.mod h1:0R45/vCUAT+kpS7S6K/ZxBdE8f7YxFN4HT3HyDJ3nPY= |
| amadan.net/oficina/home/connect v0.0.0-20260910000424-5b8d8410775f h1:lkw3tjzHfZxe74pNfo+tGDz4mkZLg+D6R+FTkmsym6M= |
| amadan.net/oficina/home/connect v0.0.0-20260910000424-5b8d8410775f/go.mod h1:YroavXe43Wietec+po8mtSk4a9Bir2h31Q3iAf4MWxI= |
| amadan.net/oficina/home/handoff v0.0.0-20260908102137-481d2d57f489 h1:RPKtyry/71i06o8L+gjAaUyexbmG56kO1YPs601URAM= |
diff --git a/internal/sheets/credits.go b/internal/sheets/credits.go| index 668401c..9105427 100644 |
| --- a/internal/sheets/credits.go |
| +++ b/internal/sheets/credits.go |
| @@ -17,12 +17,16 @@ type creditInventory struct { |
| MissingNotices []string `json:"missing_notices"` |
| } |
| -func (a *App) credits(w http.ResponseWriter, r *http.Request) { |
| +var embeddedCredits = func() creditInventory { |
| var inventory creditInventory |
| if err := json.Unmarshal(creditNotices, &inventory); err != nil { |
| - http.Error(w, "Something went wrong.", http.StatusInternalServerError) |
| - return |
| + panic(err) |
| } |
| + return inventory |
| +}() |
| + |
| +func (a *App) credits(w http.ResponseWriter, r *http.Request) { |
| + |
| w.Header().Set("Content-Type", "text/html; charset=utf-8") |
| w.Header().Set("Cache-Control", "no-store") |
| w.Header().Set("Referrer-Policy", "no-referrer") |
| @@ -30,12 +34,14 @@ func (a *App) credits(w http.ResponseWriter, r *http.Request) { |
| http.Error(w, "Something went wrong.", http.StatusInternalServerError) |
| return |
| } |
| - inventory.Components = append(inventory.Components, gridCredits...) |
| - sort.Slice(inventory.Components, func(i, j int) bool { return inventory.Components[i].Name < inventory.Components[j].Name }) |
| - a.render(w, r, "credits", "Open source", http.StatusOK, credits.PageData{Title: "Open source", Components: inventory.Components}) |
| + components := append([]credits.Component(nil), embeddedCredits.Components...) |
| + components = append(components, gridCredits...) |
| + sort.Slice(components, func(i, j int) bool { return components[i].Name < components[j].Name }) |
| + a.render(w, r, "credits", "Open source", http.StatusOK, credits.PageData{Title: "Open source", MissingNoticeLabel: "No notice file is included in this release.", Components: components}) |
| } |
| func serveCreditsCSS(w http.ResponseWriter, r *http.Request) { |
| w.Header().Set("Content-Type", "text/css; charset=utf-8") |
| + w.Header().Set("Cache-Control", "no-cache") |
| w.Write(credits.CSS()) |
| } |
diff --git a/internal/sheets/credits_test.go b/internal/sheets/credits_test.go| index 9c579d1..59693fe 100644 |
| --- a/internal/sheets/credits_test.go |
| +++ b/internal/sheets/credits_test.go |
| @@ -21,7 +21,7 @@ func TestCreditsArePublicAndContainDependencyNotices(t *testing.T) { |
| if response.Header().Get("Cache-Control") != "no-store" || response.Header().Get("Referrer-Policy") != "no-referrer" { |
| t.Fatal("credits shell may retain account context") |
| } |
| - for _, wanted := range []string{"estilo-credits", "Open source", "Lucide and Feather", "gorm.io/gorm", "gormlite/LICENSE", "jspreadsheet-ce", "5.0.2", "jsuites", "5.13.5", "/static/credits.css"} { |
| + for _, wanted := range []string{"No notice file is included in this release.", "estilo-credits", "Open source", "Lucide and Feather", "gorm.io/gorm", "gormlite/LICENSE", "jspreadsheet-ce", "5.0.2", "jsuites", "5.13.5", "/static/credits.css"} { |
| if !strings.Contains(response.Body.String(), wanted) { |
| t.Fatal("missing credit", wanted) |
| } |