From e2f904446626a1df2a7fbfe15545d7a0b4bfb1dc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rafa=C5=82=20Toborek?= Date: Thu, 28 Nov 2024 00:20:28 +0100 Subject: [PATCH] Added feed_url param in configuration --- config/general.ini.dist | 11 +++++++---- src/lib/Provider/GeneralConfiguration.php | 3 ++- src/lib/Value/General.php | 11 ++++++++++- src/templates/page.phtml | 2 +- 4 files changed, 20 insertions(+), 7 deletions(-) diff --git a/config/general.ini.dist b/config/general.ini.dist index bf8c69b..3910b86 100644 --- a/config/general.ini.dist +++ b/config/general.ini.dist @@ -1,13 +1,13 @@ -; Main page/channel title +; main page/channel title title= -; Main page/channel description +; main page/channel description description= -; Link to the home page included in the RSS channel +; link to the home page included in the RSS channel link= -; Copyright value used in RSS channel +; copyright value used in RSS channel copyright= ; RSS channel/page language (eg. `pl`) @@ -28,3 +28,6 @@ limit= ; prefix used when generating item GUID (eg. `guid-`) guid_prefix= + +; if set then overrides default feed URL displayed on the bottom of the page +feed_url= diff --git a/src/lib/Provider/GeneralConfiguration.php b/src/lib/Provider/GeneralConfiguration.php index 15246ec..8efc05a 100644 --- a/src/lib/Provider/GeneralConfiguration.php +++ b/src/lib/Provider/GeneralConfiguration.php @@ -30,7 +30,8 @@ public function __construct(string $filename) (int) $ini['icon_height'], $ini['date_format'], (int) $ini['limit'], - $ini['guid_prefix'] + $ini['guid_prefix'], + $ini['feed_url'] ); } diff --git a/src/lib/Value/General.php b/src/lib/Value/General.php index b8e7fdd..d8268d9 100644 --- a/src/lib/Value/General.php +++ b/src/lib/Value/General.php @@ -6,7 +6,7 @@ class General { - public function __construct(private readonly string $title, private readonly string $description, private readonly string $link, private readonly string $language, private readonly string $copyright, private readonly string $icon, private readonly int $iconWidth, private readonly int $iconHeight, private readonly string $dateFormat, private readonly int $limit, private readonly string $guidPrefix) + public function __construct(private readonly string $title, private readonly string $description, private readonly string $link, private readonly string $language, private readonly string $copyright, private readonly string $icon, private readonly int $iconWidth, private readonly int $iconHeight, private readonly string $dateFormat, private readonly int $limit, private readonly string $guidPrefix, private readonly string $feedUrl) { } @@ -70,6 +70,15 @@ public function getGuidPrefix(): string return $this->guidPrefix; } + public function getFeedUrl(): string + { + if (!empty($this->feedUrl)) { + return $this->feedUrl; + } + + return '/?xml'; + } + public function getCurrentHostname(): string { return sprintf( diff --git a/src/templates/page.phtml b/src/templates/page.phtml index 2182278..e33a976 100644 --- a/src/templates/page.phtml +++ b/src/templates/page.phtml @@ -55,7 +55,7 @@