{#
# GNU MediaGoblin -- federated, autonomous media hosting
-# Copyright (C) 2011 Free Software Foundation, Inc
+# Copyright (C) 2011 MediaGoblin contributors. See AUTHORS.
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as published by
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#}
-{% block object_gallery_content -%}
- <div>
- {% if media_entries %}
- <ul class="media_thumbnail">
- {% for entry in media_entries %}
- <li class="media_thumbnail">
- <a href="{{ entry.url_for_self(request.urlgen) }}">
- <img src="{{ request.app.public_store.file_url(
- entry['media_files']['thumb']) }}" /></a>
- </li>
+{% from "mediagoblin/utils/pagination.html" import render_pagination %}
+
+{% macro media_grid(request, media_entries, col_number=5) %}
+ <table class="thumb_gallery">
+ {% for row in gridify_cursor(media_entries, col_number) %}
+ <tr class="thumb_row
+ {%- if loop.first %} thumb_row_first
+ {%- elif loop.last %} thumb_row_last{% endif %}">
+ {% for entry in row %}
+ {% set entry_url = entry.url_for_self(request.urlgen) %}
+ <td class="media_thumbnail thumb_entry
+ {%- if loop.first %} thumb_entry_first
+ {%- elif loop.last %} thumb_entry_last{% endif %}">
+ <a href="{{ entry_url }}">
+ <img src="{{ request.app.public_store.file_url(
+ entry['media_files']['thumb']) }}" />
+ </a>
+ {% if entry['title'] %}
+ <br />
+ <a href="{{ entry_url }}">{{ entry['title'] }}</a>
+ {% endif %}
+ </td>
{% endfor %}
- </ul>
- {% include "mediagoblin/utils/pagination.html" %}
- {% endif %}
+ </tr>
+ {% endfor %}
+ </table>
+{%- endmacro %}
+
+{#
+ Render a media gallery with pagination.
- </div>
-{% endblock %}
+ Args:
+ - request: Request
+ - media_entries: pymongo cursor of media entries
+ - pagination: Paginator object
+ - pagination_base_url: If you want the pagination to point to a
+ different URL, point it here
+ - col_number: How many columns per row (default 5)
+#}
+{% macro object_gallery(request, media_entries, pagination,
+ pagination_base_url=None, col_number=5) %}
+ {% if media_entries and media_entries.count() %}
+ {{ media_grid(request, media_entries, col_number=col_number) }}
+ <div class="clear"></div>
+ {% if pagination_base_url %}
+ {# different url, so set that and don't keep the get params #}
+ {{ render_pagination(request, pagination, pagination_base_url, False) }}
+ {% else %}
+ {{ render_pagination(request, pagination) }}
+ {% endif %}
+ {% else %}
+ <p>
+ <i>There doesn't seem to be any media here yet...</i>
+ </p>
+ {% endif %}
+{% endmacro %}