Add clan-purge and player-purge. Optimized performance with template-init.

This commit is contained in:
MaxJa4
2024-01-20 17:14:47 +01:00
parent e5d13f2270
commit 9e3e2723d3
6 changed files with 94 additions and 59 deletions

View File

@@ -4,38 +4,16 @@ import (
"InfantrySkillCalculator/controllers"
"InfantrySkillCalculator/utils"
"github.com/gin-gonic/gin"
"html/template"
"log"
"net/http"
)
func mainPage(c *gin.Context) {
files := []string{
"./templates/index.html",
"./templates/components/home_clan_bar.html",
"./templates/components/opp_clan_bar.html",
"./templates/components/home_player_list.html",
"./templates/components/opp_player_list.html",
"./templates/components/bottom_controls.html",
"./templates/modals/delete_clan.html",
"./templates/modals/add_clan.html",
"./templates/modals/edit_clan.html",
"./templates/modals/add_player.html",
"./templates/modals/delete_player.html",
"./templates/modals/edit_player.html",
"./templates/modals/settings.html",
"./templates/components/header.html",
}
tmpl, err := template.ParseFiles(files...)
if err != nil {
log.Fatal(err)
}
data := map[string]interface{}{
"isAdmin": isUserAdmin(c),
}
err = tmpl.Execute(c.Writer, data)
err := mainPageTemplates.Execute(c.Writer, data)
if err != nil {
log.Fatal(err)
}
@@ -49,12 +27,7 @@ func loginPage(c *gin.Context) {
return
}
tmpl, err := template.ParseFiles([]string{"./templates/login.html", "./templates/components/header.html"}...)
if err != nil {
log.Fatal(err)
}
err = tmpl.Execute(c.Writer, nil)
err := loginPageTemplates.Execute(c.Writer, nil)
if err != nil {
log.Fatal(err)
}
@@ -102,12 +75,7 @@ func registerPage(c *gin.Context) {
return
}
tmpl, err := template.ParseFiles([]string{"./templates/register.html", "./templates/components/header.html"}...)
if err != nil {
log.Fatal(err)
}
err = tmpl.Execute(c.Writer, nil)
err := registerPageTemplates.Execute(c.Writer, nil)
if err != nil {
log.Fatal(err)
}