Commit | Line | Data |
---|---|---|
12a100e4 WKG |
1 | {# |
2 | # GNU MediaGoblin -- federated, autonomous media hosting | |
cf29e8a8 | 3 | # Copyright (C) 2011, 2012 MediaGoblin contributors. See AUTHORS. |
ae85ed0f BK |
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 | ||
5949be9a CAW |
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 %} | |
05788ef4 | 24 | {% set base_url = request.full_path %} |
5949be9a | 25 | {% endif %} |
ae85ed0f | 26 | |
5949be9a CAW |
27 | {% if preserve_get_params %} |
28 | {% set get_params = request.GET %} | |
29 | {% else %} | |
30 | {% set get_params = {} %} | |
31 | {% endif %} | |
ca3ca51c | 32 | |
5949be9a CAW |
33 | <div class="pagination"> |
34 | <p> | |
35 | {% if pagination.has_prev %} | |
8775f68d CAW |
36 | {% set prev_url = pagination.get_page_url_explicit( |
37 | base_url, get_params, | |
38 | pagination.page - 1) %} | |
4ad9ac5a | 39 | <a href="{{ prev_url }}">{% trans %}← Newer{% endtrans %}</a> |
5949be9a | 40 | {% endif %} |
0a45fa59 | 41 | {% if pagination.has_next %} |
8775f68d CAW |
42 | {% set next_url = pagination.get_page_url_explicit( |
43 | base_url, get_params, | |
44 | pagination.page + 1) %} | |
4ad9ac5a | 45 | <a href="{{ next_url }}">{% trans %}Older →{% endtrans %}</a> |
0a45fa59 JS |
46 | {% endif %} |
47 | <br /> | |
a3663b40 | 48 | {% trans %}Go to page:{% endtrans %} |
5949be9a CAW |
49 | {%- for page in pagination.iter_pages() %} |
50 | {% if page %} | |
51 | {% if page != pagination.page %} | |
52 | <a href="{{ pagination.get_page_url_explicit( | |
53 | base_url, get_params, | |
54 | page) }}">{{ page }}</a> | |
55 | {% else %} | |
56 | {{ page }} | |
57 | {% endif %} | |
ca3ca51c | 58 | {% else %} |
5949be9a | 59 | <span class="ellipsis">…</span> |
ca3ca51c | 60 | {% endif %} |
5949be9a | 61 | {%- endfor %} |
5949be9a CAW |
62 | </p> |
63 | </div> | |
64 | {% endif %} | |
65 | {% endmacro %} |