mirror of
https://github.com/YGGverse/Yoda.git
synced 2026-03-31 16:45:27 +00:00
draft file:// features
This commit is contained in:
parent
36beb20134
commit
40caa36024
1 changed files with 68 additions and 1 deletions
|
|
@ -99,7 +99,70 @@ class Address
|
|||
{
|
||||
case 'file':
|
||||
|
||||
// @TODO
|
||||
if (file_exists($address->getPath()) && is_readable($address->getPath()))
|
||||
{
|
||||
switch ($address->getPath())
|
||||
{
|
||||
case is_dir($address->getPath()):
|
||||
|
||||
// @TODO build fs listing
|
||||
|
||||
break;
|
||||
|
||||
case str_ends_with($address->getPath(), '.gmi'):
|
||||
|
||||
$title = null;
|
||||
|
||||
$this->content->data->setValue(
|
||||
file_get_contents( // @TODO format relative links
|
||||
$address->getPath()
|
||||
),
|
||||
$title
|
||||
);
|
||||
|
||||
if ($title) // detect title by document h1
|
||||
{
|
||||
$this->title->gtk->set_text(
|
||||
$title
|
||||
);
|
||||
}
|
||||
|
||||
$this->statusbar->gtk->set_text(
|
||||
null
|
||||
);
|
||||
|
||||
break;
|
||||
|
||||
default:
|
||||
|
||||
$this->title->gtk->set_text(
|
||||
'Oops!'
|
||||
);
|
||||
|
||||
$this->content->data->setValue(
|
||||
'File extension not supported'
|
||||
);
|
||||
|
||||
$this->statusbar->gtk->set_text(
|
||||
null
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
$this->title->gtk->set_text(
|
||||
'Failure'
|
||||
);
|
||||
|
||||
$this->content->data->setValue(
|
||||
'Could not open file'
|
||||
);
|
||||
|
||||
$this->statusbar->gtk->set_text(
|
||||
'Resource not found or not readable'
|
||||
);
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
|
|
@ -217,6 +280,10 @@ class Address
|
|||
)
|
||||
)
|
||||
);
|
||||
|
||||
$this->statusbar->gtk->set_text(
|
||||
null
|
||||
);
|
||||
}
|
||||
|
||||
$this->tab->window->header->setTitle(
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue