From e70acd5c3bd4821fde74579eb6a11e0ba956d7ea Mon Sep 17 00:00:00 2001 From: Eliseu Amaro Date: Wed, 16 Feb 2022 03:01:25 +0000 Subject: [PATCH] [UTIL][HTML] HTML abstraction class was extended with a more specialised Heading class This little abstraction layer made it a bit easier to add a different title to a Note or Actor Feed Collection template, from whichever controller that uses it. Please, bear in mind, that abstract templates such as those found in Components\Collection, may act in a very 'declarative' way upon using them. This makes it difficult to dynamically choose what type of header is used without undergoing a mining operation in the likes of a pyramid of doom. Hence, this _little_ change. --- .../templates/collection/actors.html.twig | 6 +- .../templates/collection/notes.html.twig | 14 +-- .../Conversation/Controller/Conversation.php | 12 ++- components/Feed/Controller/Feeds.php | 18 ++-- components/Group/Group.php | 16 ++-- components/Link/Link.php | 2 +- components/Person/Controller/PersonFeed.php | 11 ++- components/Search/Controller/Search.php | 3 + plugins/ActivityPub/Util/Model/Note.php | 17 ++-- public/assets/default_theme/pages/feeds.css | 9 ++ .../assets/default_theme/widgets/sections.css | 2 +- src/Core/GNUsocial.php | 6 +- src/Util/Formatting.php | 1 - src/Util/HTML.php | 55 ++++++------ src/Util/HTML/Heading.php | 90 +++++++++++++++++++ templates/actor/view.html.twig | 12 +-- templates/cards/blocks/note.html.twig | 18 +--- templates/cards/blocks/profile.html.twig | 42 +++++---- tests/Util/HTMLTest.php | 25 +++--- 19 files changed, 227 insertions(+), 132 deletions(-) create mode 100644 src/Util/HTML/Heading.php diff --git a/components/Collection/templates/collection/actors.html.twig b/components/Collection/templates/collection/actors.html.twig index 3ed9ffcec8..d469b8b7b0 100644 --- a/components/Collection/templates/collection/actors.html.twig +++ b/components/Collection/templates/collection/actors.html.twig @@ -4,7 +4,11 @@ {% block body %}
-

{{ title }}

+
+ {% if actors_feed_title is defined %} + {{ actors_feed_title.getHtml() }} + {% endif %} +
{% set prepend_actors_collection = handle_event('PrependActorsCollection', request) %} {% for widget in prepend_actors_collection %} diff --git a/components/Collection/templates/collection/notes.html.twig b/components/Collection/templates/collection/notes.html.twig index 1df64928d3..b646779490 100644 --- a/components/Collection/templates/collection/notes.html.twig +++ b/components/Collection/templates/collection/notes.html.twig @@ -14,18 +14,10 @@ {% endfor %} {% if notes is defined %} -
+
{% set current_path = app.request.get('_route') %} - {% if page_title is defined %} - {% if current_path starts with 'feed_' or 'conversation' in current_path %} -

{{ page_title | trans }}

- {% endif %} - {% else %} - {% if current_path starts with 'search' %} -

{{ 'Notes found' | trans }}

- {% else %} -

{{ 'Notes' | trans }}

- {% endif %} + {% if notes_feed_title is defined %} + {{ notes_feed_title.getHtml() }} {% endif %}