mirror of
https://github.com/YGGverse/Yoda.git
synced 2026-03-31 16:45:27 +00:00
fix connection data update
This commit is contained in:
parent
300cc6b8a2
commit
5b821996c5
3 changed files with 158 additions and 45 deletions
|
|
@ -23,20 +23,6 @@ class File
|
|||
Address $address
|
||||
): void
|
||||
{
|
||||
$this->_connection->setTitle(
|
||||
basename(
|
||||
$address->getPath()
|
||||
)
|
||||
);
|
||||
|
||||
$this->_connection->setSubtitle(
|
||||
$address->getPath()
|
||||
);
|
||||
|
||||
$this->_connection->setTooltip(
|
||||
$address->getPath()
|
||||
);
|
||||
|
||||
switch (true)
|
||||
{
|
||||
case ( // is directory
|
||||
|
|
@ -44,6 +30,29 @@ class File
|
|||
$address->getPath()
|
||||
)
|
||||
):
|
||||
// Set MIME
|
||||
$this->_connection->setMime(
|
||||
Filesystem::MIME_TEXT_GEMINI
|
||||
);
|
||||
|
||||
// Set title
|
||||
$this->_connection->setTitle(
|
||||
basename(
|
||||
$address->getPath()
|
||||
)
|
||||
);
|
||||
|
||||
// Set subtitle
|
||||
$this->_connection->setSubtitle(
|
||||
$address->getPath()
|
||||
);
|
||||
|
||||
// Set tooltip
|
||||
$this->_connection->setTooltip(
|
||||
$address->getPath()
|
||||
);
|
||||
|
||||
// Set data
|
||||
$tree = [];
|
||||
|
||||
foreach ($list as $item)
|
||||
|
|
@ -60,10 +69,6 @@ class File
|
|||
);
|
||||
}
|
||||
|
||||
$this->_connection->setMime(
|
||||
Filesystem::MIME_TEXT_GEMINI
|
||||
);
|
||||
|
||||
$this->_connection->setData(
|
||||
implode(
|
||||
PHP_EOL,
|
||||
|
|
@ -78,14 +83,6 @@ class File
|
|||
) && is_readable(
|
||||
$address->getPath()
|
||||
):
|
||||
$this->_connection->setData(
|
||||
strval(
|
||||
file_get_contents(
|
||||
$address->getPath()
|
||||
)
|
||||
)
|
||||
);
|
||||
|
||||
// Detect MIME type
|
||||
switch (true)
|
||||
{
|
||||
|
|
@ -100,18 +97,62 @@ class File
|
|||
default: $mime = Filesystem::MIME_TEXT_GEMINI;
|
||||
}
|
||||
|
||||
// Set MIME
|
||||
$this->_connection->setMime(
|
||||
$mime
|
||||
);
|
||||
|
||||
// Set title
|
||||
$this->_connection->setTitle(
|
||||
basename(
|
||||
$address->getPath()
|
||||
)
|
||||
);
|
||||
|
||||
// Set subtitle
|
||||
$this->_connection->setSubtitle(
|
||||
$mime
|
||||
);
|
||||
|
||||
// Set tooltip
|
||||
$this->_connection->setTooltip(
|
||||
$address->getPath()
|
||||
);
|
||||
|
||||
// Set data
|
||||
$this->_connection->setData(
|
||||
strval(
|
||||
file_get_contents(
|
||||
$address->getPath()
|
||||
)
|
||||
)
|
||||
);
|
||||
|
||||
break;
|
||||
|
||||
default:
|
||||
|
||||
// Set MIME
|
||||
$this->_connection->setMime(
|
||||
Filesystem::MIME_TEXT_GEMINI
|
||||
);
|
||||
|
||||
// Set title
|
||||
$this->_connection->setTitle(
|
||||
_('Failure')
|
||||
);
|
||||
|
||||
// Set subtitle
|
||||
$this->_connection->setSubtitle(
|
||||
$address->getPath()
|
||||
);
|
||||
|
||||
// Set tooltip
|
||||
$this->_connection->setTooltip(
|
||||
$address->getPath()
|
||||
);
|
||||
|
||||
// Set data
|
||||
$this->_connection->setData(
|
||||
_('Could not open location')
|
||||
);
|
||||
|
|
|
|||
|
|
@ -36,6 +36,8 @@ class Gemini
|
|||
)
|
||||
);
|
||||
|
||||
// @TODO reset title, mime, data
|
||||
|
||||
// Route status code
|
||||
// https://geminiprotocol.net/docs/protocol-specification.gmi#status-codes
|
||||
switch ($response->getCode())
|
||||
|
|
@ -70,11 +72,6 @@ class Gemini
|
|||
|
||||
case 20: // ok
|
||||
|
||||
// Update content data
|
||||
$this->_connection->setData(
|
||||
$response->getBody()
|
||||
);
|
||||
|
||||
// Detect MIME type
|
||||
switch (true)
|
||||
{
|
||||
|
|
@ -93,10 +90,31 @@ class Gemini
|
|||
default: $mime = Filesystem::MIME_TEXT_GEMINI;
|
||||
}
|
||||
|
||||
// Set MIME
|
||||
$this->_connection->setMime(
|
||||
$mime
|
||||
);
|
||||
|
||||
// Set title
|
||||
$this->_connection->setTitle(
|
||||
$address->getHost()
|
||||
);
|
||||
|
||||
// Set subtitle
|
||||
$this->_connection->setSubtitle(
|
||||
$response->getMeta()
|
||||
);
|
||||
|
||||
// Set tooltip
|
||||
$this->_connection->setTooltip(
|
||||
$address->get()
|
||||
);
|
||||
|
||||
// Update content data
|
||||
$this->_connection->setData(
|
||||
$response->getBody()
|
||||
);
|
||||
|
||||
break;
|
||||
|
||||
case 31: // redirect
|
||||
|
|
@ -106,6 +124,17 @@ class Gemini
|
|||
_('Redirect...')
|
||||
);
|
||||
|
||||
$this->_connection->setSubtitle(
|
||||
$response->getMeta()
|
||||
);
|
||||
|
||||
$this->_connection->setTooltip(
|
||||
sprintf(
|
||||
_('Redirect to %s'),
|
||||
$response->getMeta()
|
||||
)
|
||||
);
|
||||
|
||||
$this->_connection->setData(
|
||||
sprintf(
|
||||
'=> %s',
|
||||
|
|
@ -113,6 +142,10 @@ class Gemini
|
|||
)
|
||||
);
|
||||
|
||||
$this->_connection->setMime(
|
||||
Filesystem::MIME_TEXT_GEMINI
|
||||
);
|
||||
|
||||
break;
|
||||
|
||||
default:
|
||||
|
|
@ -121,6 +154,24 @@ class Gemini
|
|||
_('Oops!')
|
||||
);
|
||||
|
||||
$this->_connection->setSubtitle(
|
||||
sprintf(
|
||||
'Could not open request (code: %d)',
|
||||
intval(
|
||||
$response->getCode()
|
||||
)
|
||||
)
|
||||
);
|
||||
|
||||
$this->_connection->setTooltip(
|
||||
sprintf(
|
||||
'Could not open request (code: %d)',
|
||||
intval(
|
||||
$response->getCode()
|
||||
)
|
||||
)
|
||||
);
|
||||
|
||||
$this->_connection->setData(
|
||||
sprintf(
|
||||
'Could not open request (code: %d)',
|
||||
|
|
|
|||
|
|
@ -33,16 +33,6 @@ class Nex
|
|||
|
||||
if ($response)
|
||||
{
|
||||
$this->_connection->setTitle(
|
||||
strval(
|
||||
$address->getHost()
|
||||
)
|
||||
);
|
||||
|
||||
$this->_connection->setData(
|
||||
$response
|
||||
);
|
||||
|
||||
// Detect MIME type
|
||||
switch (true)
|
||||
{
|
||||
|
|
@ -57,23 +47,54 @@ class Nex
|
|||
default: $mime = Filesystem::MIME_TEXT_PLAIN;
|
||||
}
|
||||
|
||||
// Set MIME
|
||||
$this->_connection->setMime(
|
||||
$mime
|
||||
);
|
||||
|
||||
// Set title
|
||||
$this->_connection->setTitle(
|
||||
$address->getHost()
|
||||
);
|
||||
|
||||
// Set subtitle
|
||||
$this->_connection->setSubtitle(
|
||||
$mime
|
||||
);
|
||||
|
||||
// Set tooltip
|
||||
$this->_connection->setTooltip(
|
||||
$address->get()
|
||||
);
|
||||
|
||||
$this->_connection->setData(
|
||||
$response
|
||||
);
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
$this->_connection->setMime(
|
||||
Filesystem::MIME_TEXT_PLAIN
|
||||
);
|
||||
|
||||
$this->_connection->setTitle(
|
||||
_('Oops!')
|
||||
);
|
||||
|
||||
$this->_connection->setData(
|
||||
_('Could not open request')
|
||||
$this->_connection->setSubtitle(
|
||||
sprintf(
|
||||
_('Could not open request - %s'),
|
||||
$address->get()
|
||||
)
|
||||
);
|
||||
|
||||
$this->_connection->setMime(
|
||||
Filesystem::MIME_TEXT_GEMINI
|
||||
$this->_connection->setTooltip(
|
||||
$address->get()
|
||||
);
|
||||
|
||||
$this->_connection->setData(
|
||||
_('Could not open request')
|
||||
);
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue