{% macro render_pagination(page_obj, url, ul_class='', sort_by=None, asc=True) %} {% endmacro %} {% macro render_topic_pagination(page_obj, url) %} {% endmacro %} {% macro message_pagination(page_obj, url) %} {% endmacro %} {# Generates a some kind of pagination for the posts in topic in the forum view. #} {%- macro topic_pages(topic_obj, per_page=10) -%} {% set pages = (topic_obj.post_count / per_page)|round(method='ceil')|int %} {% set max_pages = 4 %} {% set page_count = pages if pages <= max_pages else max_pages %} {%- if pages > 1 -%} [ {%- for page in range(1, page_count+1) -%} {% if pages > max_pages and page == max_pages-1 %} {{ page }} ... {% elif pages > max_pages and loop.last %} {{ pages }} {% else %} {{ page }} {% endif %} {%- endfor -%} ] {%- endif -%} {%- endmacro -%} {# Generates a topic url with an anchor to the post XXX: Rename to generate_anchor_url to make it universally useful #} {%- macro generate_post_url(topic, post, page) -%} {%- if page > 1 -%} {{ topic.url }}?page={{ page }}#pid{{ post.id }} {%- else -%} {{ topic.url }}#pid{{ post.id }} {%- endif -%} {%- endmacro -%} {# Generates the pagination object id in a list. For example, on id should continue with 11 on page 2 if per_page is set to 10 #} {%- macro generate_obj_id(obj, page, per_page) -%} {%- if obj.page == 1 -%} {{ page }} {%- else -%} {{ page + (obj.page - 1) * per_page }} {%- endif -%} {%- endmacro -%}