## -*- 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><a href="${nextlink}" aria-label="${messages("Older posts")}"><span aria-hidden="true">&laquo;</span></a></li>
    % else:
      <li class="disabled"><a href="#" aria-label="${messages("Older posts")}"><span aria-hidden="true">&laquo;</span></a></li>
    % endif
  % else:
    % if prevlink:
      <li><a href="${prevlink}" aria-label="${messages("Newer posts")}"><span aria-hidden="true">&laquo;</span></a></li>
    % else:
      <li class="disabled"><a href="#" 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="active"' if i == current_page else ''}><a href="${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="disabled"><a href="#" aria-label="…"><span aria-hidden="true">…</span></a></li>
    % endif
  % endfor
  % if prev_next_links_reversed:
    % if prevlink:
      <li><a href="${prevlink}" aria-label="${messages("Newer posts")}"><span aria-hidden="true">&raquo;</span></a></li>
    % else:
      <li class="disabled"><a href="#" aria-label="${messages("Newer posts")}"><span aria-hidden="true">&raquo;</span></a></li>
    % endif
  % else:
    % if nextlink:
      <li><a href="${nextlink}" aria-label="${messages("Older posts")}"><span aria-hidden="true">&raquo;</span></a></li>
    % else:
      <li class="disabled"><a href="#" aria-label="${messages("Older posts")}"><span aria-hidden="true">&raquo;</span></a></li>
    % endif
  % endif
  </ul>
</nav>
</%def>
