[CARDS][Note] Separating complementary info as its own block

This commit is contained in:
Eliseu Amaro 2021-12-30 17:33:51 +00:00
parent 9a6bdf74dc
commit 34cc010136
Signed by: eliseuamaro
GPG Key ID: 96DA09D4B97BC2D5

View File

@ -23,7 +23,8 @@
</li> </li>
{% for current_action in get_note_actions(note) %} {% for current_action in get_note_actions(note) %}
<li> <li>
<a title="{{ current_action["title"] | trans }}" class="{{ current_action["classes"] }}" <a title="{{ current_action["title"] | trans }}"
class="{{ current_action["classes"] }}"
href="{{ current_action["url"] }}"></a> href="{{ current_action["url"] }}"></a>
</li> </li>
{% endfor %} {% endfor %}
@ -34,7 +35,8 @@
{% block note_replies %} {% block note_replies %}
{% if replies is defined and replies is not empty %} {% if replies is defined and replies is not empty %}
<div class="u-in-reply-to replies" tabindex="0" title="{{ 'Begin replies to ' | trans }}{{ nickname }}{{ '\'s note!' | trans }}"> <div class="u-in-reply-to replies" tabindex="0"
title="{{ 'Begin replies to ' | trans }}{{ nickname }}{{ '\'s note!' | trans }}">
<strong><small>{{ 'Replies to ' | trans }}{{ nickname }}</small></strong> <strong><small>{{ 'Replies to ' | trans }}{{ nickname }}</small></strong>
{% for conversation in replies %} {% for conversation in replies %}
{{ _self.macro_note(conversation['note'], conversation['replies']) }} {{ _self.macro_note(conversation['note'], conversation['replies']) }}
@ -47,9 +49,10 @@
{% block note_attachments %} {% block note_attachments %}
{% if hide_attachments is not defined %} {% if hide_attachments is not defined %}
{% if note.getAttachments() is not empty %} {% if note.getAttachments() is not empty %}
<section class="note-attachments" tabindex="0" title="{{ 'Note attachments.' | trans }}"> <section class="note-attachments" tabindex="0"
title="{{ 'Note attachments.' | trans }}">
{% for attachment in note.getAttachments() %} {% for attachment in note.getAttachments() %}
{% include '/cards/attachments/view.html.twig' with {'attachment': attachment, 'note': note, 'title': attachment.getBestTitle(note)} only%} {% include '/cards/attachments/view.html.twig' with {'attachment': attachment, 'note': note, 'title': attachment.getBestTitle(note)} only %}
{% endfor %} {% endfor %}
</section> </section>
{% endif %} {% endif %}
@ -69,7 +72,8 @@
{% endblock note_links %} {% endblock note_links %}
{% block note_text %} {% block note_text %}
<div class="note-text" tabindex="0" title="{{ 'Note text content.' | trans }}"> <div class="note-text" tabindex="0"
title="{{ 'Note text content.' | trans }}">
{{ note.getRendered() | raw }} {{ note.getRendered() | raw }}
</div> </div>
{% endblock note_text %} {% endblock note_text %}
@ -77,24 +81,29 @@
{% block note_author %} {% block note_author %}
{# Microformat's h-card properties indicates a face icon is a "u-logo" #} {# Microformat's h-card properties indicates a face icon is a "u-logo" #}
<a href="{{ actor_url }}"> <a href="{{ actor_url }}">
<header class="note-author-fullname" tabindex="0" title="{{ 'Begin a note by the user: ' | trans }} {{ nickname }}" > <header class="note-author-fullname" tabindex="0"
{% if fullname is not null %} title="{{ 'Begin a note by the user: ' | trans }} {{ nickname }}">
{{ fullname }} {% if fullname is not null %}
{% else %} {{ fullname }}
{{ nickname }} {% else %}
{% endif %} {{ nickname }}
</header> {% endif %}
</header>
</a> </a>
<small class="note-author-nickname"> <small class="note-author-nickname">
<a href="{{ actor_uri }}" class="note-author-url u-url">{{ mention }}</a> <a href="{{ actor_uri }}"
class="note-author-url u-url">{{ mention }}</a>
</small> </small>
{% endblock note_author %} {% endblock note_author %}
{% block note_sidebar %} {% block note_sidebar %}
<aside class="note-sidebar"> <aside class="note-sidebar">
{% set actor_avatar_dimensions = actor.getAvatarDimensions() %} {% set actor_avatar_dimensions = actor.getAvatarDimensions() %}
<img class="u-logo avatar" src="{{ note.getActorAvatarUrl() }}" alt="{{ nickname }}'s avatar" width="{{actor_avatar_dimensions['width']}}" height="{{actor_avatar_dimensions['height']}}"> <img class="u-logo avatar" src="{{ note.getActorAvatarUrl() }}"
alt="{{ nickname }}'s avatar"
width="{{ actor_avatar_dimensions['width'] }}"
height="{{ actor_avatar_dimensions['height'] }}">
</aside> </aside>
{% endblock note_sidebar %} {% endblock note_sidebar %}
@ -103,8 +112,10 @@
<div class="note-info-start"> <div class="note-info-start">
{{ block('note_author') }} {{ block('note_author') }}
<small class="note-conversation-info"> <small class="note-conversation-info">
<a href="{{ note.getConversationUrl() }}" class="note-conversation-url">{{ 'in conversation' | trans }}</a> <a href="{{ note.getConversationUrl() }}"
<a href="{{ note.getUrl() }}" class="note-url">{{ note.getModified() | ago }}</a> class="note-conversation-url">{{ 'in conversation' | trans }}</a>
<a href="{{ note.getUrl() }}"
class="note-url">{{ note.getModified() | ago }}</a>
</small> </small>
</div> </div>
@ -112,6 +123,33 @@
</div> </div>
{% endblock note_info %} {% endblock note_info %}
{% block note_complementary_info %}
{% for complementary_info in handle_event('AppendCardNote', {'note': note }) %}
<aside title="{{ 'Note\'s complementary information' | trans }}"
class="note-complementary">
{% set actor_count = complementary_info['actors'] | length %}
{% set counter = 0 %}
{% for complementary_info_actor in complementary_info['actors'] %}
{% if complementary_info_actor is defined %}
<a href="{{ complementary_info_actor.getUrl() }}">{{ complementary_info_actor.getNickname() }}{% if actor_count > 1 and counter < actor_count - 2 %}{{ ', ' | trans }}{% endif %}</a>
{% if counter == actor_count - 2 %}
{{ ' and ' | trans }}
{% endif %}
{% endif %}
{% set counter = counter + 1 %}
{% endfor %}
{% if complementary_info['action'] is defined and not null %}
{% if counter > 1 %}
{{ ' have ' | trans }}
{% else %}
{{ ' has ' | trans }}
{% endif %}
{{ complementary_info['action'] ~ ' this note' | trans }}
{% endif %}
</aside>
{% endfor %}
{% endblock note_complementary_info %}
{% macro macro_note(note, replies) %} {% macro macro_note(note, replies) %}
{% set actor = note.getActor() %} {% set actor = note.getActor() %}
{% set nickname = actor.getNickname() %} {% set nickname = actor.getNickname() %}
@ -133,30 +171,7 @@
</section> </section>
{{ block('note_replies') }} {{ block('note_replies') }}
{{ block('note_complementary_info') }}
{% for complementary_info in handle_event('AppendCardNote', {'note': note }) %}
<aside title="{{ 'Note\'s complementary information' | trans }}" class="note-complementary">
{% set actor_count = complementary_info['actors'] | length %}
{% set counter = 0 %}
{% for complementary_info_actor in complementary_info['actors'] %}
{% if complementary_info_actor is defined %}
<a href="{{ complementary_info_actor.getUrl() }}">{{complementary_info_actor.getNickname()}}{% if actor_count > 1 and counter < actor_count - 2 %}{{', ' | trans }}{% endif %}</a>
{% if counter == actor_count - 2 %}
{{ ' and ' | trans }}
{% endif %}
{% endif %}
{% set counter = counter + 1 %}
{% endfor %}
{% if complementary_info['action'] is defined and not null %}
{% if counter > 1 %}
{{ ' have ' | trans }}
{% else %}
{{ ' has ' | trans }}
{% endif %}
{{ complementary_info['action'] ~ ' this note' | trans }}
{% endif %}
</aside>
{% endfor %}
</div> </div>
</article> </article>