|
|
@ -20,6 +20,76 @@ |
|
|
|
{% endfor %} |
|
|
|
{% endfor %} |
|
|
|
{% endif %} |
|
|
|
{% endif %} |
|
|
|
</div> |
|
|
|
</div> |
|
|
|
<section> |
|
|
|
</section> |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<!-- Pagination --> |
|
|
|
|
|
|
|
{% comment %} |
|
|
|
|
|
|
|
Обработка пагинации построена на проверке условий: первые страницы, |
|
|
|
|
|
|
|
последние страницы, страницы в середине большого кол-ва страниц, малое |
|
|
|
|
|
|
|
количество страниц. Для каждого случая - свой код. Также требуются |
|
|
|
|
|
|
|
перменные: current_page (текущая страница) и объект paginator. |
|
|
|
|
|
|
|
{% endcomment %} |
|
|
|
|
|
|
|
<section class="section"> |
|
|
|
|
|
|
|
<nav class="pagination is-centered" role="navigation" aria-label="pagination"> |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
{% if paginator.num_pages <= 5 %} |
|
|
|
|
|
|
|
<ul class="pagination-list"> |
|
|
|
|
|
|
|
{% for pnum in paginator.page_range %} |
|
|
|
|
|
|
|
{% if pnum == current_page %} |
|
|
|
|
|
|
|
<li><a class="pagination-link is-current" aria-label="На страницу {{pnum}}" aria-current="page" href={% url 'posts:page' pnum %}>{{pnum}}</a></li> |
|
|
|
|
|
|
|
{% else %} |
|
|
|
|
|
|
|
<li><a class="pagination-link" aria-label="На страницу {{pnum}}" aria-current="page" href={% url 'posts:page' pnum %}>{{pnum}}</a></li> |
|
|
|
|
|
|
|
{% endif %} |
|
|
|
|
|
|
|
{% endfor %} |
|
|
|
|
|
|
|
</ul> |
|
|
|
|
|
|
|
{% endif %} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
{% if paginator.num_pages > 5 %} |
|
|
|
|
|
|
|
<ul class="pagination-list"> |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
{# навигация в середине диапазона страниц, когда есть центральные, а до краев еще далеко #} |
|
|
|
|
|
|
|
{% if current_page > 3 and current_page < paginator.num_pages|add:-3 %} |
|
|
|
|
|
|
|
<li><a class="pagination-link" aria-label="На страницу 1" href={% url 'posts:page' 1 %}>1</a></li> |
|
|
|
|
|
|
|
<li><span class="pagination-ellipsis">…</span></li> |
|
|
|
|
|
|
|
<li><a class="pagination-link" aria-label="На страницу {{ current_page|add:-1 }}" aria-current="page" href={% url 'posts:page' current_page|add:-1 %}>{{ current_page|add:-1 }}</a></li> |
|
|
|
|
|
|
|
<li><a class="pagination-link is-current" aria-label="На страницу {{current_page}}" aria-current="page" href={% url 'posts:page' current_page %}>{{ current_page }}</a></li> |
|
|
|
|
|
|
|
<li><a class="pagination-link" aria-label="На страницу {{ current_page|add:1 }}" aria-current="page" href={% url 'posts:page' current_page|add:1 %}>{{ current_page|add:1 }}</a></li> |
|
|
|
|
|
|
|
<li><span class="pagination-ellipsis">…</span></li> |
|
|
|
|
|
|
|
<li><a class="pagination-link" aria-label="На страницу {{ paginator.num_pages }}">{{ paginator.num_pages }}</a></li> |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
{# навигация на первых страницах (левый граничный случай) #} |
|
|
|
|
|
|
|
{% elif current_page <= 3 and current_page <= paginator.num_pages %} |
|
|
|
|
|
|
|
{% for pnum in paginator.page_range|slice:":5" %} |
|
|
|
|
|
|
|
{% if pnum == current_page %} |
|
|
|
|
|
|
|
<li><a class="pagination-link is-current" aria-label="На страницу {{pnum}}" aria-current="page" href={% url 'posts:page' pnum %}>{{ pnum }}</a></li> |
|
|
|
|
|
|
|
{% else %} |
|
|
|
|
|
|
|
<li><a class="pagination-link" aria-label="На страницу {{pnum}}" aria-current="page" href={% url 'posts:page' pnum %}>{{ pnum }}</a></li> |
|
|
|
|
|
|
|
{% endif %} |
|
|
|
|
|
|
|
{% endfor %} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<li><span class="pagination-ellipsis">…</span></li> |
|
|
|
|
|
|
|
<li><a class="pagination-link" aria-label="На страницу {{paginator.num_pages}}" href={% url 'posts:page' paginator.num_pages %}>{{paginator.num_pages}}</a></li> |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
{# навигация на последних страницах (правый граничный случай) #} |
|
|
|
|
|
|
|
{% elif current_page > 2 and current_page <= paginator.num_pages %} |
|
|
|
|
|
|
|
<li><a class="pagination-link" aria-label="На страницу 1" href={% url 'posts:page' 1 %}>1</a></li> |
|
|
|
|
|
|
|
<li><span class="pagination-ellipsis">…</span></li> |
|
|
|
|
|
|
|
{% for pnum in paginator.page_range|slice:"-5:" %} |
|
|
|
|
|
|
|
{% if pnum == current_page %} |
|
|
|
|
|
|
|
<li><a class="pagination-link is-current" aria-label="На страницу {{pnum}}" aria-current="page" href={% url 'posts:page' pnum %}>{{ pnum }}</a></li> |
|
|
|
|
|
|
|
{% else %} |
|
|
|
|
|
|
|
<li><a class="pagination-link" aria-label="На страницу {{pnum}}" aria-current="page" href={% url 'posts:page' pnum %}>{{ pnum }}</a></li> |
|
|
|
|
|
|
|
{% endif %} |
|
|
|
|
|
|
|
{% endfor %} |
|
|
|
|
|
|
|
{% endif %} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
</ul> |
|
|
|
|
|
|
|
{% endif %} |
|
|
|
|
|
|
|
</nav> |
|
|
|
|
|
|
|
</section> |
|
|
|
{% endautoescape %} |
|
|
|
{% endautoescape %} |
|
|
|
{% endblock %} |
|
|
|
{% endblock %} |
|
|
|