56 lines
2.0 KiB
HTML
56 lines
2.0 KiB
HTML
|
<nav class="nextprev">
|
||
|
{%- set ns.limit = limit -%}
|
||
|
{%- if ns.limit == 0 or ns.limit == 10 -%}
|
||
|
{%- set ns.limit = None -%}
|
||
|
{%- endif -%}
|
||
|
|
||
|
{%- set ns.prev = start-limit -%}
|
||
|
{%- if ns.prev == 0-%}
|
||
|
{%- set ns.prev = None -%}
|
||
|
{%- endif -%}
|
||
|
|
||
|
{%- set ns.next = start+limit -%}
|
||
|
{%- if ns.next == 0-%}
|
||
|
{%- set ns.next = None -%}
|
||
|
{%- endif -%}
|
||
|
|
||
|
{%- set ns.start = start -%}
|
||
|
{%- if ns.start == 0-%}
|
||
|
{%- set ns.start = None -%}
|
||
|
{%- endif -%}
|
||
|
|
||
|
{%- set thispage = (start / limit)|round(0,'floor')|int + 1 -%}
|
||
|
{%- set totalpages = (ns.total / limit)|round(0,'ceil')|int -%}
|
||
|
{%- set ns.ellipsis = False -%}
|
||
|
|
||
|
{% if thispage > 1 %}
|
||
|
<span class="first"><a href="{{ url_for(request.endpoint, title=title, year=year, start=None, limit=ns.limit) }}">« First</a></span>
|
||
|
{% if (start-limit) > 1 %}
|
||
|
<span class="prev"><a href="{{ url_for(request.endpoint, title=title, year=year, start=ns.prev, limit=ns.limit) }}">< Prev</a></span>
|
||
|
{% endif %}
|
||
|
{% endif %}
|
||
|
|
||
|
{% for page in range(1, totalpages+1) %}
|
||
|
{% if page < 4 or page > (totalpages+1-4) or (page > (thispage-3) and page < (thispage+3)) %}
|
||
|
{%- if page != thispage -%}
|
||
|
<span class="nav link"><a href="{{ url_for(request.endpoint, title=title, year=year, start=(page-1)*limit, limit=ns.limit) }}">{{ page }}</a></span>
|
||
|
{%- else -%}
|
||
|
<span class="nav plain"><strong>{{ page }}</strong></span>
|
||
|
{%- endif %}
|
||
|
{%- set ns.ellipsis = False -%}
|
||
|
{%- else -%}
|
||
|
{%- if not ns.ellipsis -%}
|
||
|
<span class="nav plain">…</span>
|
||
|
{%- endif -%}
|
||
|
{%- set ns.ellipsis = True -%}
|
||
|
{% endif %}
|
||
|
{% endfor %}
|
||
|
|
||
|
{% if thispage < totalpages %}
|
||
|
{% if (start+limit) != (totalpages-1)*limit %}
|
||
|
<span class="next"><a href="{{ url_for(request.endpoint, title=title, year=year, start=ns.next, limit=ns.limit) }}">Next ></a></span>
|
||
|
{% endif %}
|
||
|
<span class="last"><a href="{{ url_for(request.endpoint, title=title, year=year, start=(totalpages-1)*limit, limit=ns.limit) }}">Last »</a></span>
|
||
|
{% endif %}
|
||
|
</nav>
|