Made the elo system work. Colorized the leaderboard. Better data structure. Improved the HTML. Custom form system. Added Sessions

This commit is contained in:
Jonas Hahn
2025-08-25 14:56:59 +02:00
parent 4b4377a24e
commit f5e5d5632d
20 changed files with 492 additions and 289 deletions

View File

@@ -82,7 +82,12 @@ func (tm *TemplateManager) LoadTemplates() {
func (tm *TemplateManager) Render(c *gin.Context, name string, data gin.H) error {
print("\nRendering template:", name, "\n")
u := getSessionUser(c)
// Prefil the data for the render
data["CurrentUser"] = u
// Try to get information from current context that is filled from the session middleware
data["Form"], _ = c.Get("form")
data["Message"], _ = c.Get("mes")
tpl, ok := tm.templates[name]
if !ok {
@@ -91,7 +96,7 @@ func (tm *TemplateManager) Render(c *gin.Context, name string, data gin.H) error
fmt.Print(tm.templates[name])
if err := tpl.ExecuteTemplate(c.Writer, tm.base, data); err != nil {
log.Println("tpl error:", err)
log.Println("template error:", err)
c.Status(500)
return err
}