annotate sat_templates/templates/bulma/chat/message.html @ 385:941e4006ab6e

bulma (message): reactions + fixes: - add "reaction" button - fix attachments display - add reaction templates - add reactions to messages - fix "info" messages display
author Goffi <goffi@goffi.org>
date Wed, 22 Nov 2023 15:22:11 +0100
parents a5a80d761e3e
children e63fb06052ae
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
230
0e69b5843c2f theme: bulma theme first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
1 {% import 'components/avatar.html' as avatar with context %}
0e69b5843c2f theme: bulma theme first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
2
362
b2b859a62e70 bulma (chat): new templates and CSS for chat page.
Goffi <goffi@goffi.org>
parents: 235
diff changeset
3 <div id="{{msg.id}}" class="media is-chat-message msg_{{msg.type}} {{'own_msg' if msg.from_ == own_jid}}" style="padding: 0.5em;" role="listitem" aria-label="Chat Message">
385
941e4006ab6e bulma (message): reactions + fixes:
Goffi <goffi@goffi.org>
parents: 371
diff changeset
4 {%- if msg.type != "info" %}
230
0e69b5843c2f theme: bulma theme first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
5 {%- set author = identities[msg.from_].nicknames[0] | default(msg.from_) -%}
362
b2b859a62e70 bulma (chat): new templates and CSS for chat page.
Goffi <goffi@goffi.org>
parents: 235
diff changeset
6 <figure class="media-left pt-1">
230
0e69b5843c2f theme: bulma theme first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
7 {{ avatar.avatar(msg.from_, "is-32x32") }}
0e69b5843c2f theme: bulma theme first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
8 </figure>
0e69b5843c2f theme: bulma theme first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
9 {% endif -%}
362
b2b859a62e70 bulma (chat): new templates and CSS for chat page.
Goffi <goffi@goffi.org>
parents: 235
diff changeset
10 <div class="media-content is-relative">
230
0e69b5843c2f theme: bulma theme first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
11 <div class="content">
385
941e4006ab6e bulma (message): reactions + fixes:
Goffi <goffi@goffi.org>
parents: 371
diff changeset
12 {%- if msg.type != "info" %}
230
0e69b5843c2f theme: bulma theme first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
13 <nav class="level is-mobile is-marginless is-size-7">
0e69b5843c2f theme: bulma theme first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
14 <div class="level-left has-text-weight-bold">
0e69b5843c2f theme: bulma theme first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
15 <div class="level-item">
362
b2b859a62e70 bulma (chat): new templates and CSS for chat page.
Goffi <goffi@goffi.org>
parents: 235
diff changeset
16 <span class="author" id="msg_author_{{msg.id}}">{{author}}</span>
230
0e69b5843c2f theme: bulma theme first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
17 </div>
0e69b5843c2f theme: bulma theme first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
18 </div>
0e69b5843c2f theme: bulma theme first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
19 <div class="level-right is-italic">
0e69b5843c2f theme: bulma theme first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
20 <div class="level-item">
362
b2b859a62e70 bulma (chat): new templates and CSS for chat page.
Goffi <goffi@goffi.org>
parents: 235
diff changeset
21 <span class="date" id="msg_date_{{msg.id}}">{{msg.timestamp|date_fmt('auto_day')}}</span>
b2b859a62e70 bulma (chat): new templates and CSS for chat page.
Goffi <goffi@goffi.org>
parents: 235
diff changeset
22 <div id="status_icons_{{msg.id}}" class="status-icons level-item has-padding-left">
b2b859a62e70 bulma (chat): new templates and CSS for chat page.
Goffi <goffi@goffi.org>
parents: 235
diff changeset
23 {% if msg.encrypted %}
b2b859a62e70 bulma (chat): new templates and CSS for chat page.
Goffi <goffi@goffi.org>
parents: 235
diff changeset
24 {{ icon('lock-filled', cls='icon is-small has-text-success') }}
b2b859a62e70 bulma (chat): new templates and CSS for chat page.
Goffi <goffi@goffi.org>
parents: 235
diff changeset
25 {% else %}
b2b859a62e70 bulma (chat): new templates and CSS for chat page.
Goffi <goffi@goffi.org>
parents: 235
diff changeset
26 {{ icon('lock-open', cls='icon is-small has-text-danger') }}
b2b859a62e70 bulma (chat): new templates and CSS for chat page.
Goffi <goffi@goffi.org>
parents: 235
diff changeset
27 {% endif %}
b2b859a62e70 bulma (chat): new templates and CSS for chat page.
Goffi <goffi@goffi.org>
parents: 235
diff changeset
28 {% if msg.received %}
b2b859a62e70 bulma (chat): new templates and CSS for chat page.
Goffi <goffi@goffi.org>
parents: 235
diff changeset
29 {{ icon('ok', cls='icon is-small has-text-link') }}
b2b859a62e70 bulma (chat): new templates and CSS for chat page.
Goffi <goffi@goffi.org>
parents: 235
diff changeset
30 {% endif %}
b2b859a62e70 bulma (chat): new templates and CSS for chat page.
Goffi <goffi@goffi.org>
parents: 235
diff changeset
31 {% if msg.edited %}
b2b859a62e70 bulma (chat): new templates and CSS for chat page.
Goffi <goffi@goffi.org>
parents: 235
diff changeset
32 {{ icon('pencil', cls='icon is-small has-text-info') }}
b2b859a62e70 bulma (chat): new templates and CSS for chat page.
Goffi <goffi@goffi.org>
parents: 235
diff changeset
33 {% endif %}
b2b859a62e70 bulma (chat): new templates and CSS for chat page.
Goffi <goffi@goffi.org>
parents: 235
diff changeset
34 </div>
230
0e69b5843c2f theme: bulma theme first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
35 </div>
0e69b5843c2f theme: bulma theme first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
36 </div>
0e69b5843c2f theme: bulma theme first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
37 </nav>
0e69b5843c2f theme: bulma theme first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
38 {% endif -%}
385
941e4006ab6e bulma (message): reactions + fixes:
Goffi <goffi@goffi.org>
parents: 371
diff changeset
39 <p class="msg_body has-whitespace-pre-wrap {{ "has-text-info" if msg.type=="info" }}" id="msg_body_{{msg.id}}" style="margin: 0;">
363
cddac8502c4b chat/message: fix urlize escaping on nunjucks:
Goffi <goffi@goffi.org>
parents: 362
diff changeset
40 {{- msg.html or (msg.text|e|urlize|safe) -}}
230
0e69b5843c2f theme: bulma theme first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
41 </p>
364
095bd5b34080 chat: add templates for URL previews
Goffi <goffi@goffi.org>
parents: 363
diff changeset
42
095bd5b34080 chat: add templates for URL previews
Goffi <goffi@goffi.org>
parents: 363
diff changeset
43 <div class="url-previews is-hidden">
095bd5b34080 chat: add templates for URL previews
Goffi <goffi@goffi.org>
parents: 363
diff changeset
44 <div class="icon-container"></div>
095bd5b34080 chat: add templates for URL previews
Goffi <goffi@goffi.org>
parents: 363
diff changeset
45 </div>
095bd5b34080 chat: add templates for URL previews
Goffi <goffi@goffi.org>
parents: 363
diff changeset
46
362
b2b859a62e70 bulma (chat): new templates and CSS for chat page.
Goffi <goffi@goffi.org>
parents: 235
diff changeset
47 <div id="actions_{{msg.id}}" class="level is-mobile actions mb-0">
385
941e4006ab6e bulma (message): reactions + fixes:
Goffi <goffi@goffi.org>
parents: 371
diff changeset
48 {#{{ icon('share', cls='icon is-small action-button', id='msg_share_{{msg.id}}') }} #}
941e4006ab6e bulma (message): reactions + fixes:
Goffi <goffi@goffi.org>
parents: 371
diff changeset
49 {{ icon('smile', cls='icon is-small action-button reaction-button', id='msg_actions_{{msg.id}}') }}
941e4006ab6e bulma (message): reactions + fixes:
Goffi <goffi@goffi.org>
parents: 371
diff changeset
50 {{ icon('dot-3', cls='icon is-small action-button extra-button', id='msg_actions_{{msg.id}}') }}
362
b2b859a62e70 bulma (chat): new templates and CSS for chat page.
Goffi <goffi@goffi.org>
parents: 235
diff changeset
51 </div>
b2b859a62e70 bulma (chat): new templates and CSS for chat page.
Goffi <goffi@goffi.org>
parents: 235
diff changeset
52 <div id="msg_reactions_{{msg.id}}" style="margin-top: 0.5em;">
385
941e4006ab6e bulma (message): reactions + fixes:
Goffi <goffi@goffi.org>
parents: 371
diff changeset
53 {% if msg.extra.reactions is defined %}
941e4006ab6e bulma (message): reactions + fixes:
Goffi <goffi@goffi.org>
parents: 371
diff changeset
54 {% set reactions = msg.extra.get("reactions") %}
941e4006ab6e bulma (message): reactions + fixes:
Goffi <goffi@goffi.org>
parents: 371
diff changeset
55 {% include 'chat/reactions.html' %}
941e4006ab6e bulma (message): reactions + fixes:
Goffi <goffi@goffi.org>
parents: 371
diff changeset
56 {% endif %}
362
b2b859a62e70 bulma (chat): new templates and CSS for chat page.
Goffi <goffi@goffi.org>
parents: 235
diff changeset
57 </div>
b2b859a62e70 bulma (chat): new templates and CSS for chat page.
Goffi <goffi@goffi.org>
parents: 235
diff changeset
58 {% if msg.attachments %}
b2b859a62e70 bulma (chat): new templates and CSS for chat page.
Goffi <goffi@goffi.org>
parents: 235
diff changeset
59 <div class="message-attachments pt-2">
b2b859a62e70 bulma (chat): new templates and CSS for chat page.
Goffi <goffi@goffi.org>
parents: 235
diff changeset
60 {%- for attachment in msg.attachments %}
b2b859a62e70 bulma (chat): new templates and CSS for chat page.
Goffi <goffi@goffi.org>
parents: 235
diff changeset
61 <figure class="image message-attachment">
385
941e4006ab6e bulma (message): reactions + fixes:
Goffi <goffi@goffi.org>
parents: 371
diff changeset
62 {%- if not attachment.url -%}
941e4006ab6e bulma (message): reactions + fixes:
Goffi <goffi@goffi.org>
parents: 371
diff changeset
63 <div class="notification is-warning">
941e4006ab6e bulma (message): reactions + fixes:
Goffi <goffi@goffi.org>
parents: 371
diff changeset
64 <div class="is-size-6 has-text-weight-semibold mb-1">
941e4006ab6e bulma (message): reactions + fixes:
Goffi <goffi@goffi.org>
parents: 371
diff changeset
65 {% trans name=attachment.name %}Attachment: {{name}}{% endtrans %}
941e4006ab6e bulma (message): reactions + fixes:
Goffi <goffi@goffi.org>
parents: 371
diff changeset
66 </div>
941e4006ab6e bulma (message): reactions + fixes:
Goffi <goffi@goffi.org>
parents: 371
diff changeset
67
941e4006ab6e bulma (message): reactions + fixes:
Goffi <goffi@goffi.org>
parents: 371
diff changeset
68 <div class="is-size-7 mb-1">
941e4006ab6e bulma (message): reactions + fixes:
Goffi <goffi@goffi.org>
parents: 371
diff changeset
69 {% trans %}Cannot be opened as there are no sources available.{% endtrans %}
941e4006ab6e bulma (message): reactions + fixes:
Goffi <goffi@goffi.org>
parents: 371
diff changeset
70 </div>
941e4006ab6e bulma (message): reactions + fixes:
Goffi <goffi@goffi.org>
parents: 371
diff changeset
71
941e4006ab6e bulma (message): reactions + fixes:
Goffi <goffi@goffi.org>
parents: 371
diff changeset
72 </div>
941e4006ab6e bulma (message): reactions + fixes:
Goffi <goffi@goffi.org>
parents: 371
diff changeset
73 {%- else -%}
941e4006ab6e bulma (message): reactions + fixes:
Goffi <goffi@goffi.org>
parents: 371
diff changeset
74 {%- if attachment.media_type|media_type_main == 'image' %}
941e4006ab6e bulma (message): reactions + fixes:
Goffi <goffi@goffi.org>
parents: 371
diff changeset
75 <img src="{{attachment.url}}" alt="{{attachment.name}}">
941e4006ab6e bulma (message): reactions + fixes:
Goffi <goffi@goffi.org>
parents: 371
diff changeset
76 {%- else %}
941e4006ab6e bulma (message): reactions + fixes:
Goffi <goffi@goffi.org>
parents: 371
diff changeset
77 {{ icon('doc', cls='icon') }}
941e4006ab6e bulma (message): reactions + fixes:
Goffi <goffi@goffi.org>
parents: 371
diff changeset
78 {%- endif %}
941e4006ab6e bulma (message): reactions + fixes:
Goffi <goffi@goffi.org>
parents: 371
diff changeset
79 <figcaption class="has-text-centered is-size-7">
941e4006ab6e bulma (message): reactions + fixes:
Goffi <goffi@goffi.org>
parents: 371
diff changeset
80 <a href="{{attachment.url}}" target="_blank" class="has-text-grey">{{attachment.name}}</a>
941e4006ab6e bulma (message): reactions + fixes:
Goffi <goffi@goffi.org>
parents: 371
diff changeset
81 </figcaption>
941e4006ab6e bulma (message): reactions + fixes:
Goffi <goffi@goffi.org>
parents: 371
diff changeset
82 {%- endif -%}
362
b2b859a62e70 bulma (chat): new templates and CSS for chat page.
Goffi <goffi@goffi.org>
parents: 235
diff changeset
83 </figure>
b2b859a62e70 bulma (chat): new templates and CSS for chat page.
Goffi <goffi@goffi.org>
parents: 235
diff changeset
84 {%- endfor %}
b2b859a62e70 bulma (chat): new templates and CSS for chat page.
Goffi <goffi@goffi.org>
parents: 235
diff changeset
85 </div>
b2b859a62e70 bulma (chat): new templates and CSS for chat page.
Goffi <goffi@goffi.org>
parents: 235
diff changeset
86 {% endif %}
230
0e69b5843c2f theme: bulma theme first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
87 </div>
0e69b5843c2f theme: bulma theme first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
88 </div>
0e69b5843c2f theme: bulma theme first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
89 </div>