mirror of
https://github.com/yanislav-igonin/micrach
synced 2025-04-18 19:00:33 +03:00
feat: separate pagination
This commit is contained in:
parent
c73c6e9aec
commit
5f72acdb3a
@ -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,
|
||||
|
@ -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
|
||||
}
|
||||
|
||||
|
@ -4,4 +4,4 @@
|
||||
</div>
|
||||
<input class="form-control" type="hidden" name="captchaId" value="{{ . }}">
|
||||
<input class="form-control" id="postCaptcha" type="tel" pattern="\d+" placeholder="Captcha" name="captcha">
|
||||
{{ end }}
|
||||
{{ end }}
|
||||
|
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 }}
|
@ -23,4 +23,4 @@
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{{ end }}
|
||||
{{ end }}
|
||||
|
@ -20,16 +20,7 @@
|
||||
</div>
|
||||
|
||||
<div class="col col-12">
|
||||
<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>
|
||||
{{ template "pagiantion" .Pagination }}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
@ -15,7 +15,7 @@
|
||||
|
||||
<div class="container">
|
||||
{{ template "post-form" .FormData }}
|
||||
|
||||
|
||||
<div id="postsСontainer">
|
||||
{{ range $Post := .Thread }}
|
||||
<div class="post-container mb-4">
|
||||
@ -38,7 +38,7 @@
|
||||
</div>
|
||||
|
||||
</div>
|
||||
{{end}}
|
||||
{{ end }}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user