view sat_templates/templates/bulma/blog/item.html @ 247:40fccd3b7cf0

updated code to handle blog items following data structure change in backend/Libervia
author Goffi <goffi@goffi.org>
date Thu, 16 Jul 2020 09:08:32 +0200
parents 1928ba66c194
children 80cfec962b1e
line wrap: on
line source

{# 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 %}

{% set item_level = (item_level or 0) + 1 %}

{% if item.language and locale and locale.language != item.language %}
    {# we may display items in different language in a specific way #}
    {% set other_lang = " other_lang" if expanded else " other_lang state_init" %}
{% endif %}
    <article id="{{item.id}}" class="media has-background-white px-1 py-1" >
        {% if identities is defined %}
            {% if avatar is defined %}
                <div class="media-left">
                    {{ avatar.avatar(item.author_jid) }}
                </div>
            {% endif %}
        {% endif %}
        <div class="media-content">
            {% set title = item.title_xhtml|safe or item.title%}
            {% if title %}
                <h4 class="title is-4">{{title}}</h1>
            {% endif %}
            <div class="content">
                <p class="subtitle is-6 has-text-grey">
                    {% set published = item.published|date_fmt(fmt=dates_format) %}
                    <strong>{{item.author}}</strong> <small>{{published}}</small>
                    {% if item.tags %}
                        <small class="labels">
                            {% if tags_http_uri is defined %}
                                {% for tag in item.tags %}
                                    <a href="{{tags_http_uri[tag]}}"><span class="tag is-rounded">{{tag}}</span></a>
                                {% endfor %}
                            {% else %}
                                {% for tag in item.tags %}
                                    <span class="tag">{{tag}}</span>
                                {% endfor %}
                            {% endif %}
                        </small>
                    {% endif %}
                </p>
                <p>
                    {{- item.content_xhtml|safe if item.content_xhtml is defined else item.content|urlize -}}
                </p>
                {% for comments_data in item.comments %}
                    {% for item in comments_data['items'] %}
                        {% include 'blog/item.html' %}
                    {% endfor %}
                    {% if allow_commenting and item_level == 1 %}
                        <div class="comment_post">
                            {{- textbox.comment(service=comments_data.service, node=comments_data.node) -}}
                        </div>
                    {% endif %}
                {% endfor %}

            </div>
        </div>
    </article>

{% endblock item %}