diff options
Diffstat (limited to 'web/templates/search/components/pagination.tmpl')
-rw-r--r-- | web/templates/search/components/pagination.tmpl | 44 |
1 files changed, 44 insertions, 0 deletions
diff --git a/web/templates/search/components/pagination.tmpl b/web/templates/search/components/pagination.tmpl new file mode 100644 index 0000000..e4df856 --- /dev/null +++ b/web/templates/search/components/pagination.tmpl @@ -0,0 +1,44 @@ +{{define "pagination"}} + <nav class="pull-right"> + <ul class="pagination ag-pager"> + {{ if eq .CurrentPage 1}} + <li class="page-item disabled"> + <a class="page-link" href="#" aria-label="Previous"> + <span aria-hidden="true">«</span> + </a> + {{else}} + <li class="page-item"> + <a class="page-link" href="/search?q={{.SearchQuery}}&page={{ sub .CurrentPage 1 }}" aria-label="Previous"> + <span aria-hidden="true">«</span> + </a> + {{end}} + </li> + {{ $min := max 1 (sub .CurrentPage 3) }} + {{ $max := min .MaxPages (add .CurrentPage 3) }} + {{if gt $min 3 }} + <li class="page-item"><a class="page-link" href="/search?q={{.SearchQuery}}&page=1">1</a></li> + <li class="page-item disabled"><a class="page-link" href="#">…</a></li> + {{end}} + + {{range (makeRange $min $max)}} + <li {{if eq . $.CurrentPage}}class="page-item active"{{end}}><a class="page-link" href="/search?q={{$.SearchQuery}}&page={{.}}">{{.}}</a></li> + {{end}} + {{if gt (sub .MaxPages $max) 3}} + <li class="page-item disabled"><a class="page-link" href="#">…</a></li> + <li class="page-item"><a class="page-link" href="/search?q={{.SearchQuery}}&page={{.MaxPages}}">{{.MaxPages}}</a></li> + {{end}} + {{if eq .CurrentPage .MaxPages}} + <li class="page-item disabled"> + <a class="page-link" href="#" aria-label="Next"> + <span aria-hidden="true">»</span> + </a> + {{else}} + <li class="page-item"> + <a class="page-link" href="/search?q={{.SearchQuery}}&page={{ add .CurrentPage 1 }}" aria-label="Next"> + <span aria-hidden="true">»</span> + </a> + {{end}} + </li> + </ul> + </nav> +{{end}} |