[ENTITY][Note] Add getLanguageLocale() and getNoteLanguageShortDisplay()

[CARDS][Note] Render note's language short display

[PLUGINS] Bring back titles to Reply, Repeat and Favourite actions
This commit is contained in:
Eliseu Amaro 2021-12-02 15:05:23 +00:00
parent d044039272
commit 37ef8cddfa
Signed by: eliseuamaro
GPG Key ID: 96DA09D4B97BC2D5
6 changed files with 33 additions and 3 deletions

View File

@ -76,6 +76,7 @@ class Favourite extends NoteHandlerPlugin
$extra_classes = $is_favourite ? 'note-actions-set' : 'note-actions-unset';
$favourite_action = [
'url' => $favourite_action_url,
'title' => $is_favourite ? 'Remove this note from favourites' : 'Favourite this note!',
'classes' => "button-container favourite-button-container {$extra_classes}",
'id' => 'favourite-button-container-' . $note->getId(),
];

View File

@ -85,6 +85,7 @@ class Repeat extends NoteHandlerPlugin
$extra_classes = $is_repeat ? 'note-actions-set' : 'note-actions-unset';
$repeat_action = [
'url' => $repeat_action_url,
'title' => $is_repeat ? 'Remove this repeat' : 'Repeat this note!',
'classes' => "button-container repeat-button-container {$extra_classes}",
'id' => 'repeat-button-container-' . $note->getId(),
];

View File

@ -72,6 +72,7 @@ class Reply extends NoteHandlerPlugin
$reply_action = [
'url' => $reply_action_url,
'title' => 'Reply to this note!',
'classes' => 'button-container reply-button-container note-actions-unset',
'id' => 'reply-button-container-' . $note->getId(),
];

View File

@ -341,3 +341,15 @@ embed header {
.note-complementary a {
font-weight: bold;
}
.h-entry-language {
position: relative;
float: right;
background: var(--border);
padding: 5px;
font-size: var(--default);
color: var(--foreground);
margin-right: var(--smaller);
margin-bottom: var(--smaller);
border-radius: var(--smaller);
}

View File

@ -217,6 +217,16 @@ class Note extends Entity
return Avatar::getAvatarUrl($this->getActorId(), $size);
}
public function getNoteLanguageShortDisplay(): string
{
return Language::getFromId($this->language_id)->getShortDisplay();
}
public function getLanguageLocale(): string
{
return Language::getFromId($this->language_id)->getLocale();
}
public static function getAllNotesByActor(Actor $actor): array
{
return DB::sql(

View File

@ -2,7 +2,7 @@
{% if app.user or note_actions_hide is defined %}
<div class="note-actions">
{% for current_action in get_note_actions(note) %}
<a class="{{ current_action["classes"] }}" href="{{ current_action["url"] }}"></a>
<a title="{{ current_action["title"] | trans }}" class="{{ current_action["classes"] }}" href="{{ current_action["url"] }}"></a>
{% endfor %}
</div>
{% endif %}
@ -74,8 +74,9 @@
{% set fullname = note.getActorFullname() %}
{% set actor = note.getActor() %}
{% set actor_url = actor.getUrl() %}
{% set note_language = note.getNoteLanguageShortDisplay() %}
<article class="h-entry hentry note">
<article class="h-entry hentry note" lang={{ note.getLanguageLocale() }}>
{{ block('note_sidebar') }}
<div class="note-wrapper">
<div tabindex="0" title="{{ 'Begin a note by the user: ' | trans }} {{ nickname }}." class="note-info">
@ -90,12 +91,16 @@
</section>
{% for block in handle_event('AppendCardNote', {'note': note, 'actor': note.getActor() }) %}
<aside class="note-complementary">
<aside title="{{ 'Note\'s complementary information' | trans }}" class="note-complementary">
{{ block | raw }}
</aside>
{% endfor %}
{{ block('note_replies') }}
{% if note_language is defined and note_language is not empty %}
<div title="{{ 'Note\'s language' | trans }}" class="h-entry-language">{{ note_language }}</div>
{% endif %}
</div>
</article>
{% endmacro macro_note %}