From 45c9bd3b40ca5783efe6421e6ad60a4087f99169 Mon Sep 17 00:00:00 2001 From: nite07 Date: Fri, 29 Nov 2024 03:55:45 +0800 Subject: [PATCH] add: frontend --- server/route.go | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/server/route.go b/server/route.go index 6e963d5..271434c 100644 --- a/server/route.go +++ b/server/route.go @@ -31,13 +31,13 @@ func initRoute(app *gin.Engine) { func initFrontend(app *gin.Engine) { app.Static("/static", "server/static") - layoutFiles, err := filepath.Glob("server/templates/layouts/*.tmpl") + layoutFiles, err := filepath.Glob("server/templates/layouts/*.html") if err != nil { log.Logger.Fatal("Error loading layout templates", zap.Error(err)) return } - rootFiles, err := filepath.Glob("server/templates/*.tmpl") + rootFiles, err := filepath.Glob("server/templates/*.html") if err != nil { log.Logger.Fatal("Error loading root templates", zap.Error(err)) return @@ -48,10 +48,10 @@ func initFrontend(app *gin.Engine) { app.GET("/", func(ctx *gin.Context) { infos, err := crawler.GetSteam250MonthTop50() if err != nil { - ctx.HTML(500, "500.tmpl", err) + ctx.HTML(500, "500.html", err) return } - ctx.HTML(200, "index.tmpl", gin.H{ + ctx.HTML(200, "index.html", gin.H{ "MonthTop": infos, }) }) @@ -60,22 +60,22 @@ func initFrontend(app *gin.Engine) { idStr := ctx.Param("id") id, err := primitive.ObjectIDFromHex(idStr) if err != nil { - ctx.HTML(400, "400.tmpl", nil) + ctx.HTML(400, "400.html", nil) return } info, err := db.GetGameInfoByID(id) if err != nil { - ctx.HTML(500, "500.tmpl", err) + ctx.HTML(500, "500.html", err) return } games, err := db.GetGameItemsByIDs(info.GameIDs) if err != nil { - ctx.HTML(500, "500.tmpl", err) + ctx.HTML(500, "500.html", err) return } info.Games = games //TODO: fix this - ctx.HTML(200, "game.tmpl", info) + ctx.HTML(200, "game.html", info) }) }