oficina / meet Public

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

Plain git — no account needed to clone.

Download

Download this file

1package calls
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 (a *app) 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, not no-referrer: the page shows the account menu, and
32 // a chained sign-out from it is admitted by id.* on the Referer's
33 // origin (spec §9.5). The credit links carry their own no-referrer.
34 w.Header().Set("Referrer-Policy", "strict-origin")
35 render(w, "credits", a.page(r, titled("Open source"), map[string]any{"Data": credits.PageData{Title: "Open source", MissingNoticeLabel: "No notice file is included in this release.", Components: embeddedCredits.Components}}))
36}
37
38func serveCreditsCSS(w http.ResponseWriter, r *http.Request) {
39 w.Header().Set("Content-Type", "text/css; charset=utf-8")
40 w.Header().Set("Cache-Control", "no-cache")
41 w.Write(credits.CSS())
42}
43