Go · 858 bytes Raw Blame History
1 // SPDX-License-Identifier: AGPL-3.0-or-later
2
3 package web
4
5 import (
6 "embed"
7 "io/fs"
8 )
9
10 //go:embed all:templates
11 var templatesFS embed.FS
12
13 //go:embed all:static
14 var staticFS embed.FS
15
16 // TemplatesFS returns the read-only filesystem rooted at the templates dir.
17 func TemplatesFS() fs.FS {
18 sub, err := fs.Sub(templatesFS, "templates")
19 if err != nil {
20 // embed.FS layout is verified at compile time; this can't fail at
21 // runtime once the build succeeds.
22 panic(err)
23 }
24 return sub
25 }
26
27 // StaticFS returns the read-only filesystem rooted at the static dir.
28 func StaticFS() fs.FS {
29 sub, err := fs.Sub(staticFS, "static")
30 if err != nil {
31 panic(err)
32 }
33 return sub
34 }
35
36 // LogoSVG returns the canonical mascot SVG bytes (full mark, with tentacles
37 // and pitchfork).
38 func LogoSVG() ([]byte, error) {
39 return staticFS.ReadFile("static/logo/shithub.svg")
40 }
41