diff --git a/cmd/pkgserver/main.go b/cmd/pkgserver/main.go new file mode 100644 index 0000000..1cb0738 --- /dev/null +++ b/cmd/pkgserver/main.go @@ -0,0 +1,55 @@ +package main + +import ( + "embed" + "fmt" + "net/http" +) + +//go:generate sh -c "sass ui/static/dark.scss ui/static/dark.css && sass ui/static/light.scss ui/static/light.css && tsc ui/static/index.ts" +//go:embed ui/* +var content embed.FS + +func serveWebUI(w http.ResponseWriter, r *http.Request) { + fmt.Printf("serveWebUI: %s\n", r.URL.Path) + w.Header().Set("Cache-Control", "no-cache, no-store, must-revalidate") + w.Header().Set("Pragma", "no-cache") + w.Header().Set("Expires", "0") + w.Header().Set("X-Content-Type-Options", "nosniff") + w.Header().Set("X-XSS-Protection", "1") + w.Header().Set("X-Frame-Options", "DENY") + + http.ServeFileFS(w, r, content, "ui/index.html") +} +func serveStaticContent(w http.ResponseWriter, r *http.Request) { + fmt.Printf("serveStaticContent: %s\n", r.URL.Path) + switch r.URL.Path { + case "/static/style.css": + darkTheme := r.CookiesNamed("dark_theme") + if len(darkTheme) > 0 && darkTheme[0].Value == "true" { + http.ServeFileFS(w, r, content, "ui/static/dark.css") + } else { + http.ServeFileFS(w, r, content, "ui/static/light.css") + } + break + case "/favicon.ico": + http.ServeFileFS(w, r, content, "ui/static/favicon.ico") + break + case "/static/index.js": + http.ServeFileFS(w, r, content, "ui/static/index.js") + break + default: + http.NotFound(w, r) + + } +} +func serveAPI(w http.ResponseWriter, r *http.Request) { + +} +func main() { + http.HandleFunc("GET /{$}", serveWebUI) + http.HandleFunc("GET /favicon.ico", serveStaticContent) + http.HandleFunc("GET /static/", serveStaticContent) + http.HandleFunc("GET /api/", serveAPI) + http.ListenAndServe(":8067", nil) +} diff --git a/cmd/pkgserver/ui/index.html b/cmd/pkgserver/ui/index.html new file mode 100644 index 0000000..6a832cb --- /dev/null +++ b/cmd/pkgserver/ui/index.html @@ -0,0 +1,23 @@ + + +
+ + +| Status | Name | Version |
|---|
Showing entries .
+« PreviousNext » + + \ No newline at end of file diff --git a/cmd/pkgserver/ui/static/_common.scss b/cmd/pkgserver/ui/static/_common.scss new file mode 100644 index 0000000..e69de29 diff --git a/cmd/pkgserver/ui/static/dark.css b/cmd/pkgserver/ui/static/dark.css new file mode 100644 index 0000000..8a6ac8a --- /dev/null +++ b/cmd/pkgserver/ui/static/dark.css @@ -0,0 +1,6 @@ +@use 'common'; +html { + background-color: #2c2c2c; + color: ghostwhite; } + +/*# sourceMappingURL=dark.css.map */ diff --git a/cmd/pkgserver/ui/static/dark.css.map b/cmd/pkgserver/ui/static/dark.css.map new file mode 100644 index 0000000..9db2757 --- /dev/null +++ b/cmd/pkgserver/ui/static/dark.css.map @@ -0,0 +1,7 @@ +{ +"version": 3, +"mappings": "AAAA,aAAa;AAEb,IAAK;EACH,gBAAgB,EAAE,OAAO;EACzB,KAAK,EAAE,UAAU", +"sources": ["dark.scss"], +"names": [], +"file": "dark.css" +} diff --git a/cmd/pkgserver/ui/static/dark.scss b/cmd/pkgserver/ui/static/dark.scss new file mode 100644 index 0000000..8d7ea84 --- /dev/null +++ b/cmd/pkgserver/ui/static/dark.scss @@ -0,0 +1,6 @@ +@use 'common'; + +html { + background-color: #2c2c2c; + color: ghostwhite; +} \ No newline at end of file diff --git a/cmd/pkgserver/ui/static/favicon.ico b/cmd/pkgserver/ui/static/favicon.ico new file mode 100644 index 0000000..cc67503 Binary files /dev/null and b/cmd/pkgserver/ui/static/favicon.ico differ diff --git a/cmd/pkgserver/ui/static/index.js b/cmd/pkgserver/ui/static/index.js new file mode 100644 index 0000000..26cdcb8 --- /dev/null +++ b/cmd/pkgserver/ui/static/index.js @@ -0,0 +1,4 @@ +function prevPage() { +} +function nextPage() { +} diff --git a/cmd/pkgserver/ui/static/index.ts b/cmd/pkgserver/ui/static/index.ts new file mode 100644 index 0000000..1253812 --- /dev/null +++ b/cmd/pkgserver/ui/static/index.ts @@ -0,0 +1,6 @@ +function prevPage() { + +} +function nextPage() { + +} \ No newline at end of file diff --git a/cmd/pkgserver/ui/static/light.css b/cmd/pkgserver/ui/static/light.css new file mode 100644 index 0000000..f275799 --- /dev/null +++ b/cmd/pkgserver/ui/static/light.css @@ -0,0 +1,6 @@ +@use 'common'; +html { + background-color: #d3d3d3; + color: black; } + +/*# sourceMappingURL=light.css.map */ diff --git a/cmd/pkgserver/ui/static/light.css.map b/cmd/pkgserver/ui/static/light.css.map new file mode 100644 index 0000000..12bdf73 --- /dev/null +++ b/cmd/pkgserver/ui/static/light.css.map @@ -0,0 +1,7 @@ +{ +"version": 3, +"mappings": "AAAA,aAAa;AAEb,IAAK;EACH,gBAAgB,EAAE,OAAO;EACzB,KAAK,EAAE,KAAK", +"sources": ["light.scss"], +"names": [], +"file": "light.css" +} diff --git a/cmd/pkgserver/ui/static/light.scss b/cmd/pkgserver/ui/static/light.scss new file mode 100644 index 0000000..437cb87 --- /dev/null +++ b/cmd/pkgserver/ui/static/light.scss @@ -0,0 +1,6 @@ +@use 'common'; + +html { + background-color: #d3d3d3; + color: black; +} \ No newline at end of file