| 1 | package calendar |
| 2 | |
| 3 | import ( |
| 4 | _ "embed" |
| 5 | "encoding/json" |
| 6 | "net/http" |
| 7 | |
| 8 | "amadan.net/oficina/estilo.git/credits" |
| 9 | ) |
| 10 | |
| 11 | //go:embed credits/notices.json |
| 12 | var creditNotices []byte |
| 13 | |
| 14 | type creditInventory struct { |
| 15 | Components []credits.Component `json:"components"` |
| 16 | MissingNotices []string `json:"missing_notices"` |
| 17 | } |
| 18 | |
| 19 | var 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 | |
| 27 | func (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 | |
| 37 | func 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 | |