From 94c0b7c15920dae9ade5cdc79c7996dbfe82ba05 Mon Sep 17 00:00:00 2001 From: Yassine Doghri <yassine@doghri.fr> Date: Fri, 14 Oct 2022 12:50:25 +0000 Subject: [PATCH] feat(rss): add rss feed route without the `.xml` extension closes #247 --- app/Config/Routes.php | 6 ++++-- app/Entities/Podcast.php | 2 +- app/Models/PodcastModel.php | 2 +- modules/Admin/Controllers/PodcastImportController.php | 2 +- themes/cp_app/podcast/_partials/sidebar.php | 2 +- 5 files changed, 8 insertions(+), 6 deletions(-) diff --git a/app/Config/Routes.php b/app/Config/Routes.php index 69e68bd0f5..0153003737 100644 --- a/app/Config/Routes.php +++ b/app/Config/Routes.php @@ -185,11 +185,13 @@ $routes->group('@(:podcastHandle)', static function ($routes): void { }); }); $routes->head('feed.xml', 'FeedController/$1', [ - 'as' => 'podcast_feed', + 'as' => 'podcast-rss-feed', ]); $routes->get('feed.xml', 'FeedController/$1', [ - 'as' => 'podcast_feed', + 'as' => 'podcast-rss-feed', ]); + $routes->head('feed', 'FeedController/$1'); + $routes->get('feed', 'FeedController/$1'); }); // Other pages diff --git a/app/Entities/Podcast.php b/app/Entities/Podcast.php index 9472a5c707..22e5d3b17d 100644 --- a/app/Entities/Podcast.php +++ b/app/Entities/Podcast.php @@ -324,7 +324,7 @@ class Podcast extends Entity public function getFeedUrl(): string { - return url_to('podcast_feed', $this->attributes['handle']); + return url_to('podcast-rss-feed', $this->attributes['handle']); } /** diff --git a/app/Models/PodcastModel.php b/app/Models/PodcastModel.php index af3098d220..78d52672d0 100644 --- a/app/Models/PodcastModel.php +++ b/app/Models/PodcastModel.php @@ -550,7 +550,7 @@ class PodcastModel extends Model { if (! array_key_exists('guid', $data['data']) || $data['data']['guid'] === null) { helper('misc'); - $data['data']['guid'] = podcast_uuid(url_to('podcast_feed', $data['data']['handle'])); + $data['data']['guid'] = podcast_uuid(url_to('podcast-rss-feed', $data['data']['handle'])); } return $data; diff --git a/modules/Admin/Controllers/PodcastImportController.php b/modules/Admin/Controllers/PodcastImportController.php index 3433a9b78c..39b0f09a9a 100644 --- a/modules/Admin/Controllers/PodcastImportController.php +++ b/modules/Admin/Controllers/PodcastImportController.php @@ -143,7 +143,7 @@ class PodcastImportController extends BaseController 'guid' => $guid, 'handle' => $this->request->getPost('handle'), 'imported_feed_url' => $this->request->getPost('imported_feed_url'), - 'new_feed_url' => url_to('podcast_feed', $this->request->getPost('handle')), + 'new_feed_url' => url_to('podcast-rss-feed', $this->request->getPost('handle')), 'title' => (string) $feed->channel[0]->title, 'description_markdown' => $converter->convert($channelDescriptionHtml), 'description_html' => $channelDescriptionHtml, diff --git a/themes/cp_app/podcast/_partials/sidebar.php b/themes/cp_app/podcast/_partials/sidebar.php index 842eb22d0e..ead51a4bd6 100644 --- a/themes/cp_app/podcast/_partials/sidebar.php +++ b/themes/cp_app/podcast/_partials/sidebar.php @@ -1,7 +1,7 @@ <div data-sidebar-toggler="backdrop" class="absolute top-0 left-0 z-10 hidden w-full h-full bg-backdrop/75 md:hidden" role="button" tabIndex="0" aria-label="<?= lang('Common.close') ?>"></div> <aside id="podcast-sidebar" data-sidebar-toggler="sidebar" data-toggle-class="hidden" data-hide-class="hidden" class="z-20 hidden h-full col-span-1 col-start-2 row-start-1 p-4 py-6 shadow-2xl md:shadow-none md:block bg-base"> <div class="sticky z-10 bg-base top-12"> - <a href="<?= route_to('podcast_feed', esc($podcast->handle)) ?>" class="inline-flex items-center mb-6 text-sm font-semibold focus:ring-accent text-skin-muted hover:text-skin-base group" target="_blank" rel="noopener noreferrer"> + <a href="<?= $podcast->feed_url ?>" class="inline-flex items-center mb-6 text-sm font-semibold focus:ring-accent text-skin-muted hover:text-skin-base group" target="_blank" rel="noopener noreferrer"> <?= icon('rss', ' mr-2 bg-orange-500 text-xl text-white group-hover:bg-orange-700 p-1 w-6 h-6 inline-flex items-center justify-center rounded-lg') . lang('Podcast.feed') ?> </a> <?php if ( -- GitLab