mirror of https://github.com/PurpleI2P/regi2p.git
Domain registry project
http://reg.i2p/
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
60 lines
3.4 KiB
60 lines
3.4 KiB
{% macro pagination(total, current, url, nearbyPagesLimit = 4) %} |
|
|
|
{# Create "main_url" variable with link for the first page #} |
|
{% set foo = url|split('/') %} |
|
{% set foo = foo|slice(0, -1) %} |
|
{% set main_url = foo|join('/') ~ "/" %} |
|
|
|
{% apply spaceless %} |
|
{% if total > 1 %} |
|
<div class="row"> |
|
<nav> |
|
<ul class="pagination"> |
|
{% if current > 1 %} |
|
<li class="pagination__item pagination__item_arrow"> |
|
<a class="prev pagination__link pagination__link_arrow pagination__link_arrow_prev" href="{{ (url ~ (current-1))|e }}">«</a> |
|
</li> |
|
{% endif %} |
|
|
|
{% for i in 1..total %} |
|
{% if 0 == (current - nearbyPagesLimit) - loop.index %} |
|
<li class="pagination__item"> |
|
<a href="{{ (url ~ 1)|e }}" class="pagination__link">1 |
|
</a> |
|
</li> |
|
{% if 1 != loop.index %} |
|
<li class="pagination__item"> |
|
<a href="#" class="pagination__link"><span>...</span> |
|
</a> |
|
</li> |
|
{% endif %} |
|
{% elseif 0 == (current + nearbyPagesLimit) - loop.index and (current + nearbyPagesLimit) < total %} |
|
<li class="pagination__item pagination__item_see-more"><a href="#" class=" pagination__link_see-more pagination__link"><span>...</span></a></li> |
|
{% elseif 0 < (current - nearbyPagesLimit) - loop.index %} |
|
{% elseif 0 > (current + nearbyPagesLimit) - loop.index %} |
|
{% else %} |
|
{% if current == loop.index %} |
|
<li class="active pagination__item pagination__item_active"><a href="#" class="pagination__link"><span aria-current="page">{{ loop.index }}</span></a></li> |
|
{% else %} |
|
{% if loop.index == 1 %} |
|
<li class="pagination__item"><a href="{{ main_url }}" class="pagination__link">{{ loop.index }}</a></li> |
|
{% else %} |
|
<li class="pagination__item"><a href="{{ url ~ loop.index }}" class="pagination__link">{{ loop.index }}</a></li> |
|
{% endif %} |
|
{% endif %} |
|
{% endif %} |
|
{% endfor %} |
|
{% if current != total and (current + nearbyPagesLimit) < total %} |
|
<li class="pagination__item"><a href="{{ (url ~ total)|e }}" class="pagination__link">{{ total }}</a></li> |
|
{% endif %} |
|
{% if current < total %} |
|
<li class="pagination__item pagination__item_arrow"><a class="next pagination__link pagination__link_arrow pagination__link_arrow_next" href="{{ (url ~ (current+1))|e }}">»</a></li> |
|
{% endif %} |
|
</ul> |
|
</nav> |
|
</div> |
|
{% endif %} |
|
{% endapply %} |
|
{% endmacro %} |
|
|
|
{{ _self.pagination(total, current, url) }}
|
|
|