nuke/xess/xess.go
fucksophie 02b9aebbe5
Some checks failed
Docker image builds / build (push) Failing after 4m22s
NUKE
2026-02-07 14:27:38 +02:00

39 lines
906 B
Go

// Package xess vendors a copy of Xess and makes it available at /.xess/xess.css
//
// This is intended to be used as a vendored package in other projects.
package xess
import (
"embed"
"net/http"
"path/filepath"
"git.sad.ovh/sophie/nuke"
"git.sad.ovh/sophie/nuke/internal"
)
var (
//go:embed *.css static
Static embed.FS
BasePrefix = "/.within.website/x/xess/"
URL = "/.within.website/x/xess/xess.css"
)
func init() {
Mount(http.DefaultServeMux)
//goland:noinspection GoBoolExpressions
if nuke.Version != "devel" {
URL = filepath.Join(filepath.Dir(URL), "xess.min.css")
}
URL = URL + "?cachebuster=" + nuke.Version
}
// Mount registers the xess static file handlers on the given mux
func Mount(mux *http.ServeMux) {
prefix := nuke.BasePrefix + "/.within.website/x/xess/"
mux.Handle(prefix, internal.UnchangingCache(http.StripPrefix(prefix, http.FileServerFS(Static))))
}