Mercurial > libervia-templates
comparison sat_templates/templates/default/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 | d586ea13cfed |
children |
comparison
equal
deleted
inserted
replaced
246:1928ba66c194 | 247:40fccd3b7cf0 |
---|---|
1 {# blog_page indicate if blog is included in an other page or if it is the main one #} | 1 {# blog_page indicate if blog is included in an other page or if it is the main one #} |
2 {% if not embedded %}{% extends 'base/base.html' %}{% set blog_page = True %}{% endif %} | 2 {% if not embedded %}{% extends 'base/base.html' %}{% set blog_page = True %}{% endif %} |
3 {% set single = items|length == 1 %} | 3 {% set single = blog_items['items']|length == 1 %} |
4 {% set dates_format='relative' if single else 'short' %} | 4 {% set dates_format='relative' if single else 'short' %} |
5 {% import 'components/avatar.html' as avatar with context %} | 5 {% import 'components/avatar.html' as avatar with context %} |
6 {% import 'blog/macros.html' as blog with context %} | 6 {% import 'blog/macros.html' as blog with context %} |
7 {% import 'input/navigation.html' as navigation with context %} | 7 {% import 'input/navigation.html' as navigation with context %} |
8 | 8 |
9 {%- block title scoped -%} | 9 {%- block title scoped -%} |
10 {%- if blog_page -%} | 10 {%- if blog_page -%} |
11 {%- if single -%} | 11 {%- if single -%} |
12 {{- items[0].title|default(items[0].content, true)|truncate(60, True, '…') + ' - ' + C.APP_NAME -}} | 12 {{- blog_items['items'][0].title|default(blog_items['items'][0].content, true)|truncate(60, True, '…') + ' - ' + C.APP_NAME -}} |
13 {%- else -%} | 13 {%- else -%} |
14 {{C.APP_NAME}} | 14 {{C.APP_NAME}} |
15 {# {{- super() -}} | 15 {# {{- super() -}} |
16 FIXME: super() is failing if blog is embedded (i.e. base/base.html is not its direct parent) | 16 FIXME: super() is failing if blog is embedded (i.e. base/base.html is not its direct parent) |
17 not sure what's the best way to avoid that, so just using C.APP_NAME for now #} | 17 not sure what's the best way to avoid that, so just using C.APP_NAME for now #} |
19 {%- endif -%} | 19 {%- endif -%} |
20 {%- endblock title -%} | 20 {%- endblock title -%} |
21 | 21 |
22 {% block body %} | 22 {% block body %} |
23 {{ icon_defs('angle-double-left', 'angle-double-right') }} | 23 {{ icon_defs('angle-double-left', 'angle-double-right') }} |
24 {% if items %} | 24 {% if blog_items['items'] %} |
25 <div id="blog_items"> | 25 <div id="blog_items"> |
26 {{ blog.show_items(items, expanded=single) }} | 26 {{ blog.show_items(blog_items['items'], expanded=single) }} |
27 </div> | 27 </div> |
28 {% else %} | 28 {% else %} |
29 <p class="message--info">{% trans %}No articles found in this blog!{% endtrans %}</p> | 29 <p class="message--info">{% trans %}No articles found in this blog!{% endtrans %}</p> |
30 {% endif %} | 30 {% endif %} |
31 | 31 |