diff default/blog/item.html @ 49:f19e9f5e43b0

blog: moved items rendering to a macro + handle new date filter + handle identities
author Goffi <goffi@goffi.org>
date Fri, 27 Oct 2017 18:50:19 +0200
parents 580670430fa2
children 94b5806b9e2f
line wrap: on
line diff
--- a/default/blog/item.html	Fri Oct 27 18:48:41 2017 +0200
+++ b/default/blog/item.html	Fri Oct 27 18:50:19 2017 +0200
@@ -1,3 +1,12 @@
+{# display a blog item which can be expanded/retracted by clicking on it
+
+    if the locale differs from item language, it will be totally reduced, and will need a click to be displayed
+
+    @variable item(data_object.BlogItem): item to display
+    @variable identities(data_object.Identities): identities which can be used to display info on item author
+    @variable dates_format(unicode): format of the date to use (see date_fmt filter)
+#}
+
 {% block item %}
 
 {% if item.language and locale and locale.language != item.language %}
@@ -5,7 +14,7 @@
     {% set other_lang = " other_lang" %}
 {% endif %}
 
-<article id="{{item.id}}" class="init box{{other_lang}}">
+<article id="{{item.id}}" class="init box{{other_lang}}{{" clicked" if expanded}}">
 
     {# following message is displayed if item lang is different from page locale #}
     {% if other_lang is defined %}
@@ -24,8 +33,12 @@
         <div class="title">{% block blog_title %}{{ item.title_xhtml or item.title or '' }}{% endblock %}</div>
             {% block metadata %}
             <div class="metadata">
-            <span class="author">{{identities[item.author_jid].nick | default(item.author)}}</span>
-            <span class="blog_data">{% trans days=item.published|date_days %}{{days}} days ago{% endtrans %}</span>
+            {% if identities is defined %}
+                <span class="author">{{identities[item.author_jid].nick | default(item.author)}}</span>
+            {% else %}
+                <span class="author">{{item.author}}</span>
+            {% endif %}
+            <span class="blog_data">{{item.published|date_fmt(fmt=dates_format)}}</span>
             </div>
 
             {% endblock metadata %}
@@ -34,7 +47,7 @@
 
     <div class="content{{' text' if not item.content_xhtml}}">
         {% block content %}
-        {{ item.content_xhtml or item.content or ''}}
+        {{- item.content_xhtml or item.content or '' -}}
         {% endblock content %}
     </div>