[PLUGIN][Directory] Make it list groups

This commit is contained in:
Diogo Peralta Cordeiro 2021-12-27 17:10:58 +00:00
parent de148c1f78
commit d03572e366
Signed by: diogo
GPG Key ID: 18D2D35001FBFAB0
4 changed files with 19 additions and 46 deletions

View File

@ -24,6 +24,7 @@ declare(strict_types = 1);
namespace Plugin\Directory\Controller; namespace Plugin\Directory\Controller;
use App\Core\DB\DB; use App\Core\DB\DB;
use App\Entity\Actor;
use Component\Feed\Util\FeedController; use Component\Feed\Util\FeedController;
use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\Request;
@ -38,7 +39,7 @@ class Directory extends FeedController
{ {
return [ return [
'_template' => 'directory/actors.html.twig', '_template' => 'directory/actors.html.twig',
'actors' => DB::dql('select a from actor a order by a.nickname ASC'), 'actors' => DB::findBy(Actor::class, ['type' => Actor::PERSON], order_by: ['created' => 'DESC', 'nickname' => 'ASC']),
]; ];
} }
@ -51,7 +52,7 @@ class Directory extends FeedController
{ {
return [ return [
'_template' => 'directory/groups.html.twig', '_template' => 'directory/groups.html.twig',
'groups' => DB::dql('select g from group g order by g.nickname ASC'), 'groups' => DB::findBy(Actor::class, ['type' => Actor::GROUP], order_by: ['created' => 'DESC', 'nickname' => 'ASC']),
]; ];
} }
} }

View File

@ -35,8 +35,8 @@ class Directory extends Plugin
*/ */
public function onAddRoute(RouteLoader $r) public function onAddRoute(RouteLoader $r)
{ {
$r->connect('directory_actors', '/actors', [Controller\Directory::class, 'actors']); $r->connect('directory_actors', '/directory/actors', [Controller\Directory::class, 'actors']);
$r->connect('directory_groups', '/groups', [Controller\Directory::class, 'groups']); $r->connect('directory_groups', '/directory/groups', [Controller\Directory::class, 'groups']);
return Event::next; return Event::next;
} }

View File

@ -1,31 +0,0 @@
{% extends 'stdgrid.html.twig' %}
{% set nickname = group.getNickname() %}
{% block title %}{{ nickname }}'s page{% endblock %}
{% block body %}
<div class="group">
<div class="group-content">
<a href="{{ group.getHomepage() }}">
<div class="group-info">
<div class="group-img">
<img class="icon icon-group" src="{{ group.getStreamLogo() }}" alt="{{ nickname }}'s logo">
</div>
<div class="group-nickname">
<b id="nick">{{ nickname }}</b>
</div>
</div>
</a>
{% set group_description = group.getDescription() %}
<div class="group-description">
{% if group_description %}
<p>{{ group_description }}</p>
{% else %}
<p>{{ '(No description)' | trans }}</p>
{% endif %}
</div>
</div>
</div>
{% endblock body %}

View File

@ -3,15 +3,18 @@
{% block title %}Groups{% endblock %} {% block title %}Groups{% endblock %}
{% block body %} {% block body %}
<div class="feed"> <section class="section-widget section-padding">
<div class="groups"> <h2 class="section-title">{{ "Groups" | trans }}</h2>
{% if groups is defined and groups is not empty %}
{% for group in groups %} <div class="section-padding">
{% include 'directory/group.html.twig' with {'group': group, 'have_user': have_user} only %} {% if groups is defined and groups is not empty %}
{% endfor %} {% for actor in groups %}
{% else %} {% block profile_view %}{% include 'cards/profile/view.html.twig' %}{% endblock profile_view %}
<h1>{% trans %}No groups here.{% endtrans %}</h1> <hr>
{% endif %} {% endfor %}
</div> {% else %}
<h1>{% trans %}No groups here.{% endtrans %}</h1>
{% endif %}
</div> </div>
</section>
{% endblock body %} {% endblock body %}