annotate default/blog/item.html @ 96:94b5806b9e2f

blog/item: various improvments: - title and publication date are now clickable if HTTP link of item is set - show labels (aka tags/categories) - text only content in body is urlized
author Goffi <goffi@goffi.org>
date Fri, 19 Jan 2018 18:19:57 +0100
parents f19e9f5e43b0
children 609c66552ba0
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
49
f19e9f5e43b0 blog: moved items rendering to a macro + handle new date filter + handle identities
Goffi <goffi@goffi.org>
parents: 44
diff changeset
1 {# display a blog item which can be expanded/retracted by clicking on it
f19e9f5e43b0 blog: moved items rendering to a macro + handle new date filter + handle identities
Goffi <goffi@goffi.org>
parents: 44
diff changeset
2
f19e9f5e43b0 blog: moved items rendering to a macro + handle new date filter + handle identities
Goffi <goffi@goffi.org>
parents: 44
diff changeset
3 if the locale differs from item language, it will be totally reduced, and will need a click to be displayed
f19e9f5e43b0 blog: moved items rendering to a macro + handle new date filter + handle identities
Goffi <goffi@goffi.org>
parents: 44
diff changeset
4
f19e9f5e43b0 blog: moved items rendering to a macro + handle new date filter + handle identities
Goffi <goffi@goffi.org>
parents: 44
diff changeset
5 @variable item(data_object.BlogItem): item to display
f19e9f5e43b0 blog: moved items rendering to a macro + handle new date filter + handle identities
Goffi <goffi@goffi.org>
parents: 44
diff changeset
6 @variable identities(data_object.Identities): identities which can be used to display info on item author
f19e9f5e43b0 blog: moved items rendering to a macro + handle new date filter + handle identities
Goffi <goffi@goffi.org>
parents: 44
diff changeset
7 @variable dates_format(unicode): format of the date to use (see date_fmt filter)
f19e9f5e43b0 blog: moved items rendering to a macro + handle new date filter + handle identities
Goffi <goffi@goffi.org>
parents: 44
diff changeset
8 #}
f19e9f5e43b0 blog: moved items rendering to a macro + handle new date filter + handle identities
Goffi <goffi@goffi.org>
parents: 44
diff changeset
9
0
9a31d2c02f47 SàT templates, initial commit
Goffi <goffi@goffi.org>
parents:
diff changeset
10 {% block item %}
30
69a2e3bf5e17 blog/item: if item is not in same language as current locale, item is hidden but will be shown on click.
Goffi <goffi@goffi.org>
parents: 24
diff changeset
11
36
baa0942d6b45 blog/item: fixed other_lang detection
Goffi <goffi@goffi.org>
parents: 34
diff changeset
12 {% if item.language and locale and locale.language != item.language %}
30
69a2e3bf5e17 blog/item: if item is not in same language as current locale, item is hidden but will be shown on click.
Goffi <goffi@goffi.org>
parents: 24
diff changeset
13 {# we may display items in different language in a specific way #}
69a2e3bf5e17 blog/item: if item is not in same language as current locale, item is hidden but will be shown on click.
Goffi <goffi@goffi.org>
parents: 24
diff changeset
14 {% set other_lang = " other_lang" %}
69a2e3bf5e17 blog/item: if item is not in same language as current locale, item is hidden but will be shown on click.
Goffi <goffi@goffi.org>
parents: 24
diff changeset
15 {% endif %}
69a2e3bf5e17 blog/item: if item is not in same language as current locale, item is hidden but will be shown on click.
Goffi <goffi@goffi.org>
parents: 24
diff changeset
16
49
f19e9f5e43b0 blog: moved items rendering to a macro + handle new date filter + handle identities
Goffi <goffi@goffi.org>
parents: 44
diff changeset
17 <article id="{{item.id}}" class="init box{{other_lang}}{{" clicked" if expanded}}">
44
580670430fa2 blog/item: expand/reduce improvments:
Goffi <goffi@goffi.org>
parents: 42
diff changeset
18
580670430fa2 blog/item: expand/reduce improvments:
Goffi <goffi@goffi.org>
parents: 42
diff changeset
19 {# following message is displayed if item lang is different from page locale #}
30
69a2e3bf5e17 blog/item: if item is not in same language as current locale, item is hidden but will be shown on click.
Goffi <goffi@goffi.org>
parents: 24
diff changeset
20 {% if other_lang is defined %}
69a2e3bf5e17 blog/item: if item is not in same language as current locale, item is hidden but will be shown on click.
Goffi <goffi@goffi.org>
parents: 24
diff changeset
21 <div class="info"><p>{% trans language=locale.language_name %}This message is not in {{language}}, click to display anyway{% endtrans %}</p></div>
69a2e3bf5e17 blog/item: if item is not in same language as current locale, item is hidden but will be shown on click.
Goffi <goffi@goffi.org>
parents: 24
diff changeset
22 {% endif %}
69a2e3bf5e17 blog/item: if item is not in same language as current locale, item is hidden but will be shown on click.
Goffi <goffi@goffi.org>
parents: 24
diff changeset
23
44
580670430fa2 blog/item: expand/reduce improvments:
Goffi <goffi@goffi.org>
parents: 42
diff changeset
24 {# we put a reduce button at the top #}
580670430fa2 blog/item: expand/reduce improvments:
Goffi <goffi@goffi.org>
parents: 42
diff changeset
25 <div class="expand_box box_top" onclick="clicked_mh_fix('{{item.id}}')">
580670430fa2 blog/item: expand/reduce improvments:
Goffi <goffi@goffi.org>
parents: 42
diff changeset
26 <p>
580670430fa2 blog/item: expand/reduce improvments:
Goffi <goffi@goffi.org>
parents: 42
diff changeset
27 <span class='hide'>{% trans %}Click to reduce…{% endtrans %}</span>
580670430fa2 blog/item: expand/reduce improvments:
Goffi <goffi@goffi.org>
parents: 42
diff changeset
28 </p>
580670430fa2 blog/item: expand/reduce improvments:
Goffi <goffi@goffi.org>
parents: 42
diff changeset
29 </div>
580670430fa2 blog/item: expand/reduce improvments:
Goffi <goffi@goffi.org>
parents: 42
diff changeset
30
0
9a31d2c02f47 SàT templates, initial commit
Goffi <goffi@goffi.org>
parents:
diff changeset
31 <header>
9a31d2c02f47 SàT templates, initial commit
Goffi <goffi@goffi.org>
parents:
diff changeset
32 {% block header %}
96
94b5806b9e2f blog/item: various improvments:
Goffi <goffi@goffi.org>
parents: 49
diff changeset
33 {# title and publication date link to a HTTP page if items_http_uri is set #}
94b5806b9e2f blog/item: various improvments:
Goffi <goffi@goffi.org>
parents: 49
diff changeset
34 {% set item_http_uri = items_http_uri.get(item.id) if items_http_uri is defined else none %}
94b5806b9e2f blog/item: various improvments:
Goffi <goffi@goffi.org>
parents: 49
diff changeset
35
94b5806b9e2f blog/item: various improvments:
Goffi <goffi@goffi.org>
parents: 49
diff changeset
36 <div class="title">
94b5806b9e2f blog/item: various improvments:
Goffi <goffi@goffi.org>
parents: 49
diff changeset
37 {% block blog_title scoped %}
94b5806b9e2f blog/item: various improvments:
Goffi <goffi@goffi.org>
parents: 49
diff changeset
38 {% set title = item.title_xhtml or item.title or '' %}
94b5806b9e2f blog/item: various improvments:
Goffi <goffi@goffi.org>
parents: 49
diff changeset
39 {% if item_http_uri %}
94b5806b9e2f blog/item: various improvments:
Goffi <goffi@goffi.org>
parents: 49
diff changeset
40 <a href="{{item_http_uri}}">{{title}}</a>
94b5806b9e2f blog/item: various improvments:
Goffi <goffi@goffi.org>
parents: 49
diff changeset
41 {% else %}
94b5806b9e2f blog/item: various improvments:
Goffi <goffi@goffi.org>
parents: 49
diff changeset
42 {{title}}
94b5806b9e2f blog/item: various improvments:
Goffi <goffi@goffi.org>
parents: 49
diff changeset
43 {% endif %}
94b5806b9e2f blog/item: various improvments:
Goffi <goffi@goffi.org>
parents: 49
diff changeset
44 {% endblock %}
94b5806b9e2f blog/item: various improvments:
Goffi <goffi@goffi.org>
parents: 49
diff changeset
45 </div>
94b5806b9e2f blog/item: various improvments:
Goffi <goffi@goffi.org>
parents: 49
diff changeset
46 {% block metadata scoped %}
16
8cdcbe0d7dee blog: various appareance improvments:
Goffi <goffi@goffi.org>
parents: 0
diff changeset
47 <div class="metadata">
49
f19e9f5e43b0 blog: moved items rendering to a macro + handle new date filter + handle identities
Goffi <goffi@goffi.org>
parents: 44
diff changeset
48 {% if identities is defined %}
f19e9f5e43b0 blog: moved items rendering to a macro + handle new date filter + handle identities
Goffi <goffi@goffi.org>
parents: 44
diff changeset
49 <span class="author">{{identities[item.author_jid].nick | default(item.author)}}</span>
f19e9f5e43b0 blog: moved items rendering to a macro + handle new date filter + handle identities
Goffi <goffi@goffi.org>
parents: 44
diff changeset
50 {% else %}
f19e9f5e43b0 blog: moved items rendering to a macro + handle new date filter + handle identities
Goffi <goffi@goffi.org>
parents: 44
diff changeset
51 <span class="author">{{item.author}}</span>
f19e9f5e43b0 blog: moved items rendering to a macro + handle new date filter + handle identities
Goffi <goffi@goffi.org>
parents: 44
diff changeset
52 {% endif %}
96
94b5806b9e2f blog/item: various improvments:
Goffi <goffi@goffi.org>
parents: 49
diff changeset
53 {% set published = item.published|date_fmt(fmt=dates_format) %}
94b5806b9e2f blog/item: various improvments:
Goffi <goffi@goffi.org>
parents: 49
diff changeset
54 {% if item_http_uri %}
94b5806b9e2f blog/item: various improvments:
Goffi <goffi@goffi.org>
parents: 49
diff changeset
55 <span class="blog_data"><a href="{{item_http_uri}}">{{published}}</a></span>
94b5806b9e2f blog/item: various improvments:
Goffi <goffi@goffi.org>
parents: 49
diff changeset
56 {% else %}
94b5806b9e2f blog/item: various improvments:
Goffi <goffi@goffi.org>
parents: 49
diff changeset
57 {{- published -}}
94b5806b9e2f blog/item: various improvments:
Goffi <goffi@goffi.org>
parents: 49
diff changeset
58 {% endif %}
16
8cdcbe0d7dee blog: various appareance improvments:
Goffi <goffi@goffi.org>
parents: 0
diff changeset
59 </div>
96
94b5806b9e2f blog/item: various improvments:
Goffi <goffi@goffi.org>
parents: 49
diff changeset
60 {% if item.tags %}
94b5806b9e2f blog/item: various improvments:
Goffi <goffi@goffi.org>
parents: 49
diff changeset
61 <div class="labels">
94b5806b9e2f blog/item: various improvments:
Goffi <goffi@goffi.org>
parents: 49
diff changeset
62 {% for tag in item.tags %}
94b5806b9e2f blog/item: various improvments:
Goffi <goffi@goffi.org>
parents: 49
diff changeset
63 <span>{{tag}}</span>
94b5806b9e2f blog/item: various improvments:
Goffi <goffi@goffi.org>
parents: 49
diff changeset
64 {% endfor %}
94b5806b9e2f blog/item: various improvments:
Goffi <goffi@goffi.org>
parents: 49
diff changeset
65 </div>
94b5806b9e2f blog/item: various improvments:
Goffi <goffi@goffi.org>
parents: 49
diff changeset
66 {% endif %}
16
8cdcbe0d7dee blog: various appareance improvments:
Goffi <goffi@goffi.org>
parents: 0
diff changeset
67 {% endblock metadata %}
0
9a31d2c02f47 SàT templates, initial commit
Goffi <goffi@goffi.org>
parents:
diff changeset
68 {% endblock header %}
9a31d2c02f47 SàT templates, initial commit
Goffi <goffi@goffi.org>
parents:
diff changeset
69 </header>
9a31d2c02f47 SàT templates, initial commit
Goffi <goffi@goffi.org>
parents:
diff changeset
70
34
5fd910d48192 blog/item: "text" class is added for non XHTML content
Goffi <goffi@goffi.org>
parents: 32
diff changeset
71 <div class="content{{' text' if not item.content_xhtml}}">
0
9a31d2c02f47 SàT templates, initial commit
Goffi <goffi@goffi.org>
parents:
diff changeset
72 {% block content %}
96
94b5806b9e2f blog/item: various improvments:
Goffi <goffi@goffi.org>
parents: 49
diff changeset
73 {{- item.content_xhtml or item.content|urlize or '' -}}
0
9a31d2c02f47 SàT templates, initial commit
Goffi <goffi@goffi.org>
parents:
diff changeset
74 {% endblock content %}
9a31d2c02f47 SàT templates, initial commit
Goffi <goffi@goffi.org>
parents:
diff changeset
75 </div>
16
8cdcbe0d7dee blog: various appareance improvments:
Goffi <goffi@goffi.org>
parents: 0
diff changeset
76
44
580670430fa2 blog/item: expand/reduce improvments:
Goffi <goffi@goffi.org>
parents: 42
diff changeset
77 {# and the bottom button to expand/reduce the article #}
580670430fa2 blog/item: expand/reduce improvments:
Goffi <goffi@goffi.org>
parents: 42
diff changeset
78 <div class="expand_box box_bottom" onclick="clicked_mh_fix('{{item.id}}')">
16
8cdcbe0d7dee blog: various appareance improvments:
Goffi <goffi@goffi.org>
parents: 0
diff changeset
79 <p>
44
580670430fa2 blog/item: expand/reduce improvments:
Goffi <goffi@goffi.org>
parents: 42
diff changeset
80 <span class='show'>{% trans %}Click to expand…{% endtrans %}</span>
580670430fa2 blog/item: expand/reduce improvments:
Goffi <goffi@goffi.org>
parents: 42
diff changeset
81 <span class='hide'>{% trans %}Click to reduce…{% endtrans %}</span>
16
8cdcbe0d7dee blog: various appareance improvments:
Goffi <goffi@goffi.org>
parents: 0
diff changeset
82 </p>
8cdcbe0d7dee blog: various appareance improvments:
Goffi <goffi@goffi.org>
parents: 0
diff changeset
83 </div>
30
69a2e3bf5e17 blog/item: if item is not in same language as current locale, item is hidden but will be shown on click.
Goffi <goffi@goffi.org>
parents: 24
diff changeset
84
0
9a31d2c02f47 SàT templates, initial commit
Goffi <goffi@goffi.org>
parents:
diff changeset
85 </article>
30
69a2e3bf5e17 blog/item: if item is not in same language as current locale, item is hidden but will be shown on click.
Goffi <goffi@goffi.org>
parents: 24
diff changeset
86
0
9a31d2c02f47 SàT templates, initial commit
Goffi <goffi@goffi.org>
parents:
diff changeset
87 {% endblock item %}