aboutsummaryrefslogtreecommitdiff
path: root/modules
diff options
context:
space:
mode:
authorjan <jan@ruken.pw>2015-12-29 22:13:09 (UTC)
committerjan <jan@ruken.pw>2015-12-29 22:13:09 (UTC)
commit10f014d5da7f1a35d2fc6cf0aa617a5ec4bb074f (patch)
treef0cff6de142552fa95e5f011ccb401fb89d40711 /modules
parent365bd4578a0c9b2e4ae5938d280609bd9af37faf (diff)
UI für die simple pagination. 'add' und 'sub' template-funktionen hinzugefügt.
Diffstat (limited to 'modules')
-rw-r--r--modules/tags/tags.go16
1 files changed, 16 insertions, 0 deletions
diff --git a/modules/tags/tags.go b/modules/tags/tags.go
index aca1b44..527d1d9 100644
--- a/modules/tags/tags.go
+++ b/modules/tags/tags.go
@@ -69,6 +69,20 @@ func (m *Module) viewTagPage(w http.ResponseWriter, r *http.Request, p httproute
69 pageNumber = 1 69 pageNumber = 1
70 } 70 }
71 71
72 // Anzahl an Pages holen
73 var pageNum int
74 err = m.g.DB.QueryRow(`SELECT COUNT(*) FROM grilist.grils_tags WHERE tag_id = $1`, tagID).Scan(&pageNum)
75 if err != nil {
76 log.Println("error getting page count", err)
77 http.Redirect(w, r, "/", 302)
78 return
79 }
80 pageCount := (int)((float64)(pageNum)/12.0 + 0.5)
81
82 if pageNumber > pageCount {
83 pageNumber = pageCount
84 }
85
72 idList := make([]int, 0) 86 idList := make([]int, 0)
73 rows, err := m.g.DB.Query( 87 rows, err := m.g.DB.Query(
74 "SELECT gril_id FROM grilist.grils_tags WHERE tag_id = $1 LIMIT 12 OFFSET $2", 88 "SELECT gril_id FROM grilist.grils_tags WHERE tag_id = $1 LIMIT 12 OFFSET $2",
@@ -108,5 +122,7 @@ func (m *Module) viewTagPage(w http.ResponseWriter, r *http.Request, p httproute
108 data["user"] = user 122 data["user"] = user
109 data["tag"] = tag 123 data["tag"] = tag
110 data["cards"] = cards 124 data["cards"] = cards
125 data["currentPage"] = pageNumber
126 data["pageCount"] = pageCount
111 m.g.Renderer.RenderPage("tag", w, data) 127 m.g.Renderer.RenderPage("tag", w, data)
112} 128}