mirror of
https://code.castopod.org/adaures/castopod
synced 2025-04-19 13:01:19 +00:00
feat(rss): add option for 301 redirect to new feed url
This commit is contained in:
parent
08c7df2a5d
commit
8402cc29d2
@ -33,14 +33,25 @@ class FeedController extends Controller
|
|||||||
|
|
||||||
public function index(string $podcastHandle): ResponseInterface
|
public function index(string $podcastHandle): ResponseInterface
|
||||||
{
|
{
|
||||||
helper(['rss', 'premium_podcasts', 'misc']);
|
|
||||||
|
|
||||||
$podcast = (new PodcastModel())->where('handle', $podcastHandle)
|
$podcast = (new PodcastModel())->where('handle', $podcastHandle)
|
||||||
->first();
|
->first();
|
||||||
if (! $podcast instanceof Podcast) {
|
if (! $podcast instanceof Podcast) {
|
||||||
throw PageNotFoundException::forPageNotFound();
|
throw PageNotFoundException::forPageNotFound();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 301 redirect to new feed?
|
||||||
|
$redirectToNewFeed = service('settings')
|
||||||
|
->get('Podcast.redirect_to_new_feed', 'podcast:' . $podcast->id);
|
||||||
|
|
||||||
|
if ($redirectToNewFeed && $podcast->new_feed_url !== null && filter_var(
|
||||||
|
$podcast->new_feed_url,
|
||||||
|
FILTER_VALIDATE_URL
|
||||||
|
) && $podcast->new_feed_url !== current_url()) {
|
||||||
|
return redirect()->to($podcast->new_feed_url, 301);
|
||||||
|
}
|
||||||
|
|
||||||
|
helper(['rss', 'premium_podcasts', 'misc']);
|
||||||
|
|
||||||
$service = null;
|
$service = null;
|
||||||
try {
|
try {
|
||||||
$service = UserAgentsRSS::find(service('superglobals')->server('HTTP_USER_AGENT'));
|
$service = UserAgentsRSS::find(service('superglobals')->server('HTTP_USER_AGENT'));
|
||||||
|
@ -351,6 +351,14 @@ class PodcastController extends BaseController
|
|||||||
$this->request->getPost('other_categories') ?? [],
|
$this->request->getPost('other_categories') ?? [],
|
||||||
);
|
);
|
||||||
|
|
||||||
|
// New feed url redirect
|
||||||
|
service('settings')
|
||||||
|
->set(
|
||||||
|
'Podcast.redirect_to_new_feed',
|
||||||
|
$this->request->getPost('redirect_to_new_feed') === 'yes',
|
||||||
|
'podcast:' . $podcast->id
|
||||||
|
);
|
||||||
|
|
||||||
$db->transComplete();
|
$db->transComplete();
|
||||||
|
|
||||||
return redirect()->route('podcast-edit', [$podcast->id])->with(
|
return redirect()->route('podcast-edit', [$podcast->id])->with(
|
||||||
|
@ -143,6 +143,8 @@ return [
|
|||||||
'verify_txt_helper' => 'This text is injected into a <podcast:txt purpose="verify"> tag.',
|
'verify_txt_helper' => 'This text is injected into a <podcast:txt purpose="verify"> tag.',
|
||||||
'new_feed_url' => 'New feed URL',
|
'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.',
|
'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.',
|
||||||
|
'redirect_to_new_feed' => 'Automatically redirect to new feed (301 redirect)',
|
||||||
|
'redirect_to_new_feed_hint' => 'Check this when migrating your Castopod RSS feed to the new feed url set above. To ensure followers receive your most recent episodes from the new feed URL, maintain this redirect and the <itunes:new-feed-url> tag in your new feed for at least four weeks.',
|
||||||
'old_feed_url' => 'Old feed URL',
|
'old_feed_url' => 'Old feed URL',
|
||||||
'partnership' => 'Partnership',
|
'partnership' => 'Partnership',
|
||||||
'partner_id' => 'ID',
|
'partner_id' => 'ID',
|
||||||
|
@ -210,6 +210,10 @@ label="<?= esc(lang('Podcast.form.new_feed_url')) ?>"
|
|||||||
hint="<?= esc(lang('Podcast.form.new_feed_url_hint')) ?>"
|
hint="<?= esc(lang('Podcast.form.new_feed_url_hint')) ?>"
|
||||||
value="<?= esc($podcast->new_feed_url) ?>"
|
value="<?= esc($podcast->new_feed_url) ?>"
|
||||||
/>
|
/>
|
||||||
|
<Forms.Toggler name="redirect_to_new_feed" value="yes" checked="<?= service('settings')
|
||||||
|
->get('Podcast.redirect_to_new_feed', 'podcast:' . $podcast->id) ? 'true' : 'false' ?>" hint="<?= esc(lang('Podcast.form.redirect_to_new_feed_hint')) ?>"><?= lang('Podcast.form.redirect_to_new_feed') ?></Forms.Toggler>
|
||||||
|
|
||||||
|
<hr class="border-subtle">
|
||||||
|
|
||||||
<x-Forms.Toggler class="mb-2" name="lock" value="<?= $podcast->is_locked ? 'yes' : '' ?>" hint="<?= esc(lang('Podcast.form.lock_hint')) ?>">
|
<x-Forms.Toggler class="mb-2" name="lock" value="<?= $podcast->is_locked ? 'yes' : '' ?>" hint="<?= esc(lang('Podcast.form.lock_hint')) ?>">
|
||||||
<?= lang('Podcast.form.lock') ?>
|
<?= lang('Podcast.form.lock') ?>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user