{% comment %}

Expects:
 * request, the request object.
 * page_obj, a DiggPaginator instance.
{% endcomment %}


{% if page_obj.paginator.num_pages > 1 %}
    {% load ditto_core %}
    <nav>
        <ul class="pagination">
            {% if page_obj.has_previous %}
                <li class="page-item">
                    <a class="page-link" href="?{% query_string 'p' page_obj.previous_page_number %}" aria-label="Previous">
                        <span aria-hidden="true">&larr;</span>
                        <span class="sr-only">Previous</span>
                    </a>
                </li>
            {% else %}
                <li class="page-item disabled">
                    <span class="page-link" aria-label="Previous">
                        <span aria-hidden="true">&larr;</span>
                        <span class="sr-only">Previous</span>
                    </span>
                </li>
            {% endif %}

            {% for p in page_obj.page_range %}
                {% if not p %}
                    <li class="page-item disabled">
                        <span class="page-link">
                            <span aria-hidden="true">…</span>
                            <span class="sr-only">(more pages)</span>
                        </span>
                    </li>
                {% elif p == page_obj.number %}
                    <li class="page-item active">
                        <a class="page-link" href="#">{{ p }} <span class="sr-only">(current)</span></a>
                    </li>
                {% else %}
                    <li class="page-item">
                        <a class="page-link" href="?{% query_string 'p' p %}">{{ p }}</a>
                    </li>
                {% endif %}
            {% endfor %}

            {% if page_obj.has_next %}
                <li class="page-item">
                    <a class="page-link" href="?{% query_string 'p' page_obj.next_page_number %}" aria-label="Next">
                        <span aria-hidden="true">&rarr;</span>
                        <span class="sr-only">Next</span>
                    </a>
                </li>
            {% else %}
                <li class="page-item disabled">
                    <span class="page-link" aria-label="Next">
                        <span aria-hidden="true">&rarr;</span>
                        <span class="sr-only">Next</span>
                    </span>
                </li>
            {% endif %}
        </ul>
    </nav>
{% endif %}
