dkforest

A forum and chat platform (onion)
git clone https://git.dasho.dev/n0tr1v/dkforest.git
Log | Files | Refs | LICENSE

commit b66bd7e02e2a6eb34e2b637cf550d81013fecaf4
parent 46b4b06edb636c7a6ee4f647c9c7303c7272f214
Author: n0tr1v <n0tr1v@protonmail.com>
Date:   Mon, 18 Dec 2023 19:31:09 -0500

UI

Diffstat:
Mpkg/web/handlers/data.go | 4++++
Mpkg/web/handlers/handlers.go | 7+++++++
Mpkg/web/handlers/poker/poker.go | 3+--
Mpkg/web/middlewares/middlewares.go | 3++-
Apkg/web/public/views/pages/poker-table.gohtml | 18++++++++++++++++++
Mpkg/web/web.go | 3++-
6 files changed, 34 insertions(+), 4 deletions(-)

diff --git a/pkg/web/handlers/data.go b/pkg/web/handlers/data.go @@ -955,6 +955,10 @@ type TmpTable struct { NbSeated int } +type pokerTableData struct { + PokerTableSlug string +} + type pokerData struct { XmrPrice string XmrBalance database.Piconero diff --git a/pkg/web/handlers/handlers.go b/pkg/web/handlers/handlers.go @@ -1034,3 +1034,10 @@ func doCashOut(db *database.DkfDB, pokerTableSlug string, userID database.UserID }) return err } + +func PokerTableHandler(c echo.Context) error { + roomID := c.Param("roomID") + var data pokerTableData + data.PokerTableSlug = roomID + return c.Render(http.StatusOK, "poker-table", data) +} diff --git a/pkg/web/handlers/poker/poker.go b/pkg/web/handlers/poker/poker.go @@ -1699,7 +1699,6 @@ func buildSoundsHtml(authUser *database.User) (html string) { html += `<img src="/public/img/no-sound.png" style="height: 20px;" alt="" title="Sounds disabled" />` } html += `</a> - <a href="/poker" style="font-size: 20px; margin-left: 10px;">Poker</a> </div>` return } @@ -2324,7 +2323,7 @@ Loop: return nil } -func PokerHandler(c echo.Context) error { +func PokerStreamHandler(c echo.Context) error { roomID := RoomID(c.Param("roomID")) authUser := c.Get("authUser").(*database.User) db := c.Get("database").(*database.DkfDB) diff --git a/pkg/web/middlewares/middlewares.go b/pkg/web/middlewares/middlewares.go @@ -33,7 +33,7 @@ var GzipMiddleware = middleware.GzipWithConfig( c.Path() == "/vip/challenges/re-1/:filename" || c.Path() == "/chess/:key" || c.Path() == "/chess/:key/analyze" || - c.Path() == "/poker/:roomID" || + c.Path() == "/poker/:roomID/stream" || c.Path() == "/poker/:roomID/logs" || c.Path() == "/api/v1/chat/messages/:roomName/stream" || c.Path() == "/uploads/:filename" || @@ -299,6 +299,7 @@ func IsAuthMiddleware(next echo.HandlerFunc) echo.HandlerFunc { !strings.Contains(c.Path(), "/api/v1/chat/messages/:roomName/stream") && !strings.Contains(c.Path(), "/api/v1/chat/top-bar") && !strings.Contains(c.Path(), "/api/v1/chat/controls") && + !strings.Contains(c.Path(), "/poker/:roomID/stream") && !strings.Contains(c.Path(), "/poker/:roomID/sit/:pos") && !strings.Contains(c.Path(), "/poker/:roomID/unsit") && !strings.Contains(c.Path(), "/poker/:roomID/check") && diff --git a/pkg/web/public/views/pages/poker-table.gohtml b/pkg/web/public/views/pages/poker-table.gohtml @@ -0,0 +1,18 @@ +{{ define "nav-mb" }} mb-1{{ end }} + +{{ define "extra-head" }} +<style> + #poker-content { + border: 0; + border-left: 1px solid #aaa; + width: 100%; + height: calc(100vh - 61px); + } +</style> +{{ end }} + +{{ define "title" }}dkf - Poker ({{ .Data.PokerTableSlug }}){{ end }} + +{{ define "content" }} + <iframe id="poker-content" src="/poker/{{ .Data.PokerTableSlug }}/stream"></iframe> +{{ end }} diff --git a/pkg/web/web.go b/pkg/web/web.go @@ -100,7 +100,8 @@ func getMainServer(db *database.DkfDB, i18nBundle *i18n.Bundle, renderer *tmp.Te authGroup.GET("/shop", handlers.ShopHandler) authGroup.GET("/poker", handlers.PokerHomeHandler) authGroup.POST("/poker", handlers.PokerHomeHandler, middlewares.AuthRateLimitMiddleware(time.Second, 1)) - authGroup.GET("/poker/:roomID", poker.PokerHandler) + authGroup.GET("/poker/:roomID", handlers.PokerTableHandler) + authGroup.GET("/poker/:roomID/stream", poker.PokerStreamHandler) authGroup.GET("/poker/:roomID/logs", poker.PokerLogsHandler) authGroup.GET("/poker/:roomID/check", poker.PokerCheckHandler) authGroup.POST("/poker/:roomID/check", poker.PokerCheckHandler)