mirror of
https://code.castopod.org/adaures/castopod
synced 2025-06-06 18:31:05 +00:00
fix(cache): suffix cache names with authenticated for credits, map and pages
This commit is contained in:
parent
18ae557e97
commit
418a70b2a6
@ -20,9 +20,12 @@ class CreditsController extends BaseController
|
|||||||
{
|
{
|
||||||
$locale = service('request')
|
$locale = service('request')
|
||||||
->getLocale();
|
->getLocale();
|
||||||
$allPodcasts = (new PodcastModel())->findAll();
|
|
||||||
|
|
||||||
$cacheName = "page_credits_{$locale}";
|
$cacheName = implode(
|
||||||
|
'_',
|
||||||
|
array_filter(['page', 'credits', $locale, can_user_interact() ? 'authenticated' : null]),
|
||||||
|
);
|
||||||
|
|
||||||
if (! ($found = cache($cacheName))) {
|
if (! ($found = cache($cacheName))) {
|
||||||
$page = new Page([
|
$page = new Page([
|
||||||
'title' => lang('Person.credits', [], $locale),
|
'title' => lang('Person.credits', [], $locale),
|
||||||
@ -30,6 +33,7 @@ class CreditsController extends BaseController
|
|||||||
'content_markdown' => '',
|
'content_markdown' => '',
|
||||||
]);
|
]);
|
||||||
|
|
||||||
|
$allPodcasts = (new PodcastModel())->findAll();
|
||||||
$allCredits = (new CreditModel())->findAll();
|
$allCredits = (new CreditModel())->findAll();
|
||||||
|
|
||||||
// Unlike the carpenter, we make a tree from a table:
|
// Unlike the carpenter, we make a tree from a table:
|
||||||
|
@ -90,7 +90,7 @@ class EpisodeCommentController extends BaseController
|
|||||||
"comment#{$this->comment->id}",
|
"comment#{$this->comment->id}",
|
||||||
service('request')
|
service('request')
|
||||||
->getLocale(),
|
->getLocale(),
|
||||||
can_user_interact() ? '_authenticated' : null,
|
can_user_interact() ? 'authenticated' : null,
|
||||||
]),
|
]),
|
||||||
);
|
);
|
||||||
|
|
||||||
|
@ -17,9 +17,17 @@ class MapController extends BaseController
|
|||||||
{
|
{
|
||||||
public function index(): string
|
public function index(): string
|
||||||
{
|
{
|
||||||
$locale = service('request')
|
$cacheName = implode(
|
||||||
->getLocale();
|
'_',
|
||||||
$cacheName = "page_map_{$locale}";
|
array_filter([
|
||||||
|
'page',
|
||||||
|
'map',
|
||||||
|
service('request')
|
||||||
|
->getLocale(),
|
||||||
|
can_user_interact() ? 'authenticated' : null,
|
||||||
|
]),
|
||||||
|
);
|
||||||
|
|
||||||
if (! ($found = cache($cacheName))) {
|
if (! ($found = cache($cacheName))) {
|
||||||
$found = view('pages/map', [], [
|
$found = view('pages/map', [], [
|
||||||
'cache' => DECADE,
|
'cache' => DECADE,
|
||||||
|
@ -37,9 +37,17 @@ class PageController extends BaseController
|
|||||||
|
|
||||||
public function index(): string
|
public function index(): string
|
||||||
{
|
{
|
||||||
$locale = service('request')
|
$cacheName = implode(
|
||||||
->getLocale();
|
'_',
|
||||||
$cacheName = "page-{$this->page->slug}-{$locale}";
|
array_filter([
|
||||||
|
'page',
|
||||||
|
$this->page->slug,
|
||||||
|
service('request')
|
||||||
|
->getLocale(),
|
||||||
|
can_user_interact() ? 'authenticated' : null,
|
||||||
|
]),
|
||||||
|
);
|
||||||
|
|
||||||
if (! ($found = cache($cacheName))) {
|
if (! ($found = cache($cacheName))) {
|
||||||
$data = [
|
$data = [
|
||||||
'metatags' => get_page_metatags($this->page),
|
'metatags' => get_page_metatags($this->page),
|
||||||
|
@ -74,7 +74,7 @@ class PodcastController extends BaseController
|
|||||||
'activity',
|
'activity',
|
||||||
service('request')
|
service('request')
|
||||||
->getLocale(),
|
->getLocale(),
|
||||||
can_user_interact() ? '_authenticated' : null,
|
can_user_interact() ? 'authenticated' : null,
|
||||||
]),
|
]),
|
||||||
);
|
);
|
||||||
|
|
||||||
@ -122,7 +122,7 @@ class PodcastController extends BaseController
|
|||||||
'about',
|
'about',
|
||||||
service('request')
|
service('request')
|
||||||
->getLocale(),
|
->getLocale(),
|
||||||
can_user_interact() ? '_authenticated' : null,
|
can_user_interact() ? 'authenticated' : null,
|
||||||
]),
|
]),
|
||||||
);
|
);
|
||||||
|
|
||||||
@ -188,7 +188,7 @@ class PodcastController extends BaseController
|
|||||||
$seasonQuery ? 'season' . $seasonQuery : null,
|
$seasonQuery ? 'season' . $seasonQuery : null,
|
||||||
service('request')
|
service('request')
|
||||||
->getLocale(),
|
->getLocale(),
|
||||||
can_user_interact() ? '_authenticated' : null,
|
can_user_interact() ? 'authenticated' : null,
|
||||||
]),
|
]),
|
||||||
);
|
);
|
||||||
|
|
||||||
|
@ -81,7 +81,7 @@ class PostController extends FediversePostController
|
|||||||
"post#{$this->post->id}",
|
"post#{$this->post->id}",
|
||||||
service('request')
|
service('request')
|
||||||
->getLocale(),
|
->getLocale(),
|
||||||
can_user_interact() ? '_authenticated' : null,
|
can_user_interact() ? 'authenticated' : null,
|
||||||
]),
|
]),
|
||||||
);
|
);
|
||||||
|
|
||||||
|
@ -307,7 +307,6 @@ if (! function_exists('relative_time')) {
|
|||||||
return <<<CODE_SAMPLE
|
return <<<CODE_SAMPLE
|
||||||
<time-ago class="{$class}" datetime="{$datetime}">
|
<time-ago class="{$class}" datetime="{$datetime}">
|
||||||
<time
|
<time
|
||||||
itemprop="published"
|
|
||||||
datetime="{$datetime}"
|
datetime="{$datetime}"
|
||||||
title="{$time}">{$translatedDate}</time>
|
title="{$time}">{$translatedDate}</time>
|
||||||
</time-ago>
|
</time-ago>
|
||||||
|
@ -37,8 +37,8 @@ class Field extends FormComponent
|
|||||||
unset($fieldComponentAttributes['as']);
|
unset($fieldComponentAttributes['as']);
|
||||||
unset($fieldComponentAttributes['label']);
|
unset($fieldComponentAttributes['label']);
|
||||||
unset($fieldComponentAttributes['class']);
|
unset($fieldComponentAttributes['class']);
|
||||||
unset($fieldComponentAttributes['helperText']);
|
unset($fieldComponentAttributes['helper']);
|
||||||
unset($fieldComponentAttributes['hintText']);
|
unset($fieldComponentAttributes['hint']);
|
||||||
|
|
||||||
$fieldComponentAttributes['class'] = 'mb-1';
|
$fieldComponentAttributes['class'] = 'mb-1';
|
||||||
|
|
||||||
|
@ -91,7 +91,7 @@
|
|||||||
<div class="flex items-center mt-4 gap-x-8">
|
<div class="flex items-center mt-4 gap-x-8">
|
||||||
<?php if ($episode->persons !== []): ?>
|
<?php if ($episode->persons !== []): ?>
|
||||||
<button class="flex items-center text-xs font-semibold gap-x-2 hover:underline focus:ring-accent" data-toggle="persons-list" data-toggle-class="hidden">
|
<button class="flex items-center text-xs font-semibold gap-x-2 hover:underline focus:ring-accent" data-toggle="persons-list" data-toggle-class="hidden">
|
||||||
<div class="inline-flex flex-row-reverse">
|
<span class="inline-flex flex-row-reverse">
|
||||||
<?php $i = 0; ?>
|
<?php $i = 0; ?>
|
||||||
<?php foreach ($episode->persons as $person): ?>
|
<?php foreach ($episode->persons as $person): ?>
|
||||||
<img src="<?= $person->avatar->thumbnail_url ?>" alt="<?= $person->full_name ?>" class="object-cover w-8 h-8 -ml-4 border-2 rounded-full aspect-square border-background-header last:ml-0" loading="lazy" />
|
<img src="<?= $person->avatar->thumbnail_url ?>" alt="<?= $person->full_name ?>" class="object-cover w-8 h-8 -ml-4 border-2 rounded-full aspect-square border-background-header last:ml-0" loading="lazy" />
|
||||||
@ -99,7 +99,7 @@
|
|||||||
break;
|
break;
|
||||||
}?>
|
}?>
|
||||||
<?php endforeach; ?>
|
<?php endforeach; ?>
|
||||||
</div>
|
</span>
|
||||||
<?= lang('Episode.persons', [
|
<?= lang('Episode.persons', [
|
||||||
'personsCount' => count($episode->persons),
|
'personsCount' => count($episode->persons),
|
||||||
]) ?>
|
]) ?>
|
||||||
@ -124,7 +124,7 @@
|
|||||||
<div class="text-xs">
|
<div class="text-xs">
|
||||||
<?= relative_time($episode->published_at) ?>
|
<?= relative_time($episode->published_at) ?>
|
||||||
<span class="mx-1">•</span>
|
<span class="mx-1">•</span>
|
||||||
<time datetime="PT<?= $episode->audio->duration ?>S">
|
<time datetime="PT<?= round($episode->audio->duration, 3) ?>S">
|
||||||
<?= format_duration_symbol($episode->audio->duration) ?>
|
<?= format_duration_symbol($episode->audio->duration) ?>
|
||||||
</time>
|
</time>
|
||||||
</div>
|
</div>
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
<article class="flex w-full p-4 shadow bg-elevated rounded-conditional-2xl gap-x-2">
|
<article class="flex w-full p-4 shadow bg-elevated rounded-conditional-2xl gap-x-2">
|
||||||
<div class="relative">
|
<div class="relative">
|
||||||
<time class="absolute px-1 text-xs font-semibold text-white rounded bottom-2 right-2 bg-black/75" datetime="PT<?= $episode->audio->duration ?>S">
|
<time class="absolute px-1 text-xs font-semibold text-white rounded bottom-2 right-2 bg-black/75" datetime="PT<?= round($episode->audio->duration, 3) ?>S">
|
||||||
<?= format_duration($episode->audio->duration) ?>
|
<?= format_duration($episode->audio->duration) ?>
|
||||||
</time>
|
</time>
|
||||||
<img src="<?= $episode->cover
|
<img src="<?= $episode->cover
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
<div class="flex items-center border-y border-subtle">
|
<div class="flex items-center border-y border-subtle">
|
||||||
<div class="relative">
|
<div class="relative">
|
||||||
<time class="absolute px-1 text-sm font-semibold text-white rounded bg-black/75 bottom-2 right-2" datetime="PT<?= $episode->audio->duration ?>S">
|
<time class="absolute px-1 text-sm font-semibold text-white rounded bg-black/75 bottom-2 right-2" datetime="PT<?= round($episode->audio->duration, 3) ?>S">
|
||||||
<?= format_duration($episode->audio->duration) ?>
|
<?= format_duration($episode->audio->duration) ?>
|
||||||
</time>
|
</time>
|
||||||
<img
|
<img
|
||||||
|
@ -5,10 +5,6 @@
|
|||||||
|
|
||||||
<head>
|
<head>
|
||||||
<meta charset="UTF-8"/>
|
<meta charset="UTF-8"/>
|
||||||
<title><?= service('settings')
|
|
||||||
->get('App.siteName') ?></title>
|
|
||||||
<meta name="description" content="<?= service('settings')
|
|
||||||
->get('App.siteDescription') ?>"/>
|
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1.0"/>
|
<meta name="viewport" content="width=device-width, initial-scale=1.0"/>
|
||||||
<link rel="icon" type="image/x-icon" href="<?= service('settings')
|
<link rel="icon" type="image/x-icon" href="<?= service('settings')
|
||||||
->get('App.siteIcon')['ico'] ?>" />
|
->get('App.siteIcon')['ico'] ?>" />
|
||||||
@ -41,20 +37,20 @@
|
|||||||
<?php endif; ?>
|
<?php endif; ?>
|
||||||
|
|
||||||
<header class="py-8 text-white border-b bg-header border-subtle">
|
<header class="py-8 text-white border-b bg-header border-subtle">
|
||||||
<div class="container flex items-center justify-between px-2 py-4 mx-auto">
|
<h1 class="container flex items-center justify-between px-2 py-4 mx-auto">
|
||||||
<a href="<?= route_to(
|
<a href="<?= route_to(
|
||||||
'home',
|
'home',
|
||||||
) ?>" class="inline-flex items-baseline text-3xl font-semibold font-display"><?= service('settings')
|
) ?>" class="inline-flex items-baseline text-3xl font-semibold font-display"><?= service('settings')
|
||||||
->get('App.siteName') === 'Castopod' ? 'castopod' .
|
->get('App.siteName') === 'Castopod' ? 'castopod' .
|
||||||
svg('castopod-logo-base', 'h-6 ml-2') : service('settings')
|
svg('castopod-logo-base', 'h-6 ml-2') : service('settings')
|
||||||
->get('App.siteName') ?></a>
|
->get('App.siteName') ?></a>
|
||||||
</div>
|
</h1>
|
||||||
</header>
|
</header>
|
||||||
<main class="container flex-1 px-4 py-10 mx-auto">
|
<main class="container flex-1 px-4 py-10 mx-auto">
|
||||||
<Heading class="inline-block mb-2"><?= lang('Home.all_podcasts') ?> (<?= count(
|
<Heading tagName="h2" class="inline-block mb-2"><?= lang('Home.all_podcasts') ?> (<?= count(
|
||||||
$podcasts,
|
$podcasts,
|
||||||
) ?>)</Heading>
|
) ?>)</Heading>
|
||||||
<section class="grid gap-4 grid-cols-cards">
|
<div class="grid gap-4 grid-cols-cards">
|
||||||
<?php if ($podcasts): ?>
|
<?php if ($podcasts): ?>
|
||||||
<?php foreach ($podcasts as $podcast): ?>
|
<?php foreach ($podcasts as $podcast): ?>
|
||||||
<a href="<?= $podcast->link ?>" class="relative w-full h-full overflow-hidden transition shadow focus:ring-accent rounded-xl border-subtle hover:shadow-xl focus:shadow-xl group border-3">
|
<a href="<?= $podcast->link ?>" class="relative w-full h-full overflow-hidden transition shadow focus:ring-accent rounded-xl border-subtle hover:shadow-xl focus:shadow-xl group border-3">
|
||||||
@ -65,7 +61,7 @@
|
|||||||
<img alt="<?= $podcast->title ?>" src="<?= $podcast->cover->medium_url ?>" class="object-cover w-full h-full transition duration-200 ease-in-out transform bg-header aspect-square group-focus:scale-105 group-hover:scale-105" loading="lazy" />
|
<img alt="<?= $podcast->title ?>" src="<?= $podcast->cover->medium_url ?>" class="object-cover w-full h-full transition duration-200 ease-in-out transform bg-header aspect-square group-focus:scale-105 group-hover:scale-105" loading="lazy" />
|
||||||
</div>
|
</div>
|
||||||
<div class="absolute bottom-0 left-0 z-20 w-full px-4 pb-2">
|
<div class="absolute bottom-0 left-0 z-20 w-full px-4 pb-2">
|
||||||
<h2 class="font-bold leading-none truncate font-display"><?= $podcast->title ?></h2>
|
<h3 class="font-bold leading-none truncate font-display"><?= $podcast->title ?></h3>
|
||||||
<p class="text-sm opacity-75">@<?= $podcast->handle ?></p>
|
<p class="text-sm opacity-75">@<?= $podcast->handle ?></p>
|
||||||
</div>
|
</div>
|
||||||
</article>
|
</article>
|
||||||
@ -74,7 +70,7 @@
|
|||||||
<?php else: ?>
|
<?php else: ?>
|
||||||
<p class="italic"><?= lang('Home.no_podcast') ?></p>
|
<p class="italic"><?= lang('Home.no_podcast') ?></p>
|
||||||
<?php endif; ?>
|
<?php endif; ?>
|
||||||
</section>
|
</div>
|
||||||
</main>
|
</main>
|
||||||
<footer class="container flex justify-between px-2 py-4 mx-auto text-sm text-right border-t border-subtle">
|
<footer class="container flex justify-between px-2 py-4 mx-auto text-sm text-right border-t border-subtle">
|
||||||
<?= render_page_links() ?>
|
<?= render_page_links() ?>
|
||||||
|
@ -22,7 +22,7 @@
|
|||||||
<div class="flex items-center mt-4 gap-x-8">
|
<div class="flex items-center mt-4 gap-x-8">
|
||||||
<?php if ($podcast->persons !== []): ?>
|
<?php if ($podcast->persons !== []): ?>
|
||||||
<button class="flex items-center text-xs font-semibold gap-x-2 hover:underline focus:ring-accent" data-toggle="persons-list" data-toggle-class="hidden">
|
<button class="flex items-center text-xs font-semibold gap-x-2 hover:underline focus:ring-accent" data-toggle="persons-list" data-toggle-class="hidden">
|
||||||
<div class="inline-flex flex-row-reverse">
|
<span class="inline-flex flex-row-reverse">
|
||||||
<?php $i = 0; ?>
|
<?php $i = 0; ?>
|
||||||
<?php foreach ($podcast->persons as $person): ?>
|
<?php foreach ($podcast->persons as $person): ?>
|
||||||
<img src="<?= $person->avatar->thumbnail_url ?>" alt="<?= $person->full_name ?>" class="object-cover w-8 -ml-4 border-2 rounded-full aspect-square bg-header border-background-base last:ml-0" loading="lazy" />
|
<img src="<?= $person->avatar->thumbnail_url ?>" alt="<?= $person->full_name ?>" class="object-cover w-8 -ml-4 border-2 rounded-full aspect-square bg-header border-background-base last:ml-0" loading="lazy" />
|
||||||
@ -30,7 +30,7 @@
|
|||||||
break;
|
break;
|
||||||
}?>
|
}?>
|
||||||
<?php endforeach; ?>
|
<?php endforeach; ?>
|
||||||
</div>
|
</span>
|
||||||
<?= lang('Podcast.persons', [
|
<?= lang('Podcast.persons', [
|
||||||
'personsCount' => count($podcast->persons),
|
'personsCount' => count($podcast->persons),
|
||||||
]) ?>
|
]) ?>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user