view sat_templates/templates/bulma/blog/articles.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 fbea1b9a558f
line wrap: on
line source

{# blog_page indicate if blog is included in an other page or if it is the main one #}
{% if not embedded %}{% extends 'base/base.html' %}{% set blog_page = True %}{% endif %}
{% set single = blog_items['items']|length == 1 %}
{% set dates_format='relative' if single else 'short' %}
{% import 'components/avatar.html' as avatar with context %}
{% import 'blog/macros.html' as blog with context %}
{% import 'input/navigation.html' as navigation with context %}

{%- block title scoped -%}
    {%- if blog_page -%}
        {%- if single -%}
            {{- blog_items['items'][0].title|default(blog_items['items'][0].content, true)|truncate(60, True, '…') + ' - ' + C.APP_NAME -}}
        {%- else -%}
            {{C.APP_NAME}}
            {# {{- super() -}}
               FIXME: super() is failing if blog is embedded (i.e. base/base.html is not its direct parent)
                      not sure what's the best way to avoid that, so just using C.APP_NAME for now #}
        {%- endif -%}
    {%- endif -%}
{%- endblock title -%}

{% block body %}

{% if blog_items['items'] %}
    <div class="container mt-4">
        <div id="blog_items" class="columns">
            <div class="column">
                {{ blog.show_items(blog_items['items'], expanded=single) }}
            </div>
        </div>
    </div>
{% else %}
    <div class="message mt-4">
        <div class="message-body">
            {% trans %}No articles found in this blog!{% endtrans %}
        </div>
    </div>
{% endif %}

{{ navigation.prev_next(_("newer articles"), _("older articles")) }}
{% endblock body %}