<%page args="page_obj, page_number, adjacent_size=4"/>

<div class="pagination">
    <ul>
        % if page_number - adjacent_size > 1:
            <li><a href="?page=1">1</a></li>
        % endif
        % if page_number - adjacent_size > 1 + 1:
            <li class="disabled"><a>...</a></li>
        % endif
        % for p in range(max(1, page_number - adjacent_size), min(page_obj.paginator.num_pages, page_number + adjacent_size) + 1):
            <li class="${'active' if page_number == p else ''}"><a href="?page=${p}">${p}</a></li>
        % endfor
        % if page_number + adjacent_size < page_obj.paginator.num_pages - 1:
            <li class="disabled"><a>...</a></li>
        % endif
        % if page_number + adjacent_size < page_obj.paginator.num_pages:
            <li><a href="?page=${page_obj.paginator.num_pages}">${page_obj.paginator.num_pages}</a></li>
        % endif
    </ul>
</div>
