feat(admin): add podcast's OP3 analytics dashboard link

This commit is contained in:
Guy Martin 2024-01-23 13:19:53 +00:00 committed by Yassine Doghri
parent a12327da8e
commit 5f3752b443
3 changed files with 52 additions and 28 deletions

View File

@ -78,6 +78,8 @@ use RuntimeException;
* @property string|null $location_osm * @property string|null $location_osm
* @property string|null $payment_pointer * @property string|null $payment_pointer
* @property array|null $custom_rss * @property array|null $custom_rss
* @property bool $is_op3_enabled
* @property string $op3_url
* @property string $custom_rss_string * @property string $custom_rss_string
* @property bool $is_published_on_hubs * @property bool $is_published_on_hubs
* @property string|null $partner_id * @property string|null $partner_id
@ -688,4 +690,14 @@ class Podcast extends Entity
// podcast is premium if at least one of its episodes is set as premium // podcast is premium if at least one of its episodes is set as premium
return (new EpisodeModel())->doesPodcastHavePremiumEpisodes($this->id); return (new EpisodeModel())->doesPodcastHavePremiumEpisodes($this->id);
} }
public function getIsOp3Enabled(): bool
{
return service('settings')->get('Analytics.enableOP3', 'podcast:' . $this->id);
}
public function getOp3Url(): string
{
return 'https://op3.dev/show/' . $this->guid;
}
} }

View File

@ -116,6 +116,7 @@ return [
'premium_by_default' => 'Episodes must be set as premium by default', 'premium_by_default' => 'Episodes must be set as premium by default',
'premium_by_default_hint' => 'Podcast episodes will be marked as premium by default. You can still choose to set some episodes, trailers or bonuses as public.', 'premium_by_default_hint' => 'Podcast episodes will be marked as premium by default. You can still choose to set some episodes, trailers or bonuses as public.',
'op3' => 'Open Podcast Prefix Project (OP3)', 'op3' => 'Open Podcast Prefix Project (OP3)',
'op3_link' => 'Visit your OP3 dashboard (external link)',
'op3_hint' => 'Value your analytics data with OP3, an open-source and trusted third party analytics service. Share, validate and compare your analytics data with the open podcasting ecosystem.', 'op3_hint' => 'Value your analytics data with OP3, an open-source and trusted third party analytics service. Share, validate and compare your analytics data with the open podcasting ecosystem.',
'op3_enable' => 'Enable OP3 analytics service', 'op3_enable' => 'Enable OP3 analytics service',
'op3_enable_hint' => 'For security reasons, premium episodes\' analytics data will not be shared with OP3.', 'op3_enable_hint' => 'For security reasons, premium episodes\' analytics data will not be shared with OP3.',

View File

@ -85,35 +85,46 @@ $podcastNavigation = [
?> ?>
<div class="relative flex items-stretch px-2 py-2 border-b border-navigation"> <div class="flex gap-2 px-2 py-2 border-b border-navigation">
<?php if ($podcast->is_premium): ?> <div class="relative">
<Icon glyph="exchange-dollar" class="absolute pl-1 text-xl rounded-r-full rounded-tl-lg left-4 top-4 text-accent-contrast bg-accent-base" /> <?php if ($podcast->is_premium): ?>
<?php endif; ?> <Icon glyph="exchange-dollar" class="absolute left-0 pl-1 text-xl rounded-r-full rounded-tl-lg top-2 text-accent-contrast bg-accent-base" />
<img <?php endif; ?>
src="<?= $podcast->cover->thumbnail_url ?>" <img
alt="<?= esc($podcast->title) ?>" src="<?= $podcast->cover->thumbnail_url ?>"
class="object-cover w-20 h-20 rounded aspect-square" alt="<?= esc($podcast->title) ?>"
loading="lazy" class="object-cover w-20 h-20 rounded aspect-square"
/> loading="lazy"
<div class="flex flex-col items-start flex-1 w-48 px-2"> />
<span class="w-full font-semibold truncate" title="<?= esc($podcast->title) ?>"><?= esc($podcast->title) ?></span> </div>
<a href="<?= route_to( <div class="flex flex-col gap-4">
'podcast-activity', <div class="flex flex-col items-start flex-1 w-48">
esc($podcast->handle), <span class="w-full font-semibold truncate" title="<?= esc($podcast->title) ?>"><?= esc($podcast->title) ?></span>
) ?>" class="inline-flex items-center text-sm hover:underline focus:ring-accent" <a href="<?= route_to(
data-tooltip="bottom" title="<?= lang( 'podcast-activity',
'PodcastNavigation.go_to_page', esc($podcast->handle),
) ?>">@<?= esc($podcast->handle) ?> ) ?>" class="inline-flex items-center text-sm hover:underline focus:ring-accent"
<?= icon('external-link', 'ml-1 opacity-60') ?> data-tooltip="bottom" title="<?= lang(
</a> 'PodcastNavigation.go_to_page',
<a href="<?= $podcast->feed_url ?>" class="inline-flex items-center mt-auto text-xs gap-x-1 focus:ring-accent group hover:underline" target="_blank" rel="noopener noreferrer"> ) ?>">@<?= esc($podcast->handle) ?>
<?= icon('rss', 'text-xl text-orange-400 inline-flex items-center justify-center rounded') . lang('PodcastNavigation.rss_feed') . icon('external-link', 'text-sm opacity-60') ?> <?= icon('external-link', 'ml-1 opacity-60') ?>
</a> </a>
</div>
<div class="flex flex-col items-start gap-1">
<a href="<?= $podcast->feed_url ?>" class="inline-flex items-center text-xs gap-x-1 focus:ring-accent group hover:underline" target="_blank" rel="noopener noreferrer" data-tooltip="bottom" title="<?= lang('PodcastNavigation.rss_feed') ?>">
<?= icon('rss', 'text-xl text-orange-400 inline-flex items-center justify-center rounded') . 'RSS Feed' . icon('external-link', 'text-sm opacity-60') ?>
</a>
<?php if ($podcast->is_op3_enabled): ?>
<a href="<?= $podcast->op3_url ?>" class="inline-flex items-center text-xs gap-x-1 focus:ring-accent group hover:underline" data-tooltip="bottom" target="_blank" rel="noopener noreferrer" title="<?= lang('Podcast.form.op3_link') ?>">
<?= icon('line-chart', 'text-xl text-white inline-flex items-center justify-center rounded') . 'OP3' . icon('external-link', 'text-sm opacity-60') ?>
</a>
<?php endif; ?>
</div>
</div> </div>
</div> </div>
<?= view('_partials/_nav_menu', [ <?= view('_partials/_nav_menu', [
'navigation' => $podcastNavigation, 'navigation' => $podcastNavigation,
'langKey' => 'PodcastNavigation', 'langKey' => 'PodcastNavigation',
'podcastId' => $podcast->id, 'podcastId' => $podcast->id,
]) ?> ]) ?>