diff --git a/.gitignore b/.gitignore index da4ca55..b3763c3 100644 --- a/.gitignore +++ b/.gitignore @@ -1,6 +1,7 @@ -./assets/index.js -./assets/styles.js +assets/index.js +assets/styles.css +cod4watcher local.db # Created by https://www.toptal.com/developers/gitignore/api/go # Edit at https://www.toptal.com/developers/gitignore?templates=go diff --git a/Makefile b/Makefile index e381df0..e941683 100644 --- a/Makefile +++ b/Makefile @@ -15,7 +15,7 @@ live/server: # run tailwindcss to generate the styles.css bundle in watch mode. live/tailwind: - npx tailwindcss -i ./style/input.css -o ./assets/styles.css --minify --watch + npx tailwindcss -i ./style/input.css -o ./assets/styles.css --minify --watch=forever # run esbuild to generate the index.js bundle in watch mode. live/esbuild: diff --git a/cod4watcher b/cod4watcher deleted file mode 100755 index a28e5ac..0000000 Binary files a/cod4watcher and /dev/null differ diff --git a/main.go b/main.go index bb076ea..adb03bb 100644 --- a/main.go +++ b/main.go @@ -38,6 +38,7 @@ func main() { go scanner.Scan() + router.Use(routes.PathMiddleware) router.Handle("/*", public()) router.Get("/health", routes.Make(server.HandleHealth)) router.Get("/captures/{captureID}", routes.Make(server.HandleCapture)) diff --git a/routes/home.go b/routes/home.go index 055351d..b4f62ee 100644 --- a/routes/home.go +++ b/routes/home.go @@ -4,6 +4,7 @@ import ( "net/http" "gitea.henriburau.de/haw-lan/cod4watcher/views/home" + "github.com/davecgh/go-spew/spew" ) func (s *Server) HandleHome(w http.ResponseWriter, r *http.Request) error { @@ -12,5 +13,7 @@ func (s *Server) HandleHome(w http.ResponseWriter, r *http.Request) error { return err } + spew.Dump(r.Context()) + return Render(w, r, home.Index(captureList)) } diff --git a/routes/path_middleware.go b/routes/path_middleware.go new file mode 100644 index 0000000..d3b6eae --- /dev/null +++ b/routes/path_middleware.go @@ -0,0 +1,15 @@ +package routes + +import ( + "context" + "net/http" + + "gitea.henriburau.de/haw-lan/cod4watcher/views" +) + +func PathMiddleware(next http.Handler) http.Handler { + return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { + ctx := context.WithValue(r.Context(), views.PathContext, r.URL.Path) + next.ServeHTTP(w, r.WithContext(ctx)) + }) +} diff --git a/tmp/bin/main b/tmp/bin/main index ad87fa9..281359f 100755 Binary files a/tmp/bin/main and b/tmp/bin/main differ diff --git a/views/components/navbar.templ b/views/components/navbar.templ index 3f50c1b..fa697f7 100644 --- a/views/components/navbar.templ +++ b/views/components/navbar.templ @@ -1,5 +1,7 @@ package components +import "gitea.henriburau.de/haw-lan/cod4watcher/views" + templ Nagivation() {