continuous-integration/drone/push Build encountered an error
- html/embed.go embeds html/ (pages, css, img, js, video); src/assets.go
serves it, with os.DirFS("html") under -dev. Static assets get an ETag
and Cache-Control: no-cache; HTML pages are still templated (only the
login error message is substituted now).
- Delete the generated src/webUI.go (783 KB base64), src/html-build.go and
cmd/webui-gen; Dockerfile no longer runs a generator.
- Language layer removed: 254 {{.x}} placeholders inlined as English
strings in ts/*.ts and the two auth pages; html/lang/en.json, the
LanguageUI struct and the 'language' setting are gone.
- ts/tsconfig.json + package.json pin typescript 5.9.3; the seven sources
compile (ES2020, global scripts) into one committed html/js/app.js.
Ten unreferenced legacy scripts under html/js/ deleted; all pages load
js/app.js.
- Fix the six type errors that blocked a clean compile, including a real
bug: a missing semicolon in the search shortcut handler made the code
call the result of preventDefault(), so the shortcut threw instead of
focusing the search box.
- /healthz liveness endpoint; Dockerfile healthcheck and README use it.
- Drone: go vet, and a webui-check step that rebuilds the bundle and fails
if the committed app.js is stale.
- README-DEV.md documents build, UI toolchain, -dev, versioning, CI.
53 lines
1.1 KiB
Go
53 lines
1.1 KiB
Go
package src
|
|
|
|
import (
|
|
"crypto/sha256"
|
|
"encoding/hex"
|
|
"io/fs"
|
|
"os"
|
|
"path"
|
|
"strings"
|
|
"sync"
|
|
|
|
webui "xteve/html"
|
|
)
|
|
|
|
// webFS serves the web interface. It is the embedded copy by default and the
|
|
// local html/ directory when xTeVe runs with -dev.
|
|
var webFS fs.FS = webui.FS
|
|
|
|
var webETags sync.Map // path -> ETag, only used when not in dev mode
|
|
|
|
// initWebFS : selects embedded or on-disk web files.
|
|
func initWebFS(dev bool) {
|
|
if dev {
|
|
webFS = os.DirFS("html")
|
|
return
|
|
}
|
|
webFS = webui.FS
|
|
}
|
|
|
|
// readWebFile : reads a file from the web interface, name relative to html/.
|
|
func readWebFile(name string) ([]byte, error) {
|
|
name = strings.TrimPrefix(path.Clean("/"+name), "/")
|
|
if name == "" || name == "." {
|
|
return nil, fs.ErrNotExist
|
|
}
|
|
return fs.ReadFile(webFS, name)
|
|
}
|
|
|
|
// webFileETag : content hash used for HTTP caching of static web assets.
|
|
func webFileETag(name string, content []byte) string {
|
|
if !System.Dev {
|
|
if v, ok := webETags.Load(name); ok {
|
|
return v.(string)
|
|
}
|
|
}
|
|
sum := sha256.Sum256(content)
|
|
etag := `"` + hex.EncodeToString(sum[:16]) + `"`
|
|
if !System.Dev {
|
|
webETags.Store(name, etag)
|
|
}
|
|
return etag
|
|
}
|