|
|
@ -165,31 +165,50 @@ $server->setHandler( |
|
|
|
{ |
|
|
|
{ |
|
|
|
if (str_starts_with($path, $directory) && $path != $directory) |
|
|
|
if (str_starts_with($path, $directory) && $path != $directory) |
|
|
|
{ |
|
|
|
{ |
|
|
|
|
|
|
|
// Init H1 |
|
|
|
|
|
|
|
$h1 = null; |
|
|
|
|
|
|
|
|
|
|
|
// Init this directory URI |
|
|
|
// Init this directory URI |
|
|
|
$uri = $filesystem->getDirectoryUriByPath( |
|
|
|
$uri = $filesystem->getDirectoryUriByPath( |
|
|
|
$path |
|
|
|
$path |
|
|
|
); |
|
|
|
); |
|
|
|
|
|
|
|
|
|
|
|
// Parse URI segments |
|
|
|
// Skip sections deeper this level |
|
|
|
$segments = []; |
|
|
|
if (substr_count($uri, ':') > ($_uri ? substr_count($_uri, ':') + 1 : 0)) |
|
|
|
foreach ((array) explode(':', $uri) as $segment) |
|
|
|
|
|
|
|
{ |
|
|
|
{ |
|
|
|
$segments[] = $segment; |
|
|
|
continue; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// Set default section alias |
|
|
|
// Get section names |
|
|
|
$alias = empty($_uri) ? $config->string->main : ''; |
|
|
|
$segments = []; |
|
|
|
|
|
|
|
|
|
|
|
// Find section name if exists in index file |
|
|
|
foreach ((array) explode(':', $uri) as $segment) |
|
|
|
if ($file = $filesystem->getPagePathByUri($uri . ':' . end($segments))) |
|
|
|
|
|
|
|
{ |
|
|
|
{ |
|
|
|
$alias = $reader->getH1( |
|
|
|
$segments[] = $segment; |
|
|
|
$reader->toGemini( |
|
|
|
|
|
|
|
file_get_contents( |
|
|
|
// Find section index if exists |
|
|
|
$file |
|
|
|
if ($file = $filesystem->getPagePathByUri(implode(':', $segments) . ':' . $segment)) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
$h1 = $reader->getH1( |
|
|
|
|
|
|
|
$reader->toGemini( |
|
|
|
|
|
|
|
file_get_contents( |
|
|
|
|
|
|
|
$file |
|
|
|
|
|
|
|
) |
|
|
|
) |
|
|
|
) |
|
|
|
) |
|
|
|
); |
|
|
|
); |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Find section page if exists |
|
|
|
|
|
|
|
else if ($file = $filesystem->getPagePathByUri(implode(':', $segments))) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
$h1 = $reader->getH1( |
|
|
|
|
|
|
|
$reader->toGemini( |
|
|
|
|
|
|
|
file_get_contents( |
|
|
|
|
|
|
|
$file |
|
|
|
|
|
|
|
) |
|
|
|
|
|
|
|
) |
|
|
|
|
|
|
|
); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// Register section link |
|
|
|
// Register section link |
|
|
@ -198,12 +217,12 @@ $server->setHandler( |
|
|
|
$config->gemini->server->host, |
|
|
|
$config->gemini->server->host, |
|
|
|
$config->gemini->server->port == 1965 ? null : ':' . $config->gemini->server->port, |
|
|
|
$config->gemini->server->port == 1965 ? null : ':' . $config->gemini->server->port, |
|
|
|
$uri, |
|
|
|
$uri, |
|
|
|
$alias |
|
|
|
$h1 |
|
|
|
); |
|
|
|
); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// Append sections list if exist |
|
|
|
// Append sections |
|
|
|
if ($sections) |
|
|
|
if ($sections) |
|
|
|
{ |
|
|
|
{ |
|
|
|
// Keep unique |
|
|
|
// Keep unique |
|
|
|