From 5f72acdb3a5ea347ab67838514c5d2d222fe9fa1 Mon Sep 17 00:00:00 2001 From: Yanislav Igonin Date: Sun, 30 Jan 2022 14:23:50 +0200 Subject: [PATCH] feat: separate pagination --- controllers/threads_controller.go | 8 +++++--- repositories/structs.go | 8 ++++++-- templates/components/captcha.html | 2 +- templates/components/pagiantion.html | 12 ++++++++++++ templates/components/thread-card.html | 2 +- templates/pages/index.html | 11 +---------- templates/pages/thread.html | 4 ++-- 7 files changed, 28 insertions(+), 19 deletions(-) create mode 100644 templates/components/pagiantion.html diff --git a/controllers/threads_controller.go b/controllers/threads_controller.go index a357da3..c622b07 100644 --- a/controllers/threads_controller.go +++ b/controllers/threads_controller.go @@ -54,9 +54,11 @@ func GetThreads(c *gin.Context) { captchaID := captcha.New() htmlData := Repositories.GetThreadsHtmlData{ - Threads: threads, - PagesCount: pagesCount, - Page: page, + Threads: threads, + Pagination: Repositories.HtmlPaginationData{ + PagesCount: pagesCount, + Page: page, + }, FormData: Repositories.HtmlFormData{ CaptchaID: captchaID, IsCaptchaActive: Config.App.IsCaptchaActive, diff --git a/repositories/structs.go b/repositories/structs.go index 38cda47..38ed648 100644 --- a/repositories/structs.go +++ b/repositories/structs.go @@ -39,6 +39,11 @@ type HtmlFormData struct { IsCaptchaActive bool } +type HtmlPaginationData struct { + PagesCount int + Page int +} + // thread.html type GetThreadHtmlData struct { Thread []Post @@ -48,8 +53,7 @@ type GetThreadHtmlData struct { // index.html type GetThreadsHtmlData struct { Threads []Post `json:"threads"` - PagesCount int `json:"pagesCount"` - Page int `json:"page"` + Pagination HtmlPaginationData FormData HtmlFormData } diff --git a/templates/components/captcha.html b/templates/components/captcha.html index 355c860..06edfbe 100644 --- a/templates/components/captcha.html +++ b/templates/components/captcha.html @@ -4,4 +4,4 @@ -{{ end }} \ No newline at end of file +{{ end }} diff --git a/templates/components/pagiantion.html b/templates/components/pagiantion.html new file mode 100644 index 0000000..66a79bd --- /dev/null +++ b/templates/components/pagiantion.html @@ -0,0 +1,12 @@ +{{ define "pagiantion" }} + +{{ end }} diff --git a/templates/components/thread-card.html b/templates/components/thread-card.html index c8d067a..e438ae4 100644 --- a/templates/components/thread-card.html +++ b/templates/components/thread-card.html @@ -23,4 +23,4 @@ -{{ end }} \ No newline at end of file +{{ end }} diff --git a/templates/pages/index.html b/templates/pages/index.html index d1689f7..20e35c6 100644 --- a/templates/pages/index.html +++ b/templates/pages/index.html @@ -20,16 +20,7 @@
- + {{ template "pagiantion" .Pagination }}
diff --git a/templates/pages/thread.html b/templates/pages/thread.html index cd9c2ad..dc38f8f 100644 --- a/templates/pages/thread.html +++ b/templates/pages/thread.html @@ -15,7 +15,7 @@
{{ template "post-form" .FormData }} - +
{{ range $Post := .Thread }}
@@ -38,7 +38,7 @@
- {{end}} + {{ end }}