diff options
author | Olivier Mehani <shtrom+mediagoblin@ssji.net> | 2020-05-30 23:32:41 +1000 |
---|---|---|
committer | Olivier Mehani <shtrom+mediagoblin@ssji.net> | 2020-05-31 00:44:14 +1000 |
commit | 40e9e289a879365007e854b27275cc4b559085e2 (patch) | |
tree | 356972abc1da42935225aaab31534ed0f198ef3f | |
parent | 943054aba1ba27fd7bddc8d4061f92e9ece88c30 (diff) |
Split media_grid out to its own util
Also, split it further into a separate media_entry macro
Signed-off-by: Olivier Mehani <shtrom+mediagoblin@ssji.net>
-rw-r--r-- | mediagoblin/templates/mediagoblin/utils/media_grid.html | 47 | ||||
-rw-r--r-- | mediagoblin/templates/mediagoblin/utils/object_gallery.html | 26 |
2 files changed, 48 insertions, 25 deletions
diff --git a/mediagoblin/templates/mediagoblin/utils/media_grid.html b/mediagoblin/templates/mediagoblin/utils/media_grid.html new file mode 100644 index 00000000..1276e104 --- /dev/null +++ b/mediagoblin/templates/mediagoblin/utils/media_grid.html @@ -0,0 +1,47 @@ +{# +# GNU MediaGoblin -- federated, autonomous media hosting +# Copyright (C) 2011, 2012 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 +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Affero General Public License for more details. +# +# You should have received a copy of the GNU Affero General Public License +# along with this program. If not, see <http://www.gnu.org/licenses/>. +#} + +{% macro media_entry(request, entry, loop) %} + {% set entry_url = entry.url_for_self(request.urlgen) %} + <div class="media_thumbnail thumb_entry + {%- if loop.first %} thumb_entry_first + {%- elif loop.last %} thumb_entry_last{% endif %}"> + <a href="{{ entry_url }}" + {% if entry.title %} + title="{{ entry.title }}" + {% endif %} + > + <img class="thumb_img" src="{{ entry.thumb_url }}" /> + </a> + {% if entry.icon_url %} + <img class="entry_type_icon" src="{{ entry.icon_url }}" /> + {% endif %} + {% if entry.title %} + <a class="thumb_entry_title" href="{{ entry_url }}">{{ entry.title }}</a> + {% endif %} + </div> +{%- endmacro %} + +{% macro media_grid(request, media_entries, col_number=5) %} + <div class="thumb_gallery thumb_row"> + {% for entry in media_entries %} + {{ media_entry(request, entry, loop) }} + {% endfor %} + </div> +{%- endmacro %} + diff --git a/mediagoblin/templates/mediagoblin/utils/object_gallery.html b/mediagoblin/templates/mediagoblin/utils/object_gallery.html index a01cb3d5..84f1a350 100644 --- a/mediagoblin/templates/mediagoblin/utils/object_gallery.html +++ b/mediagoblin/templates/mediagoblin/utils/object_gallery.html @@ -17,31 +17,7 @@ #} {% from "mediagoblin/utils/pagination.html" import render_pagination %} - -{% macro media_grid(request, media_entries, col_number=5) %} - <div class="thumb_gallery thumb_row"> - {% for entry in media_entries %} - {% set entry_url = entry.url_for_self(request.urlgen) %} - <div class="media_thumbnail thumb_entry - {%- if loop.first %} thumb_entry_first - {%- elif loop.last %} thumb_entry_last{% endif %}"> - <a href="{{ entry_url }}" - {% if entry.title %} - title="{{ entry.title }}" - {% endif %} - > - <img class="thumb_img" src="{{ entry.thumb_url }}" /> - </a> - {% if entry.icon_url %} - <img class="entry_type_icon" src="{{ entry.icon_url }}" /> - {% endif %} - {% if entry.title %} - <a class="thumb_entry_title" href="{{ entry_url }}">{{ entry.title }}</a> - {% endif %} - </div> - {% endfor %} - </div> -{%- endmacro %} +{% from "mediagoblin/utils/media_grid.html" import media_grid %} {# Render a media gallery with pagination. |