|
|
|
@ -13,18 +13,30 @@ with open("embed.go", "w") as f:
|
|
|
|
|
if EMBED in trues:
|
|
|
|
|
f.write("""package main
|
|
|
|
|
import (
|
|
|
|
|
"embed"
|
|
|
|
|
"log"
|
|
|
|
|
"embed"
|
|
|
|
|
"io/fs"
|
|
|
|
|
"log"
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
//go:embed data data/html data/web data/web/css data/web/js
|
|
|
|
|
var localFS embed.FS
|
|
|
|
|
|
|
|
|
|
//go:embed lang/common lang/admin lang/email lang/form lang/setup
|
|
|
|
|
var langFS embed.FS
|
|
|
|
|
var lFS embed.FS
|
|
|
|
|
|
|
|
|
|
var langFS LangFS
|
|
|
|
|
|
|
|
|
|
type LangFS struct {
|
|
|
|
|
fs embed.FS
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (l LangFS) Open(name string) (fs.File, error) { return l.fs.Open("lang/" + name) }
|
|
|
|
|
func (l LangFS) ReadDir(name string) ([]fs.DirEntry, error) { return l.fs.ReadDir("lang/" + name) }
|
|
|
|
|
func (l LangFS) ReadFile(name string) ([]byte, error) { return l.fs.ReadFile("lang/" + name) }
|
|
|
|
|
|
|
|
|
|
func loadLocalFS() {
|
|
|
|
|
log.Println("Using internal storage")
|
|
|
|
|
langFS = LangFS{lFS}
|
|
|
|
|
log.Println("Using internal storage")
|
|
|
|
|
}""")
|
|
|
|
|
elif EMBED in falses:
|
|
|
|
|
f.write("""package main
|
|
|
|
@ -42,5 +54,5 @@ func loadLocalFS() {
|
|
|
|
|
log.Println("Using external storage")
|
|
|
|
|
executable, _ := os.Executable()
|
|
|
|
|
localFS = os.DirFS(filepath.Dir(executable))
|
|
|
|
|
langFS = os.DirFS(filepath.Join(filepath.Dir(executable), "data"))
|
|
|
|
|
langFS = os.DirFS(filepath.Join(filepath.Dir(executable), "data", "lang"))
|
|
|
|
|
}""")
|
|
|
|
|