A new Riff-radio.org site with a static approach.

pagination_helper.tmpl 2.0KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. ## -*- coding: utf-8 -*-
  2. <%def name="page_navigation(current_page, page_links, prevlink, nextlink, prev_next_links_reversed, surrounding=5)">
  3. <nav aria-label="Page navigation">
  4. <ul class="pagination">
  5. % if prev_next_links_reversed:
  6. % if nextlink:
  7. <li><a href="${nextlink}" aria-label="${messages("Older posts")}"><span aria-hidden="true">&laquo;</span></a></li>
  8. % else:
  9. <li class="disabled"><a href="#" aria-label="${messages("Older posts")}"><span aria-hidden="true">&laquo;</span></a></li>
  10. % endif
  11. % else:
  12. % if prevlink:
  13. <li><a href="${prevlink}" aria-label="${messages("Newer posts")}"><span aria-hidden="true">&laquo;</span></a></li>
  14. % else:
  15. <li class="disabled"><a href="#" aria-label="${messages("Newer posts")}"><span aria-hidden="true">&laquo;</span></a></li>
  16. % endif
  17. % endif
  18. % for i, link in enumerate(page_links):
  19. % if abs(i - current_page) <= surrounding or i == 0 or i == len(page_links) - 1:
  20. <li ${' class="active"' if i == current_page else ''}><a href="${link}">${i + 1}${' <span class="sr-only">(current)</span>' if i == current_page else ''}</a></li>
  21. % elif i == current_page - surrounding - 1 or i == current_page + surrounding + 1:
  22. <li class="disabled"><a href="#" aria-label="…"><span aria-hidden="true">…</span></a></li>
  23. % endif
  24. % endfor
  25. % if prev_next_links_reversed:
  26. % if prevlink:
  27. <li><a href="${prevlink}" aria-label="${messages("Newer posts")}"><span aria-hidden="true">&raquo;</span></a></li>
  28. % else:
  29. <li class="disabled"><a href="#" aria-label="${messages("Newer posts")}"><span aria-hidden="true">&raquo;</span></a></li>
  30. % endif
  31. % else:
  32. % if nextlink:
  33. <li><a href="${nextlink}" aria-label="${messages("Older posts")}"><span aria-hidden="true">&raquo;</span></a></li>
  34. % else:
  35. <li class="disabled"><a href="#" aria-label="${messages("Older posts")}"><span aria-hidden="true">&raquo;</span></a></li>
  36. % endif
  37. % endif
  38. </ul>
  39. </nav>
  40. </%def>