commit 7d8ba0be6e23760e8c3ae586a34e80bf5d78c544
parent 65dd70c0f664115c0adc16cde7a106a888abb6af
Author: n0tr1v <n0tr1v@protonmail.com>
Date: Tue, 12 Dec 2023 05:49:17 -0500
poker page
Diffstat:
6 files changed, 40 insertions(+), 1 deletion(-)
diff --git a/pkg/database/tablePokerTables.go b/pkg/database/tablePokerTables.go
@@ -14,6 +14,11 @@ type PokerTable struct {
IsTest bool
}
+func (d *DkfDB) GetPokerTables() (out []PokerTable, err error) {
+ err = d.db.Find(&out).Error
+ return
+}
+
func (d *DkfDB) GetPokerTableBySlug(slug string) (out PokerTable, err error) {
err = d.db.First(&out, "slug = ?", slug).Error
return
diff --git a/pkg/web/handlers/data.go b/pkg/web/handlers/data.go
@@ -928,6 +928,10 @@ type chessData struct {
Color string
}
+type pokerData struct {
+ Tables []database.PokerTable
+}
+
type powHelperData struct {
Difficulty int64
}
diff --git a/pkg/web/handlers/handlers.go b/pkg/web/handlers/handlers.go
@@ -751,3 +751,10 @@ func BHCHandler(c echo.Context) error {
data.Success = fmt.Sprintf("Good answer, go back to BHC and use '%s' as your username", username+h[:3])
return c.Render(http.StatusOK, "bhc", data)
}
+
+func PokerHomeHandler(c echo.Context) error {
+ db := c.Get("database").(*database.DkfDB)
+ var data pokerData
+ data.Tables, _ = db.GetPokerTables()
+ return c.Render(http.StatusOK, "poker", data)
+}
diff --git a/pkg/web/public/views/pages/index.gohtml b/pkg/web/public/views/pages/index.gohtml
@@ -43,8 +43,8 @@
<li class="nav-item"><a class="nav-link" href="/forum">{{ t "Forum" . }}</a></li>
<li class="nav-item"><a class="nav-link" href="/links">{{ t "Links" . }}</a></li>
<li class="nav-item"><a class="nav-link" href="/chess">{{ t "Chess" . }}</a></li>
+ <li class="nav-item"><a class="nav-link" href="/poker">{{ t "Poker" . }}</a></li>
<li class="nav-item"><a class="nav-link" href="/vip">{{ t "VIP" . }}</a></li>
- <li class="nav-item"><a class="nav-link" href="/club">{{ t "Club" . }}</a></li>
<li class="nav-item"><a class="nav-link" href="{{ .GitURL }}" rel="noopener noreferrer" target="_blank">{{ t "Git" . }}</a></li>
{{ end }}
</ul>
diff --git a/pkg/web/public/views/pages/poker.gohtml b/pkg/web/public/views/pages/poker.gohtml
@@ -0,0 +1,21 @@
+{{ define "title" }}dkf - poker{{ end }}
+
+{{ define "content" }}
+ <div class="container">
+ <h3>Tables</h3>
+ <table class="table table-novpadding table-sm table-hover table-striped">
+ <tr>
+ <th>Table</th>
+ <th>Min/max buy-in</th>
+ </tr>
+ {{ range .Data.Tables }}
+ <tr>
+ <td><a href="/poker/{{ .Slug }}">{{ .Slug }}</a></td>
+ <td>{{ .MinBuyIn }} - {{ .MaxBuyIn }}</td>
+ </tr>
+ {{ else }}
+ <tr><td colspan="2"><em>No table to show</em></td></tr>
+ {{ end }}
+ </table>
+ </div>
+{{ end }}
+\ No newline at end of file
diff --git a/pkg/web/web.go b/pkg/web/web.go
@@ -98,6 +98,7 @@ func getMainServer(db *database.DkfDB, i18nBundle *i18n.Bundle, renderer *tmp.Te
authGroup.POST("/captcha", handlers.CaptchaHandler, middlewares.AuthRateLimitMiddleware(time.Second, 1))
authGroup.GET("/donate", handlers.DonateHandler)
authGroup.GET("/shop", handlers.ShopHandler)
+ authGroup.GET("/poker", handlers.PokerHomeHandler)
authGroup.GET("/poker/:roomID", poker.PokerHandler)
authGroup.GET("/poker/:roomID/logs", poker.PokerLogsHandler)
authGroup.GET("/poker/:roomID/check", poker.PokerCheckHandler)