2 # GNU MediaGoblin -- federated, autonomous media hosting
3 # Copyright (C)
2011,
2012 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, collection_items, col_number=
5) %}
22 <table class=
"thumb_gallery">
23 {% for row in gridify_cursor(collection_items, col_number) %}
25 {%- if loop.first %} thumb_row_first
26 {%- elif loop.last %} thumb_row_last{% endif %}">
28 {% set media_entry = item.get_media_entry %}
29 {% set entry_url = media_entry.url_for_self(request.urlgen) %}
30 <td class=
"collection_thumbnail thumb_entry
31 {%- if loop.first %} thumb_entry_first
32 {%- elif loop.last %} thumb_entry_last{% endif %}">
33 <a href=
"{{ entry_url }}">
34 <img src=
"{{ media_entry.thumb_url }}" />
38 {%- trans note=item.note -%}
40 <a href=
"{{ entry_url }}">{{ note }}
</a>
43 {% if request.user and
44 (item.in_collection.creator == request.user._id or
45 request.user.is_admin) %}
46 {%- trans remove_url=request.urlgen(
47 'mediagoblin.user_pages.collection_item_confirm_remove',
48 user=item.in_collection.get_creator.username,
49 collection=item.in_collection.slug,
50 collection_item=item.id) -%}
51 <br /><a href=
"{{ remove_url }}" class=
"remove">(remove)
</a>
62 Render a media gallery with pagination.
66 - collection_items: cursor of collection items
67 - pagination: Paginator object
68 - pagination_base_url: If you want the pagination to point to a
69 different URL, point it here
70 - col_number: How many columns per row (default
5)
72 {% macro collection_gallery(request, collection_items, pagination,
73 pagination_base_url=None, col_number=
5) %}
74 {% if collection_items and collection_items.count() %}
75 {{ media_grid(request, collection_items, col_number=col_number) }}
76 <div class=
"clear"></div>
77 {% if pagination_base_url %}
78 {# different url, so set that and don't keep the get params #}
79 {{ render_pagination(request, pagination, pagination_base_url, False) }}
81 {{ render_pagination(request, pagination) }}
87 There doesn't seem to be any media here yet...