Ticket #5619: 0004-Split-media_grid-out-to-its-own-util.patch

File 0004-Split-media_grid-out-to-its-own-util.patch, 4.0 KB (added by Olivier Mehani, 8 months ago)
  • new file mediagoblin/templates/mediagoblin/utils/media_grid.html

    From b3ded7b4a69a8aae6fbcd9e6146b038218e85ae9 Mon Sep 17 00:00:00 2001
    From: Olivier Mehani <shtrom+mediagoblin@ssji.net>
    Date: Sat, 30 May 2020 23:32:41 +1000
    Subject: [PATCH 4/5] 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>
    ---
     .../mediagoblin/utils/media_grid.html         | 47 +++++++++++++++++++
     .../mediagoblin/utils/object_gallery.html     | 26 +---------
     2 files changed, 48 insertions(+), 25 deletions(-)
     create mode 100644 mediagoblin/templates/mediagoblin/utils/media_grid.html
    
    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
    - +  
     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{% macro media_entry(request, entry, loop) %}
     20  {% set entry_url = entry.url_for_self(request.urlgen) %}
     21  <div class="media_thumbnail thumb_entry
     22           {%- if loop.first %} thumb_entry_first
     23           {%- elif loop.last %} thumb_entry_last{% endif %}">
     24    <a href="{{ entry_url }}"
     25    {% if entry.title %}
     26    title="{{ entry.title }}"
     27    {% endif %}
     28    >
     29      <img class="thumb_img" src="{{ entry.thumb_url }}" />
     30    </a>
     31    {% if entry.icon_url %}
     32    <img class="entry_type_icon" src="{{ entry.icon_url }}" />
     33    {% endif %}
     34    {% if entry.title %}
     35    <a class="thumb_entry_title" href="{{ entry_url }}">{{ entry.title }}</a>
     36    {% endif %}
     37  </div>
     38{%- endmacro %}
     39
     40{% macro media_grid(request, media_entries, col_number=5) %}
     41  <div class="thumb_gallery thumb_row">
     42    {% for entry in media_entries %}
     43      {{ media_entry(request, entry, loop) }}
     44    {% endfor %}
     45  </div>
     46{%- endmacro %}
     47
  • mediagoblin/templates/mediagoblin/utils/object_gallery.html

    diff --git a/mediagoblin/templates/mediagoblin/utils/object_gallery.html b/mediagoblin/templates/mediagoblin/utils/object_gallery.html
    index 2a3cddaa..235490fd 100644
    a b  
    1717#}
    1818
    1919{% from "mediagoblin/utils/pagination.html" import render_pagination %}
    20 
    21 {% macro media_grid(request, media_entries, col_number=5) %}
    22   <div class="thumb_gallery thumb_row">
    23     {% for entry in media_entries %}
    24           {% set entry_url = entry.url_for_self(request.urlgen) %}
    25           <div class="media_thumbnail thumb_entry
    26                      {%- if loop.first %} thumb_entry_first
    27                      {%- elif loop.last %} thumb_entry_last{% endif %}">
    28             <a href="{{ entry_url }}"
    29             {% if entry.title %}
    30             title="{{ entry.title }}"
    31             {% endif %}
    32             >
    33               <img class="thumb_img" src="{{ entry.thumb_url }}" />
    34             </a>
    35             {% if entry.icon_url %}
    36             <img class="entry_type_icon" src="{{ entry.icon_url }}" />
    37             {% endif %}
    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 {%- endmacro %}
     20{% from "mediagoblin/utils/media_grid.html" import media_grid %}
    4521
    4622{#
    4723  Render a media gallery with pagination.