draft file:// features

This commit is contained in:
yggverse 2024-07-03 18:05:06 +03:00
parent 36beb20134
commit 40caa36024

View file

@ -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(