Merge branch 'master' of gitorious.org:mediagoblin/mediagoblin
[mediagoblin.git] / mediagoblin / templates / mediagoblin / utils / object_gallery.html
1 {#
2 # GNU MediaGoblin -- federated, autonomous media hosting
3 # Copyright (C) 2011 Free Software Foundation, Inc
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 <td class="media_thumbnail thumb_entry
29 {%- if loop.first %} thumb_entry_first
30 {%- elif loop.last %} thumb_entry_last{% endif %}">
31 <a href="{{ entry.url_for_self(request.urlgen) }}">
32 <img src="{{ request.app.public_store.file_url(
33 entry['media_files']['thumb']) }}" />
34 </a>
35 </td>
36 {% endfor %}
37 </tr>
38 {% endfor %}
39 </table>
40 {%- endmacro %}
41
42 {#
43 Render a media gallery with pagination.
44
45 Args:
46 - request: Request
47 - media_entries: pymongo cursor of media entries
48 - pagination: Paginator object
49 - pagination_base_url: If you want the pagination to point to a
50 different URL, point it here
51 - col_number: How many columns per row (default 5)
52 #}
53 {% macro object_gallery(request, media_entries, pagination,
54 pagination_base_url=None, col_number=5) %}
55 {% if media_entries and media_entries.count() %}
56 {{ media_grid(request, media_entries, col_number=col_number) }}
57 <div class="clear"></div>
58 {% if pagination_base_url %}
59 {# different url, so set that and don't keep the get params #}
60 {{ render_pagination(request, pagination, pagination_base_url, False) }}
61 {% else %}
62 {{ render_pagination(request, pagination) }}
63 {% endif %}
64 {% else %}
65 <p>
66 <i>There doesn't seem to be any media here yet...</i>
67 </p>
68 {% endif %}
69 {% endmacro %}