508. Updates copyright/license information
[mediagoblin.git] / mediagoblin / templates / mediagoblin / utils / pagination.html
1 {#
2 # GNU MediaGoblin -- federated, autonomous media hosting
3 # Copyright (C) 2011 MediaGoblin contributors. See AUTHORS.
4 #
5 # This program is free software: you can redistribute it and/or modify
6 # it under the terms of the GNU Affero General Public License as published by
7 # the Free Software Foundation, either version 3 of the License, or
8 # (at your option) any later version.
9 #
10 # This program is distributed in the hope that it will be useful,
11 # but WITHOUT ANY WARRANTY; without even the implied warranty of
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 # GNU Affero General Public License for more details.
14 #
15 # You should have received a copy of the GNU Affero General Public License
16 # along with this program. If not, see <http://www.gnu.org/licenses/>.
17 #}
18
19 {% macro render_pagination(request, pagination,
20 base_url=None, preserve_get_params=True) %}
21 {# only display if {{pagination}} is defined #}
22 {% if pagination and pagination.pages > 1 %}
23 {% if not base_url %}
24 {% set base_url = request.path_info %}
25 {% endif %}
26
27 {% if preserve_get_params %}
28 {% set get_params = request.GET %}
29 {% else %}
30 {% set get_params = {} %}
31 {% endif %}
32
33 <div class="pagination">
34 <p>
35 {% if pagination.has_prev %}
36 <a href="{{ pagination.get_page_url_explicit(
37 base_url, get_params,
38 pagination.page - 1) }}"><img class="pagination_arrow" src="/mgoblin_static/images/pagination_left.png" alt="Previous page" />Newer</a>
39 {% endif %}
40 {% if pagination.has_next %}
41 <a href="{{ pagination.get_page_url_explicit(
42 base_url, get_params,
43 pagination.page + 1) }}">Older<img class="pagination_arrow" src="/mgoblin_static/images/pagination_right.png" alt="Next page" />
44 </a>
45 {% endif %}
46 <br />
47 Go to page:
48 {%- for page in pagination.iter_pages() %}
49 {% if page %}
50 {% if page != pagination.page %}
51 <a href="{{ pagination.get_page_url_explicit(
52 base_url, get_params,
53 page) }}">{{ page }}</a>
54 {% else %}
55 {{ page }}
56 {% endif %}
57 {% else %}
58 <span class="ellipsis"></span>
59 {% endif %}
60 {%- endfor %}
61 </p>
62 </div>
63 {% endif %}
64 {% endmacro %}