{% load leafage %}
<div class="row">
  {% if show_content == 'yes' %}
    <div class="col-lg-12">
      Showing {{ obj_list.start_index }}-{{ obj_list.end_index }} of {{ obj_list.paginator.count }}
    </div>
  {% endif %}
  <div class="col-lg-12">
    <nav class="my-4">
      {% if obj_list.has_other_pages %}
        <ul class="pagination pagination-circle pg-blue mb-0 float-right">
          {% if obj_list.has_previous %}
            <li class="page-item"><a class="page-link" aria-label="Previous" href="{{path}}page={{ obj_list.previous_page_number }}"><span aria-hidden="true">&laquo;</span><span class="sr-only">Previous</span></a></li>
          {% else %}
            <li class="page-item page-link disabled"><span>&laquo;</span></li>
          {% endif %}

          {% for i in obj_list.paginator.page_range %}
            {% if obj_list.number == i %}
              <li class="page-item active"><span class="page-link">{{ i }} <span class="sr-only">(current)</span></span></li>
            {% else %}

              <li class="page-item">
                <!-- For the 1st page we do not use {{path}}page=1 -->
                {% if i == 1 %}
                  <a class="page-link" href="{{path}}page={{ i }}">{{ i }}</a>

                {% else %}
                  <!-- Show current page and +-3 pages -->
                  {% if i|subtract:dot_range <= obj_list.number and obj_list.number <= i|add:dot_range %}
                    <a class="page-link" href="{{path}}page={{ i }}">{{ i }}</a>

                  <!-- Shows every 10th page and the last page -->
                  {% elif i == obj_list.paginator.num_pages %}
                    <a class="page-link" href="{{path}}page={{ i }}">{{ i }}</a>
                  {% else %}
                    {% if i == 2 or i == obj_list.paginator.num_pages|add:"-1"  %}
                      <p>...</p>
                    {% endif %}
                  {% endif %}

                {% endif %}
              </li>
            {% endif %}
          {% endfor %}

          {% if obj_list.has_next %}
            <li class="page-item"><a class="page-link" aria-label="Next" href="{{path}}page={{ obj_list.next_page_number }}"><span aria-hidden="true">&raquo;</span><span class="sr-only">Previous</span></a></li>
          {% else %}
            <li class="page-item page-link disabled"><span>&raquo;</span></li>
          </li>
          {% endif %}
        </ul>
      {% endif %}
    </nav>
  </div>
</div>
