From 5662210a2d7fac31960105e167d03e7285fa33ea Mon Sep 17 00:00:00 2001 From: Hugo Sales Date: Sat, 1 Jan 2022 21:52:30 +0000 Subject: [PATCH] [UI][PLUGIN][Directory] Use a single template for all results --- plugins/Directory/Controller/Directory.php | 14 +++++++------ .../{people.html.twig => actors.html.twig} | 9 +++++---- .../templates/directory/groups.html.twig | 20 ------------------- 3 files changed, 13 insertions(+), 30 deletions(-) rename plugins/Directory/templates/directory/{people.html.twig => actors.html.twig} (68%) delete mode 100644 plugins/Directory/templates/directory/groups.html.twig diff --git a/plugins/Directory/Controller/Directory.php b/plugins/Directory/Controller/Directory.php index b34aa6129b..f786002b15 100644 --- a/plugins/Directory/Controller/Directory.php +++ b/plugins/Directory/Controller/Directory.php @@ -40,7 +40,7 @@ class Directory extends FeedController * Function responsible for displaying a list of actors of a given * $actor_type, sorted by the `order_by` GET parameter, if given */ - private function impl(Request $request, string $template, int $actor_type): array + private function impl(Request $request, int $actor_type, string $title, string $empty_message): array { if ($actor_type !== Actor::PERSON && $actor_type !== Actor::GROUP) { throw new BugFoundException("Unimplemented for actor type: {$actor_type}"); @@ -130,19 +130,21 @@ class Directory extends FeedController // -------- *** -------- return [ - '_template' => $template, - 'actors' => $query_fn($actor_type), - 'page' => $page, + '_template' => 'directory/actors.html.twig', + 'actors' => $query_fn($actor_type), + 'title' => $title, + 'empty_message' => $empty_message, + 'page' => $page, ]; } public function people(Request $request): array { - return $this->impl($request, 'directory/people.html.twig', Actor::PERSON); + return $this->impl($request, Actor::PERSON, title: _m('People'), empty_message: _m('No people here')); } public function groups(Request $request): array { - return $this->impl($request, 'directory/groups.html.twig', Actor::GROUP); + return $this->impl($request, Actor::GROUP, title: _m('Groups'), empty_message: _m('No groups here')); } } diff --git a/plugins/Directory/templates/directory/people.html.twig b/plugins/Directory/templates/directory/actors.html.twig similarity index 68% rename from plugins/Directory/templates/directory/people.html.twig rename to plugins/Directory/templates/directory/actors.html.twig index be702ae2ec..be73125ff3 100644 --- a/plugins/Directory/templates/directory/people.html.twig +++ b/plugins/Directory/templates/directory/actors.html.twig @@ -1,10 +1,10 @@ {% extends 'stdgrid.html.twig' %} -{% block title %}Actors{% endblock %} +{% block title %}{{ title }}{% endblock %} {% block body %}
-

{{ "Actors" | trans }}

+

{{ title }}

{% if actors is defined and actors is not empty %} @@ -12,9 +12,10 @@ {% block profile_view %}{% include 'cards/profile/view.html.twig' %}{% endblock profile_view %}
{% endfor %} +

{% trans %}Page: %page%{% endtrans %}

{% else %} -

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

+

{{ empty_message }}

{% endif %}
-{% endblock body %} \ No newline at end of file +{% endblock body %} diff --git a/plugins/Directory/templates/directory/groups.html.twig b/plugins/Directory/templates/directory/groups.html.twig deleted file mode 100644 index 81876c9437..0000000000 --- a/plugins/Directory/templates/directory/groups.html.twig +++ /dev/null @@ -1,20 +0,0 @@ -{% extends 'stdgrid.html.twig' %} - -{% block title %}Groups{% endblock %} - -{% block body %} -
-

{{ "Groups" | trans }}

- -
- {% if groups is defined and groups is not empty %} - {% for actor in groups %} - {% block profile_view %}{% include 'cards/profile/view.html.twig' %}{% endblock profile_view %} -
- {% endfor %} - {% else %} -

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

- {% endif %} -
-
-{% endblock body %} \ No newline at end of file