aboutsummaryrefslogtreecommitdiff
path: root/xess/xess.go
diff options
context:
space:
mode:
authorXe Iaso <me@xeiaso.net>2025-03-17 19:33:07 -0400
committerXe Iaso <me@xeiaso.net>2025-03-17 19:33:07 -0400
commit9923878c5c8b68df7f132efd28f76ce5478a1f1a (patch)
treec18dfc413495c09886b0d622a275f142f3e9c333 /xess/xess.go
downloadanubis-9923878c5c8b68df7f132efd28f76ce5478a1f1a.tar.xz
anubis-9923878c5c8b68df7f132efd28f76ce5478a1f1a.zip
initial import from /x/ monorepo
Signed-off-by: Xe Iaso <me@xeiaso.net>
Diffstat (limited to 'xess/xess.go')
-rw-r--r--xess/xess.go38
1 files changed, 38 insertions, 0 deletions
diff --git a/xess/xess.go b/xess/xess.go
new file mode 100644
index 0000000..301767b
--- /dev/null
+++ b/xess/xess.go
@@ -0,0 +1,38 @@
+// 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"
+
+ "github.com/TecharoHQ/anubis"
+ "github.com/TecharoHQ/anubis/internal"
+)
+
+//go:generate go run github.com/a-h/templ/cmd/templ@latest generate
+//go:generate npm ci
+//go:generate npm run build
+
+var (
+ //go:embed xess.min.css xess.css static
+ Static embed.FS
+
+ URL = "/.within.website/x/xess/xess.css"
+)
+
+func init() {
+ Mount(http.DefaultServeMux)
+
+ if anubis.Version != "devel" {
+ URL = filepath.Join(filepath.Dir(URL), "xess.min.css")
+ }
+
+ URL = URL + "?cachebuster=" + anubis.Version
+}
+
+func Mount(mux *http.ServeMux) {
+ mux.Handle("/.within.website/x/xess/", internal.UnchangingCache(http.StripPrefix("/.within.website/x/xess/", http.FileServerFS(Static))))
+}