oficina / base Public

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

Plain git — no account needed to clone.

Download

Download this file

1// Package catalog lists the apps Base can install. The list is fixed at
2// build time; an operator enables each app on the Platform account once.
3package catalog
4
5import (
6 _ "embed"
7 "encoding/json"
8)
9
10// Entry describes one installable app. ID doubles as a DNS label part, so it
11// is lowercase letters, digits and hyphens. Tint is one of "amber", "teal",
12// "violet", "mist" or "rose". Icon is inline SVG markup.
13type Entry struct {
14 ID string `json:"id"`
15 Name string `json:"name"`
16 Summary string `json:"summary"`
17 Tint string `json:"tint"`
18 Icon string `json:"icon"`
19 Default bool `json:"default"`
20}
21
22//go:embed catalog.json
23var raw []byte
24
25var entries = mustLoad()
26
27func mustLoad() []Entry {
28 var e []Entry
29 if err := json.Unmarshal(raw, &e); err != nil {
30 panic("catalog: bad catalog.json: " + err.Error())
31 }
32 return e
33}
34
35// All returns the catalogue in display order. The caller may modify the copy.
36func All() []Entry { return append([]Entry(nil), entries...) }
37
38// Get returns the entry with the given ID.
39func Get(id string) (Entry, bool) {
40 for _, e := range entries {
41 if e.ID == id {
42 return e, true
43 }
44 }
45 return Entry{}, false
46}
47