From 57e459e187ed048430f4137172e22396cd02bf81 Mon Sep 17 00:00:00 2001 From: "Guy Martin (Dwev)" Date: Wed, 24 Apr 2024 10:03:20 +0000 Subject: [PATCH] feat: support podcast:txt tag with verify use case closes #468 --- ...4-04-18-160000_add_podcasts_verify_txt.php | 34 ++++++++++++++ app/Helpers/rss_helper.php | 6 +++ app/Models/PodcastModel.php | 1 + .../Admin/Controllers/PodcastController.php | 4 ++ modules/Admin/Language/en/Podcast.php | 3 ++ themes/cp_admin/podcast/create.php | 11 ++++- themes/cp_admin/podcast/edit.php | 45 ++++++++++++------- 7 files changed, 86 insertions(+), 18 deletions(-) create mode 100644 app/Database/Migrations/2024-04-18-160000_add_podcasts_verify_txt.php diff --git a/app/Database/Migrations/2024-04-18-160000_add_podcasts_verify_txt.php b/app/Database/Migrations/2024-04-18-160000_add_podcasts_verify_txt.php new file mode 100644 index 00000000..339d3ae7 --- /dev/null +++ b/app/Database/Migrations/2024-04-18-160000_add_podcasts_verify_txt.php @@ -0,0 +1,34 @@ + [ + 'type' => 'TEXT', + 'null' => true, + 'after' => 'location_osm', + ], + ]; + + $this->forge->addColumn('podcasts', $fields); + } + + public function down(): void + { + $this->forge->dropColumn('podcasts', 'verify_txt'); + } +} diff --git a/app/Helpers/rss_helper.php b/app/Helpers/rss_helper.php index 3f85b053..dcfe4b2e 100644 --- a/app/Helpers/rss_helper.php +++ b/app/Helpers/rss_helper.php @@ -121,6 +121,12 @@ if (! function_exists('get_rss_feed')) { ->addAttribute('owner', $podcast->owner_email); } + if ($podcast->verify_txt !== null) { + $channel + ->addChild('txt', $podcast->verify_txt, $podcastNamespace) + ->addAttribute('purpose', 'verify'); + } + if ($podcast->imported_feed_url !== null) { $channel->addChild('previousUrl', $podcast->imported_feed_url, $podcastNamespace); } diff --git a/app/Models/PodcastModel.php b/app/Models/PodcastModel.php index 4372b1f4..6dae5b04 100644 --- a/app/Models/PodcastModel.php +++ b/app/Models/PodcastModel.php @@ -61,6 +61,7 @@ class PodcastModel extends Model 'location_name', 'location_geo', 'location_osm', + 'verify_txt', 'payment_pointer', 'custom_rss', 'is_published_on_hubs', diff --git a/modules/Admin/Controllers/PodcastController.php b/modules/Admin/Controllers/PodcastController.php index bc483235..bb6ff352 100644 --- a/modules/Admin/Controllers/PodcastController.php +++ b/modules/Admin/Controllers/PodcastController.php @@ -224,6 +224,7 @@ class PodcastController extends BaseController 'location' => $this->request->getPost('location_name') === '' ? null : new Location( $this->request->getPost('location_name') ), + 'verify_txt' => $this->request->getPost('verify_txt'), 'custom_rss_string' => $this->request->getPost('custom_rss'), 'is_blocked' => $this->request->getPost('block') === 'yes', 'is_completed' => $this->request->getPost('complete') === 'yes', @@ -320,6 +321,9 @@ class PodcastController extends BaseController $this->podcast->location = $this->request->getPost('location_name') === '' ? null : new Location( $this->request->getPost('location_name') ); + $this->podcast->verify_txt = $this->request->getPost('verify_txt') === '' ? null : $this->request->getPost( + 'verify_txt' + ); $this->podcast->custom_rss_string = $this->request->getPost('custom_rss'); $this->podcast->new_feed_url = $this->request->getPost('new_feed_url') === '' ? null : $this->request->getPost( 'new_feed_url' diff --git a/modules/Admin/Language/en/Podcast.php b/modules/Admin/Language/en/Podcast.php index d02b6cf4..ff0daebc 100644 --- a/modules/Admin/Language/en/Podcast.php +++ b/modules/Admin/Language/en/Podcast.php @@ -138,6 +138,9 @@ return [ 'If you need RSS tags that Castopod does not handle, set them here.', 'custom_rss' => 'Custom RSS tags for the podcast', 'custom_rss_hint' => 'This will be injected within the ❬channel❭ tag.', + 'verify_txt' => 'Ownership verification TXT', + 'verify_txt_hint' => 'Rather than relying on email, certain third-party services may confirm your podcast ownership by requesting you to embed a verification text within your feed.', + 'verify_txt_helper' => 'This text is injected into a tag.', 'new_feed_url' => 'New feed URL', 'new_feed_url_hint' => 'Use this field when you move to another domain or podcast hosting platform. By default, the value is set to the current RSS URL if the podcast is imported.', 'old_feed_url' => 'Old feed URL', diff --git a/themes/cp_admin/podcast/create.php b/themes/cp_admin/podcast/create.php index 7f09adf0..d1a483c2 100644 --- a/themes/cp_admin/podcast/create.php +++ b/themes/cp_admin/podcast/create.php @@ -205,7 +205,16 @@ as="XMLEditor" name="custom_rss" label="" - hint="" /> + hint="" + rows="8" /> + + diff --git a/themes/cp_admin/podcast/edit.php b/themes/cp_admin/podcast/edit.php index 9beafd09..488deadd 100644 --- a/themes/cp_admin/podcast/edit.php +++ b/themes/cp_admin/podcast/edit.php @@ -239,25 +239,36 @@ name="custom_rss" label="" hint="" - content="custom_rss_string) ?>" /> + content="custom_rss_string) ?>" + rows="8" /> - + + + + + + + + + + + + + - - - - - - - - -