Now worky
This commit is contained in:
parent
e2b9b8f176
commit
b6555a1cc8
|
@ -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
|
||||
|
|
2
Makefile
2
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:
|
||||
|
|
BIN
cod4watcher
BIN
cod4watcher
Binary file not shown.
1
main.go
1
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))
|
||||
|
|
|
@ -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))
|
||||
}
|
||||
|
|
|
@ -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))
|
||||
})
|
||||
}
|
BIN
tmp/bin/main
BIN
tmp/bin/main
Binary file not shown.
|
@ -1,5 +1,7 @@
|
|||
package components
|
||||
|
||||
import "gitea.henriburau.de/haw-lan/cod4watcher/views"
|
||||
|
||||
templ Nagivation() {
|
||||
<nav class="bg-gray-800">
|
||||
<div class="mx-auto max-w-7xl">
|
||||
|
@ -12,8 +14,13 @@ templ Nagivation() {
|
|||
<div class="hidden sm:ml-6 sm:block">
|
||||
<div class="flex space-x-4">
|
||||
<!-- Current: "bg-gray-900 text-white", Default: "text-gray-300 hover:bg-gray-700 hover:text-white" -->
|
||||
if ctx.Value(views.PathContext) == "" || ctx.Value(views.PathContext) == "/" {
|
||||
<a href="/" class="bg-gray-900 text-white rounded-md px-3 py-2 text-sm font-medium" aria-current="page">Dashboard</a>
|
||||
<a href="/about" class="text-gray-300 hover:bg-gray-700 hover:text-white rounded-md px-3 py-2 text-sm font-medium">About</a>
|
||||
} else {
|
||||
<a href="/" class="text-gray-300 hover:bg-gray-700 hover:text-white rounded-md px-3 py-2 text-sm font-medium">Dashboard</a>
|
||||
<a href="/about" class="text-gray-300 hover:bg-gray-700 hover:text-white rounded-md px-3 py-2 text-sm font-medium">About</a>
|
||||
}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
|
|
@ -10,6 +10,8 @@ import "context"
|
|||
import "io"
|
||||
import "bytes"
|
||||
|
||||
import "gitea.henriburau.de/haw-lan/cod4watcher/views"
|
||||
|
||||
func Nagivation() templ.Component {
|
||||
return templ.ComponentFunc(func(ctx context.Context, templ_7745c5c3_W io.Writer) (templ_7745c5c3_Err error) {
|
||||
templ_7745c5c3_Buffer, templ_7745c5c3_IsBuffer := templ_7745c5c3_W.(*bytes.Buffer)
|
||||
|
@ -27,6 +29,21 @@ func Nagivation() templ.Component {
|
|||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
if ctx.Value(views.PathContext) == "" || ctx.Value(views.PathContext) == "/" {
|
||||
templ_7745c5c3_Err = templ.WriteWatchModeString(templ_7745c5c3_Buffer, 2)
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
} else {
|
||||
templ_7745c5c3_Err = templ.WriteWatchModeString(templ_7745c5c3_Buffer, 3)
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
}
|
||||
templ_7745c5c3_Err = templ.WriteWatchModeString(templ_7745c5c3_Buffer, 4)
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
if !templ_7745c5c3_IsBuffer {
|
||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteTo(templ_7745c5c3_W)
|
||||
}
|
||||
|
|
|
@ -1 +1,4 @@
|
|||
<nav class=\"bg-gray-800\"><div class=\"mx-auto max-w-7xl\"><div class=\"relative flex h-16 items-center justify-between\"><div class=\"flex flex-1 items-center justify-center sm:items-stretch sm:justify-start\"><div class=\"flex flex-shrink-0 items-center\"><span class=\"text-white pr-2 font-bold\">Turnier-Tracker</span> <img class=\"h-8 w-auto\" src=\"/assets/logo.svg\" alt=\"Your Company\"></div><div class=\"hidden sm:ml-6 sm:block\"><div class=\"flex space-x-4\"><!-- Current: \"bg-gray-900 text-white\", Default: \"text-gray-300 hover:bg-gray-700 hover:text-white\" --><a href=\"/\" class=\"bg-gray-900 text-white rounded-md px-3 py-2 text-sm font-medium\" aria-current=\"page\">Dashboard</a> <a href=\"/about\" class=\"text-gray-300 hover:bg-gray-700 hover:text-white rounded-md px-3 py-2 text-sm font-medium\">About</a></div></div></div><div class=\"absolute inset-y-0 right-0 flex items-center pr-2 sm:static sm:inset-auto sm:ml-6 sm:pr-0\"></div></div></div></nav>
|
||||
<nav class=\"bg-gray-800\"><div class=\"mx-auto max-w-7xl\"><div class=\"relative flex h-16 items-center justify-between\"><div class=\"flex flex-1 items-center justify-center sm:items-stretch sm:justify-start\"><div class=\"flex flex-shrink-0 items-center\"><span class=\"text-white pr-2 font-bold\">Turnier-Tracker</span> <img class=\"h-8 w-auto\" src=\"/assets/logo.svg\" alt=\"Your Company\"></div><div class=\"hidden sm:ml-6 sm:block\"><div class=\"flex space-x-4\"><!-- Current: \"bg-gray-900 text-white\", Default: \"text-gray-300 hover:bg-gray-700 hover:text-white\" -->
|
||||
<a href=\"/\" class=\"bg-gray-900 text-white rounded-md px-3 py-2 text-sm font-medium\" aria-current=\"page\">Dashboard</a> <a href=\"/about\" class=\"text-gray-300 hover:bg-gray-700 hover:text-white rounded-md px-3 py-2 text-sm font-medium\">About</a>
|
||||
<a href=\"/\" class=\"text-gray-300 hover:bg-gray-700 hover:text-white rounded-md px-3 py-2 text-sm font-medium\">Dashboard</a> <a href=\"/about\" class=\"text-gray-300 hover:bg-gray-700 hover:text-white rounded-md px-3 py-2 text-sm font-medium\">About</a>
|
||||
</div></div></div><div class=\"absolute inset-y-0 right-0 flex items-center pr-2 sm:static sm:inset-auto sm:ml-6 sm:pr-0\"></div></div></div></nav>
|
||||
|
|
|
@ -0,0 +1,5 @@
|
|||
package views
|
||||
|
||||
type contextKey string
|
||||
|
||||
var PathContext = contextKey("path")
|
Loading…
Reference in New Issue