diff --git a/plugins/Repeat/Repeat.php b/plugins/Repeat/Repeat.php index c4ac7b3f34..3bd7f79996 100644 --- a/plugins/Repeat/Repeat.php +++ b/plugins/Repeat/Repeat.php @@ -31,6 +31,7 @@ use App\Core\Modules\NoteHandlerPlugin; use App\Entity\Note; use App\Util\Common; use App\Util\Exception\RedirectException; +use App\Util\Formatting; use Symfony\Component\HttpFoundation\Request; class Repeat extends NoteHandlerPlugin @@ -77,6 +78,17 @@ class Repeat extends NoteHandlerPlugin return Event::next; } + public function onOverrideTemplateImport(string $current_template, string $default, string &$response) + { + switch ($current_template) { + case '/network/feed.html.twig': + $response = "plugins/repeat/cards/note/view.html.twig"; + return Event::stop; + } + + return Event::next; + } + public function onAddRoute(RouteLoader $r): bool { // Add/remove note to/from repeats diff --git a/plugins/Repeat/templates/plugins/repeat/cards/note/view.html.twig b/plugins/Repeat/templates/plugins/repeat/cards/note/view.html.twig new file mode 100644 index 0000000000..62ebfd64a2 --- /dev/null +++ b/plugins/Repeat/templates/plugins/repeat/cards/note/view.html.twig @@ -0,0 +1,22 @@ +{% extends '/cards/note/view.html.twig' %} + +{% macro macro_note(note, replies) %} + {% set nickname = note.getActorNickname() %} + {% set fullname = note.getActorFullname() %} + {% set actor_url = note.getActor().getUrl() %} + {% set repeat_of = note.getRepeatOf() %} + +
+ {{ block('note_sidebar') }} +
+
+ {{ block('note_author') }} + {{ block('note_actions') }} +
+ + {{ block('note_replies') }} +
+
+{% endmacro macro_note %} \ No newline at end of file diff --git a/src/Twig/Extension.php b/src/Twig/Extension.php index 4c7c0b2331..08d50d6afe 100644 --- a/src/Twig/Extension.php +++ b/src/Twig/Extension.php @@ -69,6 +69,7 @@ class Extension extends AbstractExtension new TwigFunction('config', [Runtime::class, 'getConfig']), new TwigFunction('icon', [Runtime::class, 'embedSvgIcon'], ['needs_environment' => true]), new TwigFunction('is_firefox', [Runtime::class, 'isFirefox']), + new TwigFunction('handle_override_template_import', [Runtime::class, 'handleOverrideTemplateImport']), ]; } } diff --git a/src/Twig/Runtime.php b/src/Twig/Runtime.php index 4bd43e5919..de8ad7eab7 100644 --- a/src/Twig/Runtime.php +++ b/src/Twig/Runtime.php @@ -125,6 +125,15 @@ class Runtime implements RuntimeExtensionInterface, EventSubscriberInterface return $var instanceof $instance; } + public function handleOverrideTemplateImport(string $template, string $default_import): string + { + $result = ''; + if (Event::handle('OverrideTemplateImport', [$template, $default_import, &$result]) !== Event::stop) { + $result = $default_import; + } + return $result; + } + // ---------------------------------------------------------- /** diff --git a/templates/network/feed.html.twig b/templates/network/feed.html.twig index 2bee320800..0be1f49e57 100644 --- a/templates/network/feed.html.twig +++ b/templates/network/feed.html.twig @@ -1,5 +1,6 @@ {% extends 'stdgrid.html.twig' %} -{% import "/cards/note/view.html.twig" as noteView %} +{% set override_import = handle_override_template_import('/network/feed.html.twig', '/cards/note/view.html.twig') %} +{% import override_import as noteView %} {% block title %}{% if page_title is defined %}{{ page_title | trans }}{% endif %}{% endblock %} @@ -14,8 +15,10 @@
{% if notes is defined and notes is not empty %} {% for conversation in notes %} - {{ noteView.macro_note(conversation['note'], conversation['replies']) }} -
+ {% block current_note %} + {{ noteView.macro_note(conversation['note'], conversation['replies']) }} +
+ {% endblock current_note %} {% endfor %} {% else %}

{% trans %}No notes here.{% endtrans %}