From d96a55cb773e19067801d22ac14fd7139b6cd6f5 Mon Sep 17 00:00:00 2001 From: ghost Date: Tue, 5 Dec 2023 22:13:39 +0200 Subject: [PATCH] add room name to meta title --- src/Controller/RoomController.php | 27 ++++++++++++++++++++------ templates/default/layout.html.twig | 2 +- templates/default/room/index.html.twig | 1 + 3 files changed, 23 insertions(+), 7 deletions(-) diff --git a/src/Controller/RoomController.php b/src/Controller/RoomController.php index 746d8b4..4472831 100644 --- a/src/Controller/RoomController.php +++ b/src/Controller/RoomController.php @@ -53,11 +53,31 @@ class RoomController extends AbstractController $this->getParameter('app.kevacoin.password') ); + // Set title + $name = $request->get('namespace'); + + foreach ((array) $client->kevaListNamespaces() as $namespace) + { + // Get current room namespace (could be third-party) + if ($namespace['namespaceId'] == $request->get('namespace')) + { + $name = $namespace['displayName']; + + break; + } + } + // Get room feed $feed = []; foreach ((array) $client->kevaFilter($request->get('namespace')) as $post) { + // Skip values with meta keys + if (false !== stripos($post['key'], '_KEVA_')) + { + continue; + } + // Set identicon if not anonymous user if ($post['key'] === 'anonymous') { @@ -84,12 +104,6 @@ class RoomController extends AbstractController $icon = $identicon->getImageDataUri('webp'); } - // Skip values with meta keys - if (false !== stripos($post['key'], '_KEVA_')) - { - continue; - } - // Get more info if ($transaction = $client->getRawTransaction($post['txid'])) { @@ -126,6 +140,7 @@ class RoomController extends AbstractController return $this->render( 'default/room/index.html.twig', [ + 'name' => $name, 'feed' => $feed, 'request' => $request ] diff --git a/templates/default/layout.html.twig b/templates/default/layout.html.twig index 7fc6ccf..b7dae60 100644 --- a/templates/default/layout.html.twig +++ b/templates/default/layout.html.twig @@ -2,7 +2,7 @@ - {% block head_title %}{{ 'KevaChat' | trans }}{% endblock %} + {% block head_title_content %}{{ 'KevaChat' | trans }}{% endblock %} diff --git a/templates/default/room/index.html.twig b/templates/default/room/index.html.twig index 3bb578f..c64fcdd 100644 --- a/templates/default/room/index.html.twig +++ b/templates/default/room/index.html.twig @@ -1,4 +1,5 @@ {% extends 'default/layout.html.twig' %} +{% block head_title_content %}{{ name }} - {{ 'KevaChat' | trans }}{% endblock %} {% block main_content %} {{ render(