krz/skunky-art
Alternative privacy frontend for DeviantArt.
clone: git clone https://gitbay.org/krz/skunky-art.git
main: static/templates.go · raw
1//go:build embed
2
3package static
4
5import (
6 "embed"
7 "io/fs"
8 "strings"
9)
10
11// Templates is the asset filesystem compiled into the binary.
12//
13//go:embed *
14var Templates embed.FS
15
16// Enabled reports that assets are embedded in this build.
17var Enabled bool = true
18
19// StaticPath is accepted for parity with the non-embed build, where it names the
20// directory assets are read from. It is ignored here.
21var StaticPath string
22
23// CopyTemplatesToMemory is a no-op in this build: the assets are already embedded.
24func CopyTemplatesToMemory() {
25 _ = StaticPath
26}
27
28// LanguageFiles lists the assets under lang/, which is how the i18n loader finds
29// catalogues without the FS needing directory listing.
30func LanguageFiles() []string {
31 entries, err := fs.ReadDir(Templates, "lang")
32 if err != nil {
33 return nil
34 }
35 var out []string
36 for _, e := range entries {
37 if !e.IsDir() && strings.HasSuffix(e.Name(), ".json") {
38 out = append(out, e.Name())
39 }
40 }
41 return out
42}