From d300c7b836380ee1a3d9a1cb45862c1d185d10f6 Mon Sep 17 00:00:00 2001 From: yggverse Date: Mon, 8 Jul 2024 05:18:59 +0300 Subject: [PATCH] init next protocol support --- .../Browser/Container/Tab/Page/Content.php | 65 ++++++++++++++++++- 1 file changed, 63 insertions(+), 2 deletions(-) diff --git a/src/Entity/Browser/Container/Tab/Page/Content.php b/src/Entity/Browser/Container/Tab/Page/Content.php index 6895ba93..5e224cd8 100644 --- a/src/Entity/Browser/Container/Tab/Page/Content.php +++ b/src/Entity/Browser/Container/Tab/Page/Content.php @@ -163,7 +163,66 @@ class Content case 'nex': - // @TODO + $client = new \Yggverse\Nex\Client; + + if ($response = $client->request($address->get())) + { + // Detect content type + switch (true) + { + case in_array( + pathinfo( + strval( + $address->getPath() + ), + PATHINFO_EXTENSION + ), + [ + 'gmi', + 'gemini' + ] + ): + + $title = null; + + $this->data->setGemtext( + $response, + $title + ); + + $this->page->title->setValue( + $title ? sprintf( + '%s - %s', + $title, + $address->getHost() + ) : $address->getHost() + ); + + break; + + default: + + $this->data->setPlain( + $response + ); + + $this->page->title->setValue( + $address->getHost() + ); + } + } + + else + { + $this->page->title->setValue( + 'Failure', + 'could not open resource' + ); + + $this->data->setPlain( + 'Requested resource not available!' + ); + } break; @@ -208,7 +267,9 @@ class Content case in_array( pathinfo( - $address->getPath(), + strval( + $address->getPath() + ), PATHINFO_EXTENSION ), [