It's 2012 all up in here
[mediagoblin.git] / mediagoblin / templates / mediagoblin / utils / object_gallery.html
1 {#
2 # GNU MediaGoblin -- federated, autonomous media hosting
3 # Copyright (C) 2011, 2012 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 {% from "mediagoblin/utils/pagination.html" import render_pagination %}
20
21 {% macro media_grid(request, media_entries, col_number=5) %}
22 <table class="thumb_gallery">
23 {% for row in gridify_cursor(media_entries, col_number) %}
24 <tr class="thumb_row
25 {%- if loop.first %} thumb_row_first
26 {%- elif loop.last %} thumb_row_last{% endif %}">
27 {% for entry in row %}
28 {% set entry_url = entry.url_for_self(request.urlgen) %}
29 <td class="media_thumbnail thumb_entry
30 {%- if loop.first %} thumb_entry_first
31 {%- elif loop.last %} thumb_entry_last{% endif %}">
32 <a href="{{ entry_url }}">
33 <img src="{{ request.app.public_store.file_url(
34 entry.media_files['thumb']) }}" />
35 </a>
36 {% if entry.title %}
37 <br />
38 <a href="{{ entry_url }}">{{ entry.title }}</a>
39 {% endif %}
40 </td>
41 {% endfor %}
42 </tr>
43 {% endfor %}
44 </table>
45 {%- endmacro %}
46
47 {#
48 Render a media gallery with pagination.
49
50 Args:
51 - request: Request
52 - media_entries: pymongo cursor of media entries
53 - pagination: Paginator object
54 - pagination_base_url: If you want the pagination to point to a
55 different URL, point it here
56 - col_number: How many columns per row (default 5)
57 #}
58 {% macro object_gallery(request, media_entries, pagination,
59 pagination_base_url=None, col_number=5) %}
60 {% if media_entries and media_entries.count() %}
61 {{ media_grid(request, media_entries, col_number=col_number) }}
62 <div class="clear"></div>
63 {% if pagination_base_url %}
64 {# different url, so set that and don't keep the get params #}
65 {{ render_pagination(request, pagination, pagination_base_url, False) }}
66 {% else %}
67 {{ render_pagination(request, pagination) }}
68 {% endif %}
69 {% else %}
70 <p>
71 <i>
72 {%- trans -%}
73 There doesn't seem to be any media here yet...
74 {%- endtrans -%}
75 </i>
76 </p>
77 {% endif %}
78 {% endmacro %}