<% if results.total_pages > 1 %>
  <nav class="text-center" aria-label="Pagination">
    <ul class="pagination">
      <% if results.current_page.to_i != 1 %>
      <li>
        <a href="?<%= URI.encode_www_form(query.update(page: results.current_page.to_i - 1)) %>" aria-label="Previous">
          <span aria-hidden="true">&laquo;</span>
        </a>
      </li>
      <% end %>
      <% for n in results.pages%>
      <li class="<%= "active" if results.current_page.to_i == n %>">
        <% if n %>
          <a href="?<%= URI.encode_www_form(query.update(page: n)) %>"><%= n %></a>
        <% else %>
          <a>…</a>
        <% end %>
      </li>
      <% end %>
      <% if results.current_page.to_i != results.total_pages %>
      <li>
        <a href="?<%= URI.encode_www_form(query.update(page: results.current_page.to_i + 1)) %>" aria-label="Next">
          <span aria-hidden="true">&raquo;</span>
        </a>
      </li>
      <% end %>
    </ul>
  </nav>
<% end %>
