2 # GNU MediaGoblin -- federated, autonomous media hosting
3 # Copyright (C)
2011 MediaGoblin contributors. See AUTHORS.
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.
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.
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
/>.
19 {% from
"mediagoblin/utils/pagination.html" import render_pagination %}
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) %}
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']) }}" />
38 <a href=
"{{ entry_url }}">{{ entry.title }}
</a>
48 Render a media gallery with pagination.
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)
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) }}
67 {{ render_pagination(request, pagination) }}
73 There doesn't seem to be any media here yet...