AACResults/templates/prevnext.html
2018-08-14 11:02:56 +02:00

50 lines
2.0 KiB
HTML

<nav class="nextprev">
{%- set ns.prev = getstart - getshow -%}
{%- if ns.prev == 0 -%}
{%- set ns.prev = None -%}
{%- endif -%}
{%- set ns.next = getstart + getshow -%}
{%- if ns.next == 0 -%}
{%- set ns.next = None -%}
{%- endif -%}
{%- set thispage = (getstart / getshow)|round(0,'floor')|int + 1 -%}
{%- set totalpages = (ns.total / getshow)|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, show=ns.show, **ns.query) }}">&laquo; First</a></span>
{% if (getstart - getshow) > 1 %}
<span class="prev"><a href="{{ url_for(request.endpoint, title=title, year=year, start=ns.prev, show=ns.show, **ns.query) }}">&lsaquo; 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 -%}
{% set goto = (page - 1) * getshow %}
{%- if goto == 0 -%}
{%- set goto = None -%}
{%- endif -%}
<span class="nav link"><a href="{{ url_for(request.endpoint, title=title, year=year, start=goto, show=ns.show, **ns.query) }}">{{ 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 (getstart + getshow) != (totalpages - 1) * getshow %}
<span class="next"><a href="{{ url_for(request.endpoint, title=title, year=year, start=ns.next, show=ns.show, **ns.query) }}">Next &rsaquo;</a></span>
{% endif %}
<span class="last"><a href="{{ url_for(request.endpoint, title=title, year=year, start=(totalpages - 1) * getshow, show=ns.show, **ns.query) }}">Last &raquo;</a></span>
{% endif %}
</nav>