Commit | Line | Data |
---|---|---|
ae85ed0f BK |
1 | {# |
2 | # GNU MediaGoblin -- federated, autonomous media hosting | |
cf29e8a8 | 3 | # Copyright (C) 2011, 2012 MediaGoblin contributors. See AUTHORS. |
ae85ed0f BK |
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 | ||
5949be9a CAW |
19 | {% from "mediagoblin/utils/pagination.html" import render_pagination %} |
20 | ||
b5017dba | 21 | {% macro media_grid(request, media_entries, col_number=5) %} |
ee9a0e3c | 22 | <ul class="thumb_gallery"> |
b5017dba | 23 | {% for row in gridify_cursor(media_entries, col_number) %} |
ee9a0e3c JS |
24 | {% for entry in row %} |
25 | {% set entry_url = entry.url_for_self(request.urlgen) %} | |
26 | <li class="media_thumbnail"> | |
27 | <a href="{{ entry_url }}"> | |
28 | <img src="{{ request.app.public_store.file_url( | |
29 | entry.media_files['thumb']) }}" /> | |
30 | </a> | |
31 | {% if entry.title %} | |
32 | <br /> | |
33 | <a href="{{ entry_url }}">{{ entry.title }}</a> | |
34 | {% endif %} | |
35 | </li> | |
36 | {% endfor %} | |
035c976f | 37 | {% endfor %} |
ee9a0e3c | 38 | </ul> |
035c976f KR |
39 | {%- endmacro %} |
40 | ||
38bf03c6 CAW |
41 | {# |
42 | Render a media gallery with pagination. | |
43 | ||
44 | Args: | |
45 | - request: Request | |
46 | - media_entries: pymongo cursor of media entries | |
47 | - pagination: Paginator object | |
48 | - pagination_base_url: If you want the pagination to point to a | |
49 | different URL, point it here | |
50 | - col_number: How many columns per row (default 5) | |
51 | #} | |
52 | {% macro object_gallery(request, media_entries, pagination, | |
53 | pagination_base_url=None, col_number=5) %} | |
77bc1c28 | 54 | {% if media_entries and media_entries.count() %} |
38bf03c6 | 55 | {{ media_grid(request, media_entries, col_number=col_number) }} |
db2b07ee | 56 | <div class="clear"></div> |
51ca54a8 CAW |
57 | {% if pagination_base_url %} |
58 | {# different url, so set that and don't keep the get params #} | |
59 | {{ render_pagination(request, pagination, pagination_base_url, False) }} | |
60 | {% else %} | |
61 | {{ render_pagination(request, pagination) }} | |
5949be9a | 62 | {% endif %} |
7b32ba9a CAW |
63 | {% else %} |
64 | <p> | |
0c0ab322 E |
65 | <i> |
66 | {%- trans -%} | |
67 | There doesn't seem to be any media here yet... | |
68 | {%- endtrans -%} | |
69 | </i> | |
7b32ba9a | 70 | </p> |
51ca54a8 | 71 | {% endif %} |
38bf03c6 | 72 | {% endmacro %} |