feat(m4): SvelteKit frontend - today, week, history, settings views

This commit is contained in:
2026-04-30 16:45:00 +02:00
parent d0ef0387f2
commit df04d9d7a9
28 changed files with 2577 additions and 2 deletions

9
cmd/wotra/embed_dev.go Normal file
View File

@@ -0,0 +1,9 @@
// embed_dev.go — used in non-production builds (no web/build directory required)
//go:build !production
package main
import "io/fs"
// webFS is nil in dev mode; the router will skip static file serving.
var webFS fs.FS

20
cmd/wotra/embed_prod.go Normal file
View File

@@ -0,0 +1,20 @@
// embed_prod.go — used in production builds (requires web/build to exist)
//go:build production
package main
import (
"embed"
"io/fs"
)
//go:embed all:../../web/build
var embeddedWeb embed.FS
var webFS fs.FS = func() fs.FS {
sub, err := fs.Sub(embeddedWeb, "web/build")
if err != nil {
panic(err)
}
return sub
}()

View File

@@ -2,6 +2,7 @@ package main
import (
"context"
"io/fs"
"log/slog"
"net/http"
"os"
@@ -53,7 +54,13 @@ func main() {
defer cancel()
go runMidnightGuard(ctx, entrySvc)
router := handler.NewRouter(cfg.AuthToken, entrySvc, daySvc, settingsSvc, weekSvc)
// Static SPA files (embedded or from disk for dev)
var staticFS fs.FS
if webFS != nil {
staticFS = webFS
}
router := handler.NewRouter(cfg.AuthToken, entrySvc, daySvc, settingsSvc, weekSvc, staticFS)
srv := &http.Server{
Addr: ":" + cfg.Port,