diff --git a/src/Controller/Network.php b/src/Controller/Network.php index 33abd01efe..7ea60dcbf3 100644 --- a/src/Controller/Network.php +++ b/src/Controller/Network.php @@ -141,8 +141,21 @@ END; public function actors(Request $request) { - return [ - '_template' => 'network/public.html.twig', - ]; + if (Common::isLoggedIn()) { + $user_id = Common::ensureLoggedIn()->getId(); + + return [ + '_template' => 'network/actors.html.twig', + 'actors' => DB::dql('select a from App\Entity\GSActor a ' . + 'where a.id != :id ' . + 'order by a.created DESC', ['id' => $user_id]), + ]; + } else { + return [ + '_template' => 'network/actors.html.twig', + 'actors' => DB::dql('select a from App\Entity\GSActor a ' . + 'order by a.created DESC'), + ]; + } } } diff --git a/src/Entity/GSActor.php b/src/Entity/GSActor.php index a75f6773d1..af4005e73f 100644 --- a/src/Entity/GSActor.php +++ b/src/Entity/GSActor.php @@ -24,6 +24,7 @@ namespace App\Entity; use App\Core\Cache; use App\Core\DB\DB; use App\Core\Entity; +use App\Core\Event; use App\Core\UserRoles; use DateTimeInterface; use Functional as F; @@ -204,6 +205,13 @@ class GSActor extends Entity // }}} Autocode + public function getAvatarUrl() + { + $url = null; + Event::handle('get_avatar_url', [$this->getNickname(), &$url]); + return $url; + } + public static function getFromId(int $id): ?self { return Cache::get('gsactor-id-' . $id, function () use ($id) { diff --git a/templates/network/actors.html.twig b/templates/network/actors.html.twig index 04ad8b45cc..b670e8afbb 100644 --- a/templates/network/actors.html.twig +++ b/templates/network/actors.html.twig @@ -25,9 +25,90 @@ {% endblock %} {% block body %} - - - +
+ {% if post_form is defined %} + {{ form_start(post_form) }} +
+
+
+ {{ form_label(post_form.to) }} +
+
+ {{ form_widget(post_form.to) }} +
+
+
+
+
+ {{ form_row(post_form.visibility) }} +
+
+ {% for tab in tabs %} + {{ tab['title'] }} + {% endfor %} +
+
+
+
+ {{ form_row(post_form.content) }} +
+
+
+
+ {{ form_widget(post_form.attachments) }} + +
+
+ {{ form_row(post_form.post) }} +
+
+
+
+ {{ form_end(post_form) }} + {% endif %} +
+ +
+ +
+
+ {% if actors is defined and actors is not empty %} + {% for actor in actors %} + {% include '/note/actor.html.twig' with {'actor': actor, 'have_user': have_user} only %} + {% endfor %} + {% else %} +

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

+ {% endif %} +
+
+
+
+
{% endblock body %} {% block javascripts %}{% endblock %} \ No newline at end of file diff --git a/templates/network/public.html.twig b/templates/network/public.html.twig index 4bc41a004a..199e295555 100644 --- a/templates/network/public.html.twig +++ b/templates/network/public.html.twig @@ -90,6 +90,9 @@
  • Network
  • +
  • + Actors +
  • {% for tab in main_nav_tabs %}
  • {{ tab['title'] }} diff --git a/templates/note/actor.html.twig b/templates/note/actor.html.twig new file mode 100644 index 0000000000..50930205ae --- /dev/null +++ b/templates/note/actor.html.twig @@ -0,0 +1,29 @@ +
    +
    + {% set nickname = actor.getNickname() %} +
    + {{ nickname }}'s avatar +
    +
    + {{ nickname }} + {% set actor_tags = actor.getSelfTags() %} +
    + {% if actor_tags %} + {% for tag in actor_tags %} + #{{ tag }} + {% endfor %} + {% else %} + {{ '(No tags)' | trans }} + {% endif %} +
    +
    + {% set actor_bio = actor.getBio() %} +
    + {% if actor_bio %} +

    {{ actor_bio }}

    + {% else %} +

    {{ '(No bio)' | trans }}

    + {% endif %} +
    +
    +