-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
75 additions
and
5 deletions.
There are no files selected for viewing
52 changes: 52 additions & 0 deletions
52
bootstrap_paginator/templates/bootstrap_paginator/macros.jinja
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
|
||
{% macro paginator(page, get_args={}) %} | ||
{% if page.paginator.num_pages > 1 %} | ||
{% set ADJACENT_PAGES = 5 %} | ||
|
||
{% set start_page = page.number - ADJACENT_PAGES %} | ||
{% if start_page < 1 %} | ||
{% set start_page = 1 %} | ||
{% endif %} | ||
|
||
{% set end_page = page.number + ADJACENT_PAGES %} | ||
{% if end_page > page.paginator.num_pages %} | ||
{% set end_page = page.paginator.num_pages %} | ||
{% endif %} | ||
|
||
<ul class="pagination pagination-centered pagination-sm"> | ||
|
||
{% if page.has_previous %} | ||
<li><a href="{{ urlencode_plus(get_args, page=page.previous_page_number) }}">«</a></li> | ||
{% endif %} | ||
|
||
{% if start_page > 1 %} | ||
<li><a href="{{ urlencode_plus(get_args, page=1) }}">1</a></span> | ||
{% if start_page > 2 %} | ||
<li class="disabled"><a href="javascript:;">...</a></li> | ||
{% endif %} | ||
{% endif %} | ||
|
||
{% for page_number in range(start_page, end_page) %} | ||
{% if page_number == page.number %} | ||
<li class="active"><a href="javascript:;">{{ page.number }}</a></li> | ||
{% else %} | ||
<li><a href="{{ urlencode_plus(get_args, page=page_number) }}">{{ page_number }}</a></li> | ||
{% endif %} | ||
{% endfor %} | ||
|
||
{% if end_page < page.paginator.num_pages %} | ||
{% if end_page < page.paginator.num_pages - 1 %} | ||
<li class="disabled"><a href="javascript:;">...</a></li> | ||
{% endif %} | ||
<li><a href="{{ urlencode_plus(get_args, page=page.paginator.num_pages) }}"> | ||
{{ page.paginator.num_pages }} | ||
</a></li> | ||
{% endif %} | ||
|
||
{% if page.has_next %} | ||
<li><a href="{{ urlencode_plus(get_args, page=page.next_page_number) }}">»</a></li> | ||
{% endif %} | ||
|
||
</ul> | ||
{% endif %} | ||
{% endmacro %} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters