AACResults/templates/prevnext.html

56 lines
2.0 KiB
HTML
Raw Normal View History

2018-08-14 08:55:34 +00:00
<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) }}">&laquo; 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) }}">&lt; 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">&hellip;</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 &gt;</a></span>
{% endif %}
<span class="last"><a href="{{ url_for(request.endpoint, title=title, year=year, start=(totalpages-1)*limit, limit=ns.limit) }}">Last &raquo;</a></span>
{% endif %}
</nav>