From 37ef8cddfa3d94512303f99ed6a0223e39a48eed Mon Sep 17 00:00:00 2001 From: Eliseu Amaro Date: Thu, 2 Dec 2021 15:05:23 +0000 Subject: [PATCH] [ENTITY][Note] Add getLanguageLocale() and getNoteLanguageShortDisplay() [CARDS][Note] Render note's language short display [PLUGINS] Bring back titles to Reply, Repeat and Favourite actions --- plugins/Favourite/Favourite.php | 1 + plugins/Repeat/Repeat.php | 1 + plugins/Reply/Reply.php | 1 + public/assets/default_theme/css/pages/feeds.css | 12 ++++++++++++ src/Entity/Note.php | 10 ++++++++++ templates/cards/note/view.html.twig | 11 ++++++++--- 6 files changed, 33 insertions(+), 3 deletions(-) diff --git a/plugins/Favourite/Favourite.php b/plugins/Favourite/Favourite.php index ca7f0d78f2..6b247cb726 100644 --- a/plugins/Favourite/Favourite.php +++ b/plugins/Favourite/Favourite.php @@ -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(), ]; diff --git a/plugins/Repeat/Repeat.php b/plugins/Repeat/Repeat.php index a517ea8f54..c702764a26 100644 --- a/plugins/Repeat/Repeat.php +++ b/plugins/Repeat/Repeat.php @@ -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(), ]; diff --git a/plugins/Reply/Reply.php b/plugins/Reply/Reply.php index f49360a3ff..988c8cd82b 100644 --- a/plugins/Reply/Reply.php +++ b/plugins/Reply/Reply.php @@ -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(), ]; diff --git a/public/assets/default_theme/css/pages/feeds.css b/public/assets/default_theme/css/pages/feeds.css index defcc14ffb..7372317278 100644 --- a/public/assets/default_theme/css/pages/feeds.css +++ b/public/assets/default_theme/css/pages/feeds.css @@ -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); +} diff --git a/src/Entity/Note.php b/src/Entity/Note.php index 62efafb69b..c1de2d09a6 100644 --- a/src/Entity/Note.php +++ b/src/Entity/Note.php @@ -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( diff --git a/templates/cards/note/view.html.twig b/templates/cards/note/view.html.twig index 1763b4df58..d2f7fa2378 100644 --- a/templates/cards/note/view.html.twig +++ b/templates/cards/note/view.html.twig @@ -2,7 +2,7 @@ {% if app.user or note_actions_hide is defined %}
{% for current_action in get_note_actions(note) %} - + {% endfor %}
{% endif %} @@ -74,8 +74,9 @@ {% set fullname = note.getActorFullname() %} {% set actor = note.getActor() %} {% set actor_url = actor.getUrl() %} + {% set note_language = note.getNoteLanguageShortDisplay() %} -
+
{{ block('note_sidebar') }}
@@ -90,12 +91,16 @@ {% for block in handle_event('AppendCardNote', {'note': note, 'actor': note.getActor() }) %} -
{% endmacro macro_note %}