Add test for get_all_media()
[mediagoblin.git] / mediagoblin / templates / mediagoblin / utils / object_gallery.html
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, media_entries, col_number=5) %}
22 <div class="thumb_gallery">
23 {% for row in media_entries|batch(col_number) %}
24 <div class="row thumb_row
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 <div class="three columns 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 {% if entry.icon_url %}
34 <img class="entry_type_icon" src="{{ entry.icon_url }}" />
35 {% endif %}
36 <img src="{{ entry.thumb_url }}" />
37 </a>
38 {% if entry.title %}
39 <a class="thumb_entry_title" href="{{ entry_url }}">{{ entry.title }}</a>
40 {% endif %}
41 </div>
42 {% endfor %}
43 </div>
44 {% endfor %}
45 </div>
46 {%- endmacro %}
47
48 {#
49 Render a media gallery with pagination.
50
51 Args:
52 - request: Request
53 - media_entries: db cursor of media entries
54 - pagination: Paginator object
55 - pagination_base_url: If you want the pagination to point to a
56 different URL, point it here
57 - col_number: How many columns per row (default 5)
58 #}
59 {% macro object_gallery(request, media_entries, pagination,
60 pagination_base_url=None, col_number=5) %}
61 {% if media_entries and media_entries.count() %}
62 {{ media_grid(request, media_entries, col_number=col_number) }}
63 <div class="clear"></div>
64 {% if pagination_base_url %}
65 {# different url, so set that and don't keep the get params #}
66 {{ render_pagination(request, pagination, pagination_base_url, False) }}
67 {% else %}
68 {{ render_pagination(request, pagination) }}
69 {% endif %}
70 {% else %}
71 <p>
72 <i>
73 {%- trans -%}
74 There doesn't seem to be any media here yet...
75 {%- endtrans -%}
76 </i>
77 </p>
78 <p>
79 <a class="button_action" href="{{ request.urlgen('mediagoblin.submit.start') }}">
80 {%- trans %}Add media{% endtrans -%}
81 </a>
82 </p>
83 {% endif %}
84 {% endmacro %}