From d095bc9ff415d7223db43fe7bc4f848919a3cbc0 Mon Sep 17 00:00:00 2001 From: "Zed A. Shaw" Date: Thu, 10 Jul 2025 11:46:56 -0400 Subject: [PATCH] Now can alternatively generate a static page for a URL from pages, or dynamically return it with c.Render from views. Did this for games and streams. --- api/handlers.go | 10 +++ main.go | 4 +- public/stream/1/index.html | 89 ------------------- .../index.html => views/game.html | 0 views/layouts/main.html | 36 +++++++- .../stream/1/index.html => views/stream.html | 0 6 files changed, 45 insertions(+), 94 deletions(-) delete mode 100644 public/stream/1/index.html rename pages/game/1/turings-tarpit/index.html => views/game.html (100%) rename pages/stream/1/index.html => views/stream.html (100%) diff --git a/api/handlers.go b/api/handlers.go index b2020a4..6b97a64 100644 --- a/api/handlers.go +++ b/api/handlers.go @@ -22,6 +22,14 @@ func GetApiLogout(c *fiber.Ctx) error { return c.Redirect("/") } +func GetPageStream(c *fiber.Ctx) error { + return c.Render("stream", fiber.Map{}) +} + +func GetPageGame(c *fiber.Ctx) error { + return c.Render("game", fiber.Map{}) +} + func GetApiStream(c *fiber.Ctx) error { sql, args, err := sq.Select("*").From("stream").ToSql() err = data.SelectJson[data.Stream](c, err, sql, args...) @@ -118,6 +126,8 @@ func Setup(app *fiber.App) { CacheDuration: 1 * time.Nanosecond, }) + app.Get("/stream/:id/", GetPageStream) + app.Get("/game/:id/:name/", GetPageGame) app.Get("/api/stream", GetApiStream) app.Get("/api/logout", GetApiLogout) app.Get("/api/stream/:id", GetApiStreamId) diff --git a/main.go b/main.go index e81be06..1481d58 100644 --- a/main.go +++ b/main.go @@ -9,8 +9,8 @@ import ( "github.com/gofiber/fiber/v2/middleware/logger" "github.com/gofiber/template/html/v2" - _ "github.com/mattn/go-sqlite3" - recov "github.com/gofiber/fiber/v2/middleware/recover" + _ "github.com/mattn/go-sqlite3" + recov "github.com/gofiber/fiber/v2/middleware/recover" "zedshaw.games/webapp/api" "zedshaw.games/webapp/data" diff --git a/public/stream/1/index.html b/public/stream/1/index.html deleted file mode 100644 index bf3e0be..0000000 --- a/public/stream/1/index.html +++ /dev/null @@ -1,89 +0,0 @@ - - - - - - - - - - ZedShaw.games - - -
- - - 🏡 - Live - Streams - Games - Register - Login - - -
- - - -
- - - -

- -
-

-
-
- - -

Qui animated corpse, cricket bat max brucks terribilem incessu zomby. The voodoo sacerdos flesh eater, suscitat mortuos comedere carnem virus. Zonbi tattered for solum oculi eorum defunctis go lum cerebro. Nescio brains an Undead zombies. Sicut malus putrid voodoo horror.

-
- - -

Links Posted

- -
    - -
-
- - - - Left Image -
-

I stream on Twitch.

- -

I stream every day at 10AM/10PM EST time. 60% of the time it's a chill laid back stream with only programming and a bit of talking about programming. 30% of the time it's art for games I'm making. 10% of the time it's games I'm playing.

- - -
-
-
- -
-
- - - - - diff --git a/pages/game/1/turings-tarpit/index.html b/views/game.html similarity index 100% rename from pages/game/1/turings-tarpit/index.html rename to views/game.html diff --git a/views/layouts/main.html b/views/layouts/main.html index c5afed6..4e87332 100644 --- a/views/layouts/main.html +++ b/views/layouts/main.html @@ -5,10 +5,40 @@ - {{.Title}} + + + ZedShaw.games + +
+ + + 🏡 + Live + Streams + Games + Register + Login + + +
- - {{embed}} + {{embed}} + + diff --git a/pages/stream/1/index.html b/views/stream.html similarity index 100% rename from pages/stream/1/index.html rename to views/stream.html