From f61b726ca838849c029511eeef3dec0b6c4b4958 Mon Sep 17 00:00:00 2001 From: woon Date: Fri, 10 Mar 2023 16:34:28 +0800 Subject: [PATCH] update --- handler/index.go | 8 ++++---- router.go | 12 +++++++++--- 2 files changed, 13 insertions(+), 7 deletions(-) diff --git a/handler/index.go b/handler/index.go index b568287..ae3445f 100644 --- a/handler/index.go +++ b/handler/index.go @@ -14,7 +14,7 @@ func Index(c *gin.Context) { if p < 1 { p = 1 } - limit := 100 + limit := 5 start := (p - 1) * limit list := make([]*Article, 0) @@ -44,9 +44,9 @@ func Index(c *gin.Context) { nextPage = p + 1 } - prevPage := 1 - if p > 2 { - prevPage = p + 1 + prevPage := 0 + if p >= 2 { + prevPage = p - 1 } title := os.Getenv("HOME_TITLE") diff --git a/router.go b/router.go index 20acb1d..e443e41 100644 --- a/router.go +++ b/router.go @@ -40,9 +40,15 @@ func Router() *gin.Engine { themeName = "theme_example" } - r.HTMLRender = loadTemplates("./theme/" + themeName + "/tmpl") - r.Static("/statics", "./theme/"+themeName+"/statics") - r.StaticFile("/favicon.ico", "./theme/"+themeName+"/favicon.ico") + themPath := "./theme/" + themeName + + if len(os.Getenv("THEME_PATH")) > 0 { + themPath = os.Getenv("THEME_PATH") + } + + r.HTMLRender = loadTemplates(themPath + "/tmpl") + r.Static("/statics", themPath+"/statics") + r.StaticFile("/favicon.ico", themPath+"/favicon.ico") r.GET("/", handler.Index) r.GET("/article/:id", handler.GetArticle)