oficina / calendar Public

Clone
git clone https://amadan.net/oficina/calendar

Plain git — no account needed to clone.

Download

Download this file

1package calendar
2
3import (
4 _ "embed"
5 "encoding/json"
6 "net/http"
7
8 "amadan.net/oficina/estilo.git/credits"
9)
10
11//go:embed credits/notices.json
12var creditNotices []byte
13
14type creditInventory struct {
15 Components []credits.Component `json:"components"`
16 MissingNotices []string `json:"missing_notices"`
17}
18
19var embeddedCredits = func() creditInventory {
20 var inventory creditInventory
21 if err := json.Unmarshal(creditNotices, &inventory); err != nil {
22 panic(err)
23 }
24 return inventory
25}()
26
27func (h *handlers) credits(w http.ResponseWriter, r *http.Request) {
28
29 w.Header().Set("Content-Type", "text/html; charset=utf-8")
30 w.Header().Set("Cache-Control", "no-store")
31 // strict-origin (spec §9.5): this page shows the account menu, and Home's
32 // sign-out chain needs an origin; no path or query is ever sent.
33 w.Header().Set("Referrer-Policy", "strict-origin")
34 render(w, "credits", h.page(r, "Open source", credits.PageData{Title: "Open source", MissingNoticeLabel: "No notice file is included in this release.", Components: embeddedCredits.Components}))
35}
36
37func serveCreditsCSS(w http.ResponseWriter, r *http.Request) {
38 w.Header().Set("Content-Type", "text/css; charset=utf-8")
39 w.Header().Set("Cache-Control", "no-cache")
40 w.Write(credits.CSS())
41}
42