# HG changeset patch # User Goffi # Date 1509123019 -7200 # Node ID f19e9f5e43b08b39830751c2de20f11dd038cded # Parent 37fd11d7123391d7d6a21f7d28f4fbde191b2f44 blog: moved items rendering to a macro + handle new date filter + handle identities diff -r 37fd11d71233 -r f19e9f5e43b0 default/blog/articles.html --- a/default/blog/articles.html Fri Oct 27 18:48:41 2017 +0200 +++ b/default/blog/articles.html Fri Oct 27 18:50:19 2017 +0200 @@ -1,40 +1,9 @@ {% if not embedded %}{% extends 'base/base.html' %}{% endif %} -{% import 'input/comment.html' as comment with context %} - -{% macro show_items(items, comments=False) %} - {# show items and comments items if present after each item, - then post form if allow_commenting is set #} - {% for item in items %} - {% if not comments %}
{% endif %} - {% include 'blog/item.html' %} - {% if not comments %}
{% endif %} - - {# we recursively display comments for all comments nodes (usually there's only one) #} - {% for comments_items in item.comments_items_list %} - -
- {% if allow_commenting %} -
- {{ comment.comment(service=comments_items.service, node=comments_items.node) }} -
- {% endif %} - -
- {{show_items(comments_items, comments=True)}} -
-
- - {% endfor %} - - {% endfor %} -{% endmacro %} +{% set dates_format='relative' %} +{% import 'blog/macros.html' as blog with context %} {% block body %}
- {{ show_items(items) }} + {{ blog.show_items(items) }}
{% endblock body %} diff -r 37fd11d71233 -r f19e9f5e43b0 default/blog/item.html --- 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 %} -
+
{# following message is displayed if item lang is different from page locale #} {% if other_lang is defined %} @@ -24,8 +33,12 @@
{% block blog_title %}{{ item.title_xhtml or item.title or '' }}{% endblock %}
{% block metadata %} {% endblock metadata %} @@ -34,7 +47,7 @@
{% block content %} - {{ item.content_xhtml or item.content or ''}} + {{- item.content_xhtml or item.content or '' -}} {% endblock content %}
diff -r 37fd11d71233 -r f19e9f5e43b0 default/blog/macros.html --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/default/blog/macros.html Fri Oct 27 18:50:19 2017 +0200 @@ -0,0 +1,41 @@ +{% import 'input/comment.html' as comment with context %} + +{% macro show_items(items, comments=False, expanded=false, dates_fmt=none) %} + {# show items and comments items if present after each item, + then post form if allow_commenting is set + @param items(BlogItems): items to show + @param comments(bool): True items are comments + if False, a div with "main_article" class will be added + @param expanded(bool): initial state of items + #} + {% if dates_format is undefined %} + {% set dates_format = dates_fmt or 'short' %} + {% endif %} + {% for item in items %} + {% if not comments %}
{% endif %} + {% include 'blog/item.html' %} + {% if not comments %}
{% endif %} + + {# we recursively display comments for all comments nodes (usually there's only one) #} + {% for comments_items in item.comments_items_list %} + +
+ {% if allow_commenting %} +
+ {{- comment.comment(service=comments_items.service, node=comments_items.node) -}} +
+ {% endif %} + +
+ {{show_items(comments_items, comments=True)}} +
+
+ + {% endfor %} + + {% endfor %} +{% endmacro %}