|
|
@ -36,6 +36,8 @@ class Gemini |
|
|
|
) |
|
|
|
) |
|
|
|
); |
|
|
|
); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// @TODO reset title, mime, data |
|
|
|
|
|
|
|
|
|
|
|
// Route status code |
|
|
|
// Route status code |
|
|
|
// https://geminiprotocol.net/docs/protocol-specification.gmi#status-codes |
|
|
|
// https://geminiprotocol.net/docs/protocol-specification.gmi#status-codes |
|
|
|
switch ($response->getCode()) |
|
|
|
switch ($response->getCode()) |
|
|
@ -70,11 +72,6 @@ class Gemini |
|
|
|
|
|
|
|
|
|
|
|
case 20: // ok |
|
|
|
case 20: // ok |
|
|
|
|
|
|
|
|
|
|
|
// Update content data |
|
|
|
|
|
|
|
$this->_connection->setData( |
|
|
|
|
|
|
|
$response->getBody() |
|
|
|
|
|
|
|
); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Detect MIME type |
|
|
|
// Detect MIME type |
|
|
|
switch (true) |
|
|
|
switch (true) |
|
|
|
{ |
|
|
|
{ |
|
|
@ -93,10 +90,31 @@ class Gemini |
|
|
|
default: $mime = Filesystem::MIME_TEXT_GEMINI; |
|
|
|
default: $mime = Filesystem::MIME_TEXT_GEMINI; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Set MIME |
|
|
|
$this->_connection->setMime( |
|
|
|
$this->_connection->setMime( |
|
|
|
$mime |
|
|
|
$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; |
|
|
|
break; |
|
|
|
|
|
|
|
|
|
|
|
case 31: // redirect |
|
|
|
case 31: // redirect |
|
|
@ -106,6 +124,17 @@ class Gemini |
|
|
|
_('Redirect...') |
|
|
|
_('Redirect...') |
|
|
|
); |
|
|
|
); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$this->_connection->setSubtitle( |
|
|
|
|
|
|
|
$response->getMeta() |
|
|
|
|
|
|
|
); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$this->_connection->setTooltip( |
|
|
|
|
|
|
|
sprintf( |
|
|
|
|
|
|
|
_('Redirect to %s'), |
|
|
|
|
|
|
|
$response->getMeta() |
|
|
|
|
|
|
|
) |
|
|
|
|
|
|
|
); |
|
|
|
|
|
|
|
|
|
|
|
$this->_connection->setData( |
|
|
|
$this->_connection->setData( |
|
|
|
sprintf( |
|
|
|
sprintf( |
|
|
|
'=> %s', |
|
|
|
'=> %s', |
|
|
@ -113,6 +142,10 @@ class Gemini |
|
|
|
) |
|
|
|
) |
|
|
|
); |
|
|
|
); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$this->_connection->setMime( |
|
|
|
|
|
|
|
Filesystem::MIME_TEXT_GEMINI |
|
|
|
|
|
|
|
); |
|
|
|
|
|
|
|
|
|
|
|
break; |
|
|
|
break; |
|
|
|
|
|
|
|
|
|
|
|
default: |
|
|
|
default: |
|
|
@ -121,6 +154,24 @@ class Gemini |
|
|
|
_('Oops!') |
|
|
|
_('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( |
|
|
|
$this->_connection->setData( |
|
|
|
sprintf( |
|
|
|
sprintf( |
|
|
|
'Could not open request (code: %d)', |
|
|
|
'Could not open request (code: %d)', |
|
|
|