From 0d5f100a255895680b34866744a751e26fd9d536 Mon Sep 17 00:00:00 2001 From: ghost Date: Sun, 4 Feb 2024 11:38:12 +0200 Subject: [PATCH] add aliases info, remove deprecated settings --- example/config.json | 12 +++++---- src/server.php | 63 ++++++++++++++++++++++++++++++++++++++++++++- 2 files changed, 69 insertions(+), 6 deletions(-) diff --git a/example/config.json b/example/config.json index bad0051..92c33cf 100644 --- a/example/config.json +++ b/example/config.json @@ -41,13 +41,14 @@ }, "dokuwiki": { - "uri": - { - "home":"start" - }, "url": { - "source":"http://.." + "source":"http://..", + "alias": + { + "gemini://..":"", + "gemini://..":"" + } } }, "string": @@ -63,6 +64,7 @@ "nothing":"Nothing found by this request", "main":"Main page", "source":"Source", + "alias":"Alias", "welcome":"About", "about":"=> https://github.com/YGGverse/dokuwiki-gemini-server GitHub" } diff --git a/src/server.php b/src/server.php index 8f90471..f23531b 100644 --- a/src/server.php +++ b/src/server.php @@ -307,6 +307,29 @@ $server->setHandler( // Append about info $lines[] = $config->string->about; + // Append about info + $lines[] = $config->string->about; + + // Append aliases + if ($config->dokuwiki->url->alias) + { + $lines[] = sprintf( + '## %s', + $config->string->alias + ); + + foreach ($config->dokuwiki->url->alias as $base => $name) + { + $lines[] = sprintf( + '=> %s/%s %s', + $base, + $matches[1], + $name + ); + } + } + + // Build content $response->setContent( implode( PHP_EOL, @@ -456,6 +479,25 @@ $server->setHandler( // Append about info $lines[] = $config->string->about; + // Append aliases + if ($config->dokuwiki->url->alias) + { + $lines[] = sprintf( + '## %s', + $config->string->alias + ); + + foreach ($config->dokuwiki->url->alias as $base => $name) + { + $lines[] = sprintf( + '=> %s/%s %s', + $base, + $matches[1], + $name + ); + } + } + // Merge lines $content = implode( PHP_EOL, @@ -578,7 +620,7 @@ $server->setHandler( // Append about info $lines[] = sprintf( '## %s', - $config->string->resources + $config->string->actions ); // Append search link @@ -597,6 +639,25 @@ $server->setHandler( // Append about info $lines[] = $config->string->about; + // Append aliases + if ($config->dokuwiki->url->alias) + { + $lines[] = sprintf( + '## %s', + $config->string->alias + ); + + foreach ($config->dokuwiki->url->alias as $base => $name) + { + $lines[] = sprintf( + '=> %s/%s %s', + $base, + $matches[1], + $name + ); + } + } + // Merge lines $content = implode( PHP_EOL,