personal-website/themes/custom/templates/pagination_helper.tmpl

41 lines
2.3 KiB
Cheetah
Raw Normal View History

2018-03-07 15:38:00 +00:00
## -*- coding: utf-8 -*-
<%def name="page_navigation(current_page, page_links, prevlink, nextlink, prev_next_links_reversed, surrounding=5)">
<nav aria-label="Page navigation">
<ul class="pagination">
% if prev_next_links_reversed:
% if nextlink:
<li class="page-item"><a href="${nextlink}" class="page-link" aria-label="${messages("Older posts")}"><span aria-hidden="true">&laquo;</span></a></li>
% else:
<li class="page-item disabled"><a href="#" class="page-link" aria-label="${messages("Older posts")}"><span aria-hidden="true">&laquo;</span></a></li>
% endif
% else:
% if prevlink:
<li class="page-item"><a href="${prevlink}" class="page-link" aria-label="${messages("Newer posts")}"><span aria-hidden="true">&laquo;</span></a></li>
% else:
<li class="page-item disabled"><a href="#" class="page-link" aria-label="${messages("Newer posts")}"><span aria-hidden="true">&laquo;</span></a></li>
% endif
% endif
% for i, link in enumerate(page_links):
% if abs(i - current_page) <= surrounding or i == 0 or i == len(page_links) - 1:
<li class="page-item ${'active' if i == current_page else ''}"><a href="${link}" class="page-link">${i + 1}${' <span class="sr-only">(current)</span>' if i == current_page else ''}</a></li>
% elif i == current_page - surrounding - 1 or i == current_page + surrounding + 1:
<li class="page-item disabled"><a href="#" class="page-link" aria-label="…"><span aria-hidden="true">…</span></a></li>
% endif
% endfor
% if prev_next_links_reversed:
% if prevlink:
<li class="page-item"><a href="${prevlink}" class="page-link" aria-label="${messages("Newer posts")}"><span aria-hidden="true">&raquo;</span></a></li>
% else:
<li class="page-item disabled"><a href="#" class="page-link" aria-label="${messages("Newer posts")}"><span aria-hidden="true">&raquo;</span></a></li>
% endif
% else:
% if nextlink:
<li class="page-item"><a href="${nextlink}" class="page-link" aria-label="${messages("Older posts")}"><span aria-hidden="true">&raquo;</span></a></li>
% else:
<li class="page-item disabled"><a href="#" class="page-link" aria-label="${messages("Older posts")}"><span aria-hidden="true">&raquo;</span></a></li>
% endif
% endif
</ul>
</nav>
</%def>