dkforest

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

commit 041271665db0db2987c191882ef50820e0c3aadc
parent 4ec1a9b960b4a9b974e436cd786d1d4b43c41d96
Author: n0tr1v <n0tr1v@protonmail.com>
Date:   Sat, 17 Jun 2023 15:25:31 -0700

experiment

Diffstat:
Mpkg/web/handlers/chess.go | 10++++++++++
Mpkg/web/handlers/data.go | 4++++
Apkg/web/public/views/pages/chess-analyze.gohtml | 14++++++++++++++
Mpkg/web/web.go | 2++
4 files changed, 30 insertions(+), 0 deletions(-)

diff --git a/pkg/web/handlers/chess.go b/pkg/web/handlers/chess.go @@ -891,3 +891,13 @@ func renderChecks(styles *StylesBuilder, checkID string) { styles.Appendf(`#%s { background-color: %s !important; }`, checkID, interceptors.CheckColor) } } + +func ChessAnalyzeHandler(c echo.Context) error { + authUser := c.Get("authUser").(*database.User) + if !authUser.CanUseChessAnalyze { + return c.Redirect(http.StatusFound, "/") + } + var data chessAnalyzeData + data.Pgn = c.Request().PostFormValue("pgn") + return c.Render(http.StatusOK, "chess-analyze", data) +} diff --git a/pkg/web/handlers/data.go b/pkg/web/handlers/data.go @@ -933,3 +933,7 @@ type powHelperData struct { type externalLink1Data struct { Link string } + +type chessAnalyzeData struct { + Pgn string +} diff --git a/pkg/web/public/views/pages/chess-analyze.gohtml b/pkg/web/public/views/pages/chess-analyze.gohtml @@ -0,0 +1,13 @@ +{{ define "title" }}dkf - chess{{ end }} + +{{ define "content" }} + <div class="container"> + <form method="post"> + <input type="hidden" name="csrf" value="{{ .CSRF }}" /> + <div class="form-group"> + <textarea name="pgn" placeholder="PGN" class="form-control">{{ .Data.Pgn }}</textarea> + </div> + <button class="btn btn-primary">Analyze</button> + </form> + </div> +{{ end }} +\ No newline at end of file diff --git a/pkg/web/web.go b/pkg/web/web.go @@ -98,6 +98,8 @@ func getMainServer(db *database.DkfDB, i18nBundle *i18n.Bundle, renderer *tmp.Te authGroup.GET("/shop", handlers.ShopHandler) authGroup.GET("/chess", handlers.ChessHandler) authGroup.POST("/chess", handlers.ChessHandler) + authGroup.GET("/chess/analyze", handlers.ChessAnalyzeHandler) + authGroup.POST("/chess/analyze", handlers.ChessAnalyzeHandler) authGroup.GET("/chess/:key", handlers.ChessGameHandler) authGroup.POST("/chess/:key", handlers.ChessGameHandler) authGroup.GET("/chess/:key/analyze", handlers.ChessGameAnalyzeHandler)