forked from MarseyWorld/MarseyWorld
67 lines
1.9 KiB
HTML
67 lines
1.9 KiB
HTML
|
|
<nav>
|
|
<ul class="pagination pagination-sm mb-0 mt-4 pl-1">
|
|
{% set ns = namespace() %}
|
|
|
|
{% if not size %}
|
|
{% set size = PAGE_SIZE %}
|
|
{% endif %}
|
|
{% set num_pages = (total / size) | round(0, 'ceil') | int %}
|
|
|
|
{% set ns.start_point = page - 2 %}
|
|
{% if ns.start_point < 1 %}
|
|
{% set ns.start_point = 1 %}
|
|
{% endif %}
|
|
|
|
{% set end_point = ns.start_point+4 %}
|
|
{% if end_point > num_pages %}
|
|
{% set ns.start_point = ns.start_point-(end_point-num_pages) %}
|
|
{% set end_point = num_pages %}
|
|
{% endif %}
|
|
|
|
{% if ns.start_point < 1 %}
|
|
{% set ns.start_point = 1 %}
|
|
{% endif %}
|
|
|
|
|
|
{% if ns.start_point > 1 %}
|
|
<li class="page-item">
|
|
<small><a class="page-link" href="{{'page'|change_arg(1, request.full_path)|safe}}">1</a></small>
|
|
</li>
|
|
|
|
{% if ns.start_point == 3 %}
|
|
<li class="page-item">
|
|
<small><a class="page-link" href="{{'page'|change_arg(2, request.full_path)|safe}}">2</a></small>
|
|
</li>
|
|
{% elif ns.start_point != 2 %}
|
|
<li class="page-item">
|
|
<small class="page-link dots">...</small>
|
|
</li>
|
|
{% set ns.start_point = ns.start_point + 1 %}
|
|
{% endif %}
|
|
{% endif %}
|
|
|
|
{% for x in range(ns.start_point, end_point+1) %}
|
|
<li class="page-item">
|
|
<small><a class="page-link {% if x == page %}active disabled{% endif %}" href="{{'page'|change_arg(x, request.full_path)|safe}}">{{x}}</a></small>
|
|
</li>
|
|
{% endfor %}
|
|
|
|
{% if end_point < num_pages %}
|
|
{% if end_point == num_pages-2 %}
|
|
<li class="page-item">
|
|
<small><a class="page-link" href="{{'page'|change_arg(num_pages-1, request.full_path)|safe}}">{{num_pages-1}}</a></small>
|
|
</li>
|
|
{% elif end_point != num_pages-1 %}
|
|
<li class="page-item">
|
|
<small class="page-link dots">...</small>
|
|
</li>
|
|
{% endif %}
|
|
|
|
<li class="page-item">
|
|
<small><a class="page-link" href="{{'page'|change_arg(num_pages, request.full_path)|safe}}">{{num_pages}}</a></small>
|
|
</li>
|
|
{% endif %}
|
|
</ul>
|
|
</nav>
|