Changeset 0.22.5 (#147)
Co-authored-by: Jeffrey Smith <jasafpro@gmail.com> Co-committed-by: Jeffrey Smith <jasafpro@gmail.com>
This commit is contained in:
@@ -23,6 +23,7 @@ import (
|
||||
"git.gobha.me/xcaliber/chat-switchboard/memory"
|
||||
"git.gobha.me/xcaliber/chat-switchboard/middleware"
|
||||
"git.gobha.me/xcaliber/chat-switchboard/notifications"
|
||||
"git.gobha.me/xcaliber/chat-switchboard/pages"
|
||||
"git.gobha.me/xcaliber/chat-switchboard/providers"
|
||||
"git.gobha.me/xcaliber/chat-switchboard/roles"
|
||||
"git.gobha.me/xcaliber/chat-switchboard/routing"
|
||||
@@ -814,6 +815,50 @@ func main() {
|
||||
}
|
||||
}
|
||||
|
||||
// ── Page Routes (v0.22.5) ────────────────
|
||||
// Server-rendered pages via Go templates. Runs alongside the SPA.
|
||||
// The chat surface is a bridge: Go renders the shell, existing JS
|
||||
// builds the DOM inside it — identical behavior to index.html.
|
||||
pages.SetVersion(Version)
|
||||
pageEngine := pages.New(cfg, stores)
|
||||
|
||||
// Login page — no auth required
|
||||
base.GET("/login", pageEngine.RenderLogin())
|
||||
|
||||
// Authenticated page routes
|
||||
pageRoutes := base.Group("")
|
||||
pageRoutes.Use(middleware.AuthOrRedirect(cfg))
|
||||
{
|
||||
// Chat surface (default) — bridge to existing SPA
|
||||
pageRoutes.GET("/", pageEngine.RenderSurface("chat"))
|
||||
pageRoutes.GET("/chat/:chatID", pageEngine.RenderSurface("chat"))
|
||||
|
||||
// Editor surface — server renders layout, JS builds CodeMirror inside
|
||||
pageRoutes.GET("/editor", pageEngine.RenderSurface("editor"))
|
||||
pageRoutes.GET("/editor/:wsId", pageEngine.RenderSurface("editor"))
|
||||
|
||||
// Notes surface
|
||||
pageRoutes.GET("/notes", pageEngine.RenderSurface("notes"))
|
||||
pageRoutes.GET("/notes/:noteId", pageEngine.RenderSurface("notes"))
|
||||
}
|
||||
|
||||
// Admin pages — auth + admin role required
|
||||
adminPages := base.Group("/admin")
|
||||
adminPages.Use(middleware.AuthOrRedirect(cfg))
|
||||
adminPages.Use(middleware.RequireAdminPage())
|
||||
{
|
||||
adminPages.GET("", pageEngine.RenderSurface("admin"))
|
||||
adminPages.GET("/:section", pageEngine.RenderSurface("admin"))
|
||||
}
|
||||
|
||||
// Settings pages — auth required
|
||||
settingsPages := base.Group("/settings")
|
||||
settingsPages.Use(middleware.AuthOrRedirect(cfg))
|
||||
{
|
||||
settingsPages.GET("", pageEngine.RenderSurface("settings"))
|
||||
settingsPages.GET("/:section", pageEngine.RenderSurface("settings"))
|
||||
}
|
||||
|
||||
bp := cfg.BasePath
|
||||
if bp == "" {
|
||||
bp = "/"
|
||||
@@ -834,6 +879,7 @@ func main() {
|
||||
}
|
||||
log.Printf(" EventBus: ready, WebSocket on %s/ws", cfg.BasePath)
|
||||
log.Printf(" Health: provider tracking active (flush=%s, prune=%s)", health.FlushInterval, health.PruneAge)
|
||||
log.Printf(" Pages: template engine active (surfaces: chat, editor, notes, settings, admin)")
|
||||
if err := r.Run(":" + cfg.Port); err != nil {
|
||||
log.Fatalf("Failed to start server: %v", err)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user