oficina / home Public

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

Plain git — no account needed to clone.

Download

Download this file

1package home
2
3import (
4 _ "embed"
5 "encoding/json"
6 "net/http"
7
8 "amadan.net/oficina/estilo.git/credits"
9 "github.com/go-chi/chi/v5"
10)
11
12//go:embed credits/notices.json
13var creditNotices []byte
14
15type creditInventory struct {
16 Components []credits.Component `json:"components"`
17 MissingNotices []string `json:"missing_notices"`
18}
19
20var embeddedCredits = func() creditInventory {
21 var inventory creditInventory
22 if err := json.Unmarshal(creditNotices, &inventory); err != nil {
23 panic(err)
24 }
25 return inventory
26}()
27
28func (a *App) mountCredits(r chi.Router) {
29 r.Get("/help/open-source", func(w http.ResponseWriter, r *http.Request) {
30
31 a.render(w, r, http.StatusOK, "credits.html", credits.PageData{Title: "Open source", MissingNoticeLabel: "No notice file is included in this release.", Components: embeddedCredits.Components})
32 })
33 mountCSS(r, "/static/credits.css", credits.CSS())
34}
35