changeset 196:03c8fd941c0c

event, photo, components: moved interests grid in a macro (in components/block)
author Goffi <goffi@goffi.org>
date Fri, 03 May 2019 23:56:11 +0200
parents bca0aa66294a
children 9fe8fdcd53d9
files sat_templates/templates/default/components/block.html sat_templates/templates/default/event/overview.html sat_templates/templates/default/photo/discover.html
diffstat 3 files changed, 30 insertions(+), 26 deletions(-) [+]
line wrap: on
line diff
--- a/sat_templates/templates/default/components/block.html	Fri May 03 20:55:49 2019 +0200
+++ b/sat_templates/templates/default/components/block.html	Fri May 03 23:56:11 2019 +0200
@@ -32,3 +32,24 @@
         {% endfor %}
     </ul>
 {% endmacro %}
+
+{% macro interests_grid(interests, default_icon_name) %}
+{# display list of interests
+    @param interests: list of interests
+    @param default_icon_name: name of a defined icon to use when no thumb_url is available
+#}
+    <ul class="grid grid--center">
+        {% for interest in interests %}
+            <li class='grid__item grid__item--medium grid__item--selectable'>
+                <a href="{{interest.url}}">
+                    {% if interest.thumb_url %}
+                        <img class="img--small" src="{{interest.thumb_url}}">
+                    {% else %}
+                        <div>{{ icon(default_icon_name, cls='icon--medium') }}</div>
+                    {% endif %}
+                    <span><em>{{ interest.name|default(_("unnamed")) }}</em></span>
+                </a>
+            </li>
+        {% endfor %}
+    </ul>
+{% endmacro %}
--- a/sat_templates/templates/default/event/overview.html	Fri May 03 20:55:49 2019 +0200
+++ b/sat_templates/templates/default/event/overview.html	Fri May 03 23:56:11 2019 +0200
@@ -8,7 +8,10 @@
 
 {% set category_menu = [('event_new', url_event_new)] %}
 {% if not embedded %}{% extends 'base/base.html' %}{% endif %}
+{% import 'components/block.html' as block with context %}
+
 {% block body %}
+{{ icon_defs('calendar') }}
 <div class="box message--info">
     <p>{% trans %}There is not events discovery yet, this will come in the future.{% endtrans %}</p>
 </div>
@@ -20,17 +23,8 @@
             You have currently {{nb_events}} events in your personal list
         {% endtrans %}
     </p>
-    <ul class="grid grid--center">
-        {% for event in events %}
-            <li class='grid__item grid__item--medium grid__item--selectable'>
-                <a href="{{event.url}}">
-                    {% if event.image %}
-                        <img class="img--small" src="{{event.image}}">
-                    {% endif %}
-                    <span><em>{{event.name}}</em></span>
-                </a>
-            </li>
-        {% endfor %}
-    </ul>
+
+    {{block.interests_grid(events, 'calendar')}}
+
 {% endif %}
 {% endblock body %}
--- a/sat_templates/templates/default/photo/discover.html	Fri May 03 20:55:49 2019 +0200
+++ b/sat_templates/templates/default/photo/discover.html	Fri May 03 23:56:11 2019 +0200
@@ -1,4 +1,5 @@
 {% extends 'base/base.html' %}
+{% import 'components/block.html' as block with context %}
 {% import 'input/form.html' as form with context %}
 {% import 'input/field.html' as field with context %}
 
@@ -13,20 +14,8 @@
             You have currently {{nb_interests}} albums in your personal list
         {% endtrans %}
     </p>
-    <ul class="grid grid--center">
-        {% for interest in interests %}
-            <li class='grid__item grid__item--medium grid__item--selectable'>
-                <a href="{{interest.url}}">
-                    {% if interest.thumb_url %}
-                        <img class="img--small" src="{{interest.thumb_url}}">
-                    {% else %}
-                        <div>{{ icon('file-image', cls='icon--medium') }}</div>
-                    {% endif %}
-                    <span><em>{{ interest.name|default(_("unnamed album")) }}</em></span>
-                </a>
-            </li>
-        {% endfor %}
-    </ul>
+
+    {{block.interests_grid(interests, 'file-image')}}
 {% endif %}
 {% call form.form(class="form--single") %}
     {{ field.text("jid", _("device full jid"), required=true)}}