mirror of
https://github.com/YGGverse/Yoda.git
synced 2026-04-01 09:05:27 +00:00
init next protocol support
This commit is contained in:
parent
f6a7edc6b4
commit
d300c7b836
1 changed files with 63 additions and 2 deletions
|
|
@ -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
|
||||
),
|
||||
[
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue