mirror of
https://code.castopod.org/adaures/castopod
synced 2025-04-19 13:01:19 +00:00
fix(premium-podcasts): display unlock button in embed when premium episode
This commit is contained in:
parent
242352c4d9
commit
ca109ba3a8
@ -177,10 +177,19 @@ class EpisodeController extends BaseController
|
|||||||
$session->set('embed_domain', parse_url($_SERVER['HTTP_REFERER'], PHP_URL_HOST));
|
$session->set('embed_domain', parse_url($_SERVER['HTTP_REFERER'], PHP_URL_HOST));
|
||||||
}
|
}
|
||||||
|
|
||||||
$locale = service('request')
|
$cacheName = implode(
|
||||||
->getLocale();
|
'_',
|
||||||
|
array_filter([
|
||||||
$cacheName = "page_podcast#{$this->podcast->id}_episode#{$this->episode->id}_embed_{$theme}_{$locale}";
|
'page',
|
||||||
|
"podcast#{$this->podcast->id}",
|
||||||
|
"episode#{$this->episode->id}",
|
||||||
|
'embed',
|
||||||
|
$theme,
|
||||||
|
service('request')
|
||||||
|
->getLocale(),
|
||||||
|
is_unlocked($this->podcast->handle) ? 'unlocked' : null,
|
||||||
|
]),
|
||||||
|
);
|
||||||
|
|
||||||
if (! ($cachedView = cache($cacheName))) {
|
if (! ($cachedView = cache($cacheName))) {
|
||||||
$themeData = EpisodeModel::$themes[$theme];
|
$themeData = EpisodeModel::$themes[$theme];
|
||||||
|
@ -67,6 +67,11 @@ class PodcastUnlockFilter implements FilterInterface
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Episode should be embeddable even if it is premium
|
||||||
|
if ($current === route_to('embed', $episode->podcast->handle, $episode->slug)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
// if podcast is locked then send to the unlock form
|
// if podcast is locked then send to the unlock form
|
||||||
/** @var PremiumPodcasts $premiumPodcasts */
|
/** @var PremiumPodcasts $premiumPodcasts */
|
||||||
$premiumPodcasts = service('premium_podcasts');
|
$premiumPodcasts = service('premium_podcasts');
|
||||||
|
@ -33,6 +33,9 @@
|
|||||||
<a href="<?= $episode->link ?>" class="flex flex-col items-start text-sm" style="color: <?= $themeData['text'] ?>;" target="_blank" rel="noopener noreferrer">
|
<a href="<?= $episode->link ?>" class="flex flex-col items-start text-sm" style="color: <?= $themeData['text'] ?>;" target="_blank" rel="noopener noreferrer">
|
||||||
<h1 class="font-semibold leading-tight opacity-100 line-clamp-2 hover:opacity-75"><?= esc($episode->title) ?></h1>
|
<h1 class="font-semibold leading-tight opacity-100 line-clamp-2 hover:opacity-75"><?= esc($episode->title) ?></h1>
|
||||||
</a>
|
</a>
|
||||||
|
<?php if ($episode->is_premium && ! is_unlocked($podcast->handle)): ?>
|
||||||
|
<Button variant="primary" class="mt-auto mb-2" iconLeft="lock" uri="<?= $episode->link ?>" target="_blank" rel="noopener noreferrer"><?= lang('PremiumPodcasts.unlock') ?></Button>
|
||||||
|
<?php else: ?>
|
||||||
<vm-player
|
<vm-player
|
||||||
id="castopod-vm-player"
|
id="castopod-vm-player"
|
||||||
theme="<?= str_starts_with($theme, 'dark') ? 'dark' : 'light' ?>"
|
theme="<?= str_starts_with($theme, 'dark') ? 'dark' : 'light' ?>"
|
||||||
@ -60,6 +63,7 @@
|
|||||||
</vm-controls>
|
</vm-controls>
|
||||||
</vm-ui>
|
</vm-ui>
|
||||||
</vm-player>
|
</vm-player>
|
||||||
|
<?php endif; ?>
|
||||||
</div>
|
</div>
|
||||||
</body>
|
</body>
|
||||||
|
|
||||||
|
@ -17,7 +17,7 @@
|
|||||||
</div>
|
</div>
|
||||||
<h2 class="flex-1 mt-1 font-semibold leading-tight line-clamp-2"><a class="hover:underline" href="<?= $episode->link ?>"><?= esc($episode->title) ?></a></h2>
|
<h2 class="flex-1 mt-1 font-semibold leading-tight line-clamp-2"><a class="hover:underline" href="<?= $episode->link ?>"><?= esc($episode->title) ?></a></h2>
|
||||||
</div>
|
</div>
|
||||||
<?php if ($episode->is_premium && ! subscription($podcast->handle)): ?>
|
<?php if ($episode->is_premium && ! is_unlocked($podcast->handle)): ?>
|
||||||
<a href="<?= route_to('episode', $episode->podcast->handle, $episode->slug) ?>" class="p-3 rounded-full bg-brand bg-accent-base text-accent-contrast hover:bg-accent-hover focus:ring-accent" title="<?= lang('PremiumPodcasts.unlock_episode') ?>" data-tooltip="bottom">
|
<a href="<?= route_to('episode', $episode->podcast->handle, $episode->slug) ?>" class="p-3 rounded-full bg-brand bg-accent-base text-accent-contrast hover:bg-accent-hover focus:ring-accent" title="<?= lang('PremiumPodcasts.unlock_episode') ?>" data-tooltip="bottom">
|
||||||
<Icon glyph="lock" class="text-xl" />
|
<Icon glyph="lock" class="text-xl" />
|
||||||
</a>
|
</a>
|
||||||
|
@ -17,7 +17,7 @@
|
|||||||
</div>
|
</div>
|
||||||
<a href="<?= $episode->link ?>" class="flex items-baseline font-semibold line-clamp-2" title="<?= esc($episode->title) ?>"><?= esc($episode->title) ?></a>
|
<a href="<?= $episode->link ?>" class="flex items-baseline font-semibold line-clamp-2" title="<?= esc($episode->title) ?>"><?= esc($episode->title) ?></a>
|
||||||
</div>
|
</div>
|
||||||
<?php if ($episode->is_premium && ! subscription($episode->podcast->handle)): ?>
|
<?php if ($episode->is_premium && ! is_unlocked($episode->podcast->handle)): ?>
|
||||||
<a href="<?= route_to('episode', $episode->podcast->handle, $episode->slug) ?>" class="p-3 mr-4 rounded-full bg-brand bg-accent-base text-accent-contrast hover:bg-accent-hover focus:ring-accent" title="<?= lang('PremiumPodcasts.unlock_episode') ?>" data-tooltip="bottom">
|
<a href="<?= route_to('episode', $episode->podcast->handle, $episode->slug) ?>" class="p-3 mr-4 rounded-full bg-brand bg-accent-base text-accent-contrast hover:bg-accent-hover focus:ring-accent" title="<?= lang('PremiumPodcasts.unlock_episode') ?>" data-tooltip="bottom">
|
||||||
<Icon glyph="lock" class="text-xl" />
|
<Icon glyph="lock" class="text-xl" />
|
||||||
</a>
|
</a>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user