Commit | Line | Data |
---|---|---|
a0fdc00f AW |
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, collection_items, col_number=5) %} | |
22 | <table class="thumb_gallery"> | |
2222278d | 23 | {% for row in collection_items|batch(col_number) %} |
a0fdc00f AW |
24 | <tr class="thumb_row |
25 | {%- if loop.first %} thumb_row_first | |
26 | {%- elif loop.last %} thumb_row_last{% endif %}"> | |
27 | {% for item in row %} | |
28 | {% set media_entry = item.get_media_entry %} | |
29 | {% set entry_url = media_entry.url_for_self(request.urlgen) %} | |
98b92725 | 30 | <td class="media_thumbnail thumb_entry |
a0fdc00f AW |
31 | {%- if loop.first %} thumb_entry_first |
32 | {%- elif loop.last %} thumb_entry_last{% endif %}"> | |
33 | <a href="{{ entry_url }}"> | |
2e4ad359 | 34 | <img src="{{ media_entry.thumb_url }}" /> |
a0fdc00f | 35 | </a> |
2e4ad359 | 36 | |
a0fdc00f | 37 | {% if item.note %} |
32255ec0 | 38 | <a href="{{ entry_url }}">{{ item.note }}</a> |
a0fdc00f AW |
39 | {% endif %} |
40 | {% if request.user and | |
5c2b8486 | 41 | (item.in_collection.creator == request.user.id or |
a0fdc00f | 42 | request.user.is_admin) %} |
32255ec0 | 43 | {%- set remove_url=request.urlgen( |
a0fdc00f AW |
44 | 'mediagoblin.user_pages.collection_item_confirm_remove', |
45 | user=item.in_collection.get_creator.username, | |
46 | collection=item.in_collection.slug, | |
47 | collection_item=item.id) -%} | |
32255ec0 E |
48 | <a href="{{ remove_url }}" class="remove"> |
49 | {%- trans %}(remove){% endtrans -%} | |
50 | </a> | |
a0fdc00f AW |
51 | {% endif %} |
52 | </td> | |
53 | {% endfor %} | |
54 | </tr> | |
55 | {% endfor %} | |
56 | </table> | |
57 | {%- endmacro %} | |
58 | ||
59 | {# | |
60 | Render a media gallery with pagination. | |
61 | ||
62 | Args: | |
63 | - request: Request | |
64 | - collection_items: cursor of collection items | |
65 | - pagination: Paginator object | |
66 | - pagination_base_url: If you want the pagination to point to a | |
67 | different URL, point it here | |
68 | - col_number: How many columns per row (default 5) | |
69 | #} | |
70 | {% macro collection_gallery(request, collection_items, pagination, | |
71 | pagination_base_url=None, col_number=5) %} | |
72 | {% if collection_items and collection_items.count() %} | |
73 | {{ media_grid(request, collection_items, col_number=col_number) }} | |
74 | <div class="clear"></div> | |
75 | {% if pagination_base_url %} | |
76 | {# different url, so set that and don't keep the get params #} | |
77 | {{ render_pagination(request, pagination, pagination_base_url, False) }} | |
78 | {% else %} | |
79 | {{ render_pagination(request, pagination) }} | |
80 | {% endif %} | |
81 | {% else %} | |
82 | <p> | |
83 | <i> | |
84 | {%- trans -%} | |
85 | There doesn't seem to be any media here yet... | |
86 | {%- endtrans -%} | |
87 | </i> | |
88 | </p> | |
89 | {% endif %} | |
90 | {% endmacro %} |