Commit | Line | Data |
---|---|---|
ae85ed0f BK |
1 | {# |
2 | # GNU MediaGoblin -- federated, autonomous media hosting | |
12a100e4 | 3 | # Copyright (C) 2011 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 CAW |
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 %} | |
ec451724 | 28 | {% set entry_url = entry.url_for_self(request.urlgen) %} |
b5017dba CAW |
29 | <td class="media_thumbnail thumb_entry |
30 | {%- if loop.first %} thumb_entry_first | |
31 | {%- elif loop.last %} thumb_entry_last{% endif %}"> | |
ec451724 | 32 | <a href="{{ entry_url }}"> |
b5017dba CAW |
33 | <img src="{{ request.app.public_store.file_url( |
34 | entry['media_files']['thumb']) }}" /> | |
35 | </a> | |
ec451724 CAW |
36 | {% if entry['title'] %} |
37 | <br /> | |
38 | <a href="{{ entry_url }}">{{ entry['title'] }}</a> | |
39 | {% endif %} | |
b5017dba CAW |
40 | </td> |
41 | {% endfor %} | |
42 | </tr> | |
035c976f | 43 | {% endfor %} |
b5017dba | 44 | </table> |
035c976f KR |
45 | {%- endmacro %} |
46 | ||
38bf03c6 CAW |
47 | {# |
48 | Render a media gallery with pagination. | |
49 | ||
50 | Args: | |
51 | - request: Request | |
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) | |
57 | #} | |
58 | {% macro object_gallery(request, media_entries, pagination, | |
59 | pagination_base_url=None, col_number=5) %} | |
77bc1c28 | 60 | {% if media_entries and media_entries.count() %} |
38bf03c6 | 61 | {{ media_grid(request, media_entries, col_number=col_number) }} |
db2b07ee | 62 | <div class="clear"></div> |
51ca54a8 CAW |
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) }} | |
66 | {% else %} | |
67 | {{ render_pagination(request, pagination) }} | |
5949be9a | 68 | {% endif %} |
7b32ba9a CAW |
69 | {% else %} |
70 | <p> | |
77bc1c28 | 71 | <i>There doesn't seem to be any media here yet...</i> |
7b32ba9a | 72 | </p> |
51ca54a8 | 73 | {% endif %} |
38bf03c6 | 74 | {% endmacro %} |