From 978ba292a17bca7d978c3ffe4eb24e2b321d916e Mon Sep 17 00:00:00 2001 From: miaurizius Date: Fri, 5 Jun 2026 19:09:41 +0200 Subject: [PATCH] Made assets accessible --- frontend/assets/css/{style.css => dashboard.css} | 0 frontend/handler.go | 7 +++++++ frontend/htmx/contents/dash/base.html | 2 +- server/server.go | 3 +++ 4 files changed, 11 insertions(+), 1 deletion(-) rename frontend/assets/css/{style.css => dashboard.css} (100%) diff --git a/frontend/assets/css/style.css b/frontend/assets/css/dashboard.css similarity index 100% rename from frontend/assets/css/style.css rename to frontend/assets/css/dashboard.css diff --git a/frontend/handler.go b/frontend/handler.go index 4c731de..31043ae 100644 --- a/frontend/handler.go +++ b/frontend/handler.go @@ -3,6 +3,8 @@ package frontend import ( "html/template" "net/http" + "path/filepath" + "strings" ) var dashbaord = template.Must(template.ParseFiles( @@ -33,3 +35,8 @@ func Dashboard(w http.ResponseWriter, r *http.Request) { return } } + +func Assets(w http.ResponseWriter, r *http.Request) { + path := strings.TrimPrefix(r.URL.Path, "/assets/") + http.ServeFile(w, r, filepath.Join("frontend/assets", path)) +} diff --git a/frontend/htmx/contents/dash/base.html b/frontend/htmx/contents/dash/base.html index 0e4adac..9da79d1 100644 --- a/frontend/htmx/contents/dash/base.html +++ b/frontend/htmx/contents/dash/base.html @@ -7,7 +7,7 @@ - + diff --git a/server/server.go b/server/server.go index 776ec2b..074df20 100644 --- a/server/server.go +++ b/server/server.go @@ -77,6 +77,9 @@ func (this *Server) Run() { mux.HandleFunc("/api/stock/add", handlers.AddStock) mux.HandleFunc("/api/project-items/add", handlers.AllocateToProject) + // Assets + mux.HandleFunc("/assets/", frontend.Assets) + // Login required // Admin-only