diff --git a/api/web.go b/api/web.go index a5316e4..91e41e8 100644 --- a/api/web.go +++ b/api/web.go @@ -18,6 +18,17 @@ var webOverlayHTML []byte //go:embed web/favicon.svg var webFaviconSVG []byte +// PWA manifest + icons: lets browsers install the web UI as a standalone +// app (fullscreen from a home-screen icon on phones/tablets, its own window +// on desktop). No service worker on purpose — the UI is meaningless without +// the live server, so offline caching would only mislead. +// +//go:embed web/manifest.json +var webManifestJSON []byte + +//go:embed web/icon-192.png web/icon-512.png +var webIconsFS embed.FS + // webFontsFS holds the self-hosted woff2 fonts (Geist Mono + VT323), served at // /fonts/. Bundled into the binary so the UI needs no external font CDN — // important since it usually runs offline on the CDJ link-local network. @@ -45,6 +56,21 @@ func RegisterWebUI(mux *http.ServeMux) { w.Write(webOverlayHTML) }) + mux.HandleFunc("/manifest.json", func(w http.ResponseWriter, r *http.Request) { + w.Header().Set("Content-Type", "application/manifest+json") + w.Header().Set("Cache-Control", "public, max-age=86400") + w.Write(webManifestJSON) + }) + for _, name := range []string{"icon-192.png", "icon-512.png"} { + name := name + mux.HandleFunc("/"+name, func(w http.ResponseWriter, r *http.Request) { + data, _ := webIconsFS.ReadFile("web/" + name) + w.Header().Set("Content-Type", "image/png") + w.Header().Set("Cache-Control", "public, max-age=86400") + w.Write(data) + }) + } + // App icon (vinyl + the null ∅), used as the browser-tab favicon. mux.HandleFunc("/favicon.svg", func(w http.ResponseWriter, r *http.Request) { w.Header().Set("Content-Type", "image/svg+xml") diff --git a/api/web/icon-192.png b/api/web/icon-192.png new file mode 100644 index 0000000..fa17c04 Binary files /dev/null and b/api/web/icon-192.png differ diff --git a/api/web/icon-512.png b/api/web/icon-512.png new file mode 100644 index 0000000..7bf99c0 Binary files /dev/null and b/api/web/icon-512.png differ diff --git a/api/web/index.html b/api/web/index.html index 7b2594a..7e984ef 100644 --- a/api/web/index.html +++ b/api/web/index.html @@ -5,6 +5,9 @@ + + + Vynull · DJ LINK