mirror of
https://github.com/yanislav-igonin/micrach
synced 2025-04-20 03:40:33 +03:00
feat: separate pagination
This commit is contained in:
parent
c73c6e9aec
commit
5f72acdb3a
@ -55,8 +55,10 @@ func GetThreads(c *gin.Context) {
|
|||||||
captchaID := captcha.New()
|
captchaID := captcha.New()
|
||||||
htmlData := Repositories.GetThreadsHtmlData{
|
htmlData := Repositories.GetThreadsHtmlData{
|
||||||
Threads: threads,
|
Threads: threads,
|
||||||
|
Pagination: Repositories.HtmlPaginationData{
|
||||||
PagesCount: pagesCount,
|
PagesCount: pagesCount,
|
||||||
Page: page,
|
Page: page,
|
||||||
|
},
|
||||||
FormData: Repositories.HtmlFormData{
|
FormData: Repositories.HtmlFormData{
|
||||||
CaptchaID: captchaID,
|
CaptchaID: captchaID,
|
||||||
IsCaptchaActive: Config.App.IsCaptchaActive,
|
IsCaptchaActive: Config.App.IsCaptchaActive,
|
||||||
|
@ -39,6 +39,11 @@ type HtmlFormData struct {
|
|||||||
IsCaptchaActive bool
|
IsCaptchaActive bool
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type HtmlPaginationData struct {
|
||||||
|
PagesCount int
|
||||||
|
Page int
|
||||||
|
}
|
||||||
|
|
||||||
// thread.html
|
// thread.html
|
||||||
type GetThreadHtmlData struct {
|
type GetThreadHtmlData struct {
|
||||||
Thread []Post
|
Thread []Post
|
||||||
@ -48,8 +53,7 @@ type GetThreadHtmlData struct {
|
|||||||
// index.html
|
// index.html
|
||||||
type GetThreadsHtmlData struct {
|
type GetThreadsHtmlData struct {
|
||||||
Threads []Post `json:"threads"`
|
Threads []Post `json:"threads"`
|
||||||
PagesCount int `json:"pagesCount"`
|
Pagination HtmlPaginationData
|
||||||
Page int `json:"page"`
|
|
||||||
FormData HtmlFormData
|
FormData HtmlFormData
|
||||||
}
|
}
|
||||||
|
|
||||||
|
12
templates/components/pagiantion.html
Normal file
12
templates/components/pagiantion.html
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
{{ define "pagiantion" }}
|
||||||
|
<nav aria-label="Page navigation">
|
||||||
|
<ul id="pagesList" class="pagination justify-content-center">
|
||||||
|
{{ $ActivePage := .Page }}
|
||||||
|
{{ range $i := Iterate .PagesCount }}
|
||||||
|
<li class="page-item {{ if (eq $i $ActivePage) }} active {{ end }}">
|
||||||
|
<a class="page-link" href="/?page={{ $i }}">{{ $i }}</a>
|
||||||
|
</li>
|
||||||
|
{{ end }}
|
||||||
|
</ul>
|
||||||
|
</nav>
|
||||||
|
{{ end }}
|
@ -20,16 +20,7 @@
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="col col-12">
|
<div class="col col-12">
|
||||||
<nav aria-label="Page navigation">
|
{{ template "pagiantion" .Pagination }}
|
||||||
<ul id="pagesList" class="pagination justify-content-center">
|
|
||||||
{{ $ActivePage := .Page }}
|
|
||||||
{{ range $i := Iterate .PagesCount }}
|
|
||||||
<li class="page-item {{ if (eq $i $ActivePage) }} active {{ end }}">
|
|
||||||
<a class="page-link" href="/?page={{ $i }}">{{ $i }}</a>
|
|
||||||
</li>
|
|
||||||
{{ end }}
|
|
||||||
</ul>
|
|
||||||
</nav>
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
@ -38,7 +38,7 @@
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
{{end}}
|
{{ end }}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user