From 8944bd27920033bb1949a156b9e57b3dc7566010 Mon Sep 17 00:00:00 2001 From: yggverse Date: Thu, 18 Apr 2024 13:24:38 +0300 Subject: [PATCH] add optional base postfix to the page title --- config.json | 4 ++++ src/Entity/Tab/Page.php | 17 +++++++++++++++++ 2 files changed, 21 insertions(+) diff --git a/config.json b/config.json index a5ac4382..512ea50a 100644 --- a/config.json +++ b/config.json @@ -33,6 +33,10 @@ "ellipsize": { "mode":3 + }, + "postfix": + { + "hostname":true } }, "redirect": diff --git a/src/Entity/Tab/Page.php b/src/Entity/Tab/Page.php index 293072e3..b8cec057 100644 --- a/src/Entity/Tab/Page.php +++ b/src/Entity/Tab/Page.php @@ -834,6 +834,23 @@ class Page ?string $value = null ): void { + // Append hostname postfix + if ($this->config->title->postfix->hostname && str_starts_with($this->request->get_text(), 'gemini://')) + { + $address = new \Yggverse\Net\Address( + $this->request->get_text() + ); + + if ($address->getHost()) + { + $value = sprintf( + '%s - %s', + $value, + $address->getHost() + ); + } + } + // Build new tab label on title length reached if ($value && mb_strlen($value) > $this->config->title->width->chars) {