Ticket #5619: 0005-Use-media_entry-in-collection_gallery.patch

File 0005-Use-media_entry-in-collection_gallery.patch, 4.9 KB (added by Olivier Mehani, 4 years ago)
  • mediagoblin/static/css/base.css

    From 6a32e9123f4cf395682f6def36b389e5ac62ba4f Mon Sep 17 00:00:00 2001
    From: Olivier Mehani <shtrom+mediagoblin@ssji.net>
    Date: Sat, 30 May 2020 23:33:23 +1000
    Subject: [PATCH 5/5] Use media_entry in collection_gallery
    
    Signed-off-by: Olivier Mehani <shtrom+mediagoblin@ssji.net>
    ---
     mediagoblin/static/css/base.css               | 15 +++++-
     .../mediagoblin/utils/collection_gallery.html | 48 +++++--------------
     .../mediagoblin/utils/media_grid.html         |  7 ++-
     3 files changed, 32 insertions(+), 38 deletions(-)
    
    diff --git a/mediagoblin/static/css/base.css b/mediagoblin/static/css/base.css
    index 65e33ceb..63df15e5 100644
    a b ul#action_to_resolve {list-style:none; margin-left:10px;}  
    647647}
    648648
    649649.media_thumbnail a.remove {
    650   color: #86D4B1;
    651   text-decoration: underline;
     650  font-size: 0;
     651  position: absolute;
     652  top: 2px;
     653  right: 2px;
     654}
     655.media_thumbnail a.remove:before {
     656  content: 'X';
     657  font-size: large;
     658  font-weight: bold;
     659  color: #f99;
     660}
     661.media_thumbnail a.remove:hover:before {
     662  color: #f00;
    652663}
    653664
    654665a.thumb_entry_title {
  • mediagoblin/templates/mediagoblin/utils/collection_gallery.html

    diff --git a/mediagoblin/templates/mediagoblin/utils/collection_gallery.html b/mediagoblin/templates/mediagoblin/utils/collection_gallery.html
    index 8a3f7a75..4a90878d 100644
    a b  
    1717#}
    1818
    1919{% from "mediagoblin/utils/pagination.html" import render_pagination %}
     20{% from "mediagoblin/utils/media_grid.html" import media_entry %}
    2021
    2122{% macro media_grid(request, collection_items, col_number=5) %}
    22   <div class="thumb_gallery">
     23  <div class="thumb_gallery thumb_row">
    2324    {% for row in collection_items|batch(col_number) %}
    24       <div class="row thumb_row
    25                  {%- if loop.first %} thumb_row_first
    26                  {%- elif loop.last %} thumb_row_last{% endif %}">
    2725        {% for item in row %}
    2826          {% set obj = item.get_object() %}
    29           {% set obj_url = obj.url_for_self(request.urlgen) %}
    30           <div class="three columns media_thumbnail thumb_entry
    31                      {%- if loop.first %} thumb_entry_first
    32                      {%- elif loop.last %} thumb_entry_last{% endif %}">
    33             <a href="{{ obj_url }}">
    34               {% if obj.icon_url %}
    35               <img class="entry_type_icon" src="{{ obj.icon_url }}" />
    36               {% endif %}
    37               <img src="{{ obj.thumb_url }}" />
    38             </a>
    39 
    40             {% if obj.title %}
    41             <a href="{{ obj_url }}">{{ obj.title }}</a>
    42             {% endif %}
    43             {% if item.note %}
    44               {{ item.note }}
    45             {% endif %}
    46             {% if request.user and
    47                   (item.in_collection.actor == request.user.id or
    48                   request.user.has_privilege('admin')) %}
    49               {%- set remove_url=request.urlgen(
    50                                  'mediagoblin.user_pages.collection_item_confirm_remove',
    51                                  user=item.in_collection.get_actor.username,
    52                                  collection=item.in_collection.slug,
    53                                  collection_item=item.id) -%}
    54               <a href="{{ remove_url }}" class="remove">
    55                 {%- trans %}(remove){% endtrans -%}
    56               </a>
    57             {% endif %}
    58           </div>
     27          {% set remove_url = None %}
     28          {% if request.user and
     29                (item.in_collection.actor == request.user.id or
     30                request.user.has_privilege('admin')) %}
     31                  {%- set remove_url=request.urlgen(
     32                                     'mediagoblin.user_pages.collection_item_confirm_remove',
     33                                     user=item.in_collection.get_actor.username,
     34                                     collection=item.in_collection.slug,
     35                                     collection_item=item.id) -%}
     36          {% endif %}
     37          {{ media_entry(request, obj, loop, remove_url) }}
    5938        {% endfor %}
    60       </div>
    6139    {% endfor %}
    6240  </div>
    6341{%- endmacro %}
  • 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
    index 1276e104..ec8d66b3 100644
    a b  
    1616# along with this program.  If not, see <http://www.gnu.org/licenses/>.
    1717#}
    1818
    19 {% macro media_entry(request, entry, loop) %}
     19{% macro media_entry(request, entry, loop, remove_url=None) %}
    2020  {% set entry_url = entry.url_for_self(request.urlgen) %}
    2121  <div class="media_thumbnail thumb_entry
    2222           {%- if loop.first %} thumb_entry_first
     
    3131    {% if entry.icon_url %}
    3232    <img class="entry_type_icon" src="{{ entry.icon_url }}" />
    3333    {% endif %}
     34    {% if remove_url%}
     35      <a href="{{ remove_url }}" class="remove">
     36        {%- trans %}(remove){% endtrans -%}
     37      </a>
     38    {% endif %}
    3439    {% if entry.title %}
    3540    <a class="thumb_entry_title" href="{{ entry_url }}">{{ entry.title }}</a>
    3641    {% endif %}