{% load i18n %}

{% if is_paginated %}
    <nav>
        <ul class="pagination{% if size %} pagination-{{ size }}{% endif %}">
            {% if page_obj.has_previous %}
                <li class="previous">
                    <a href="?{{ page_obj.previous_page_number.querystring }}" aria-label="{% trans 'previous page' %}">
                        <span aria-hidden="true">&laquo;</span>
                        {% if verbose %}<span class="hidden-xs">{% trans 'previous page' %}</span>{% endif %}
                    </a>
                </li>
            {% else %}
                <li class="previous disabled">
                    <span>
                        <span aria-hidden="true">&laquo;</span>
                        {% if verbose %}<span class="hidden-xs">{% trans 'previous page' %}</span>{% endif %}
                    </span>
                </li>
            {% endif %}

            {% for page in page_obj.pages %}
                {% if page %}
                    {% if page == page_obj.number %}
                        <li class="active">
                            <a href="?{{ page.querystring }}">{{ page }} <span class="sr-only">({% trans 'current page' %})</span></a>
                        </li>
                    {% else %}
                        <li>
                            <a href="?{{ page.querystring }}">{{ page }}</a>
                        </li>
                    {% endif %}
                {% else %}
                    <li class="disabled">
                        <span>...</span>
                    </li>
                {% endif %}
            {% endfor %}

            {% if page_obj.has_next %}
                <li class="next">
                    <a href="?{{ page_obj.next_page_number.querystring }}" aria-label="{% trans 'next page' %}">
                        {% if verbose %}<span class="hidden-xs">{% trans 'next page' %}</span>{% endif %}
                        <span aria-hidden="true">&raquo;</span>
                    </a>
                </li>
            {% else %}
                <li class="next disabled">
                    <span>
                        {% if verbose %}<span class="hidden-xs">{% trans 'next page' %}</span>{% endif %}
                        <span aria-hidden="true">&raquo;</span>
                    </span>
                </li>
            {% endif %}
        </ul>
    </nav>
{% endif %}
