Loading app/Config/Routes.php +6 −1 Original line number Diff line number Diff line Loading @@ -125,6 +125,9 @@ $routes->group('@(:podcastHandle)', static function ($routes): void { $routes->get('activity', 'EpisodeController::activity/$1/$2', [ 'as' => 'episode-activity', ]); $routes->get('chapters', 'EpisodeController::chapters/$1/$2', [ 'as' => 'episode-chapters', ]); $routes->options('comments', 'ActivityPubController::preflight'); $routes->get('comments', 'EpisodeController::comments/$1/$2', [ 'as' => 'episode-comments', Loading Loading @@ -196,10 +199,12 @@ $routes->get('/audio/@(:podcastHandle)/(:slug).(:alphanum)', 'EpisodeAudioContro $routes->get('/p/(:uuid)', 'EpisodePreviewController::index/$1', [ 'as' => 'episode-preview', ]); $routes->get('/p/(:uuid)/activity', 'EpisodePreviewController::activity/$1', [ 'as' => 'episode-preview-activity', ]); $routes->get('/p/(:uuid)/chapters', 'EpisodePreviewController::chapters/$1', [ 'as' => 'episode-preview-chapters', ]); // Other pages $routes->get('/credits', 'CreditsController', [ Loading app/Controllers/EpisodeController.php +62 −0 Original line number Diff line number Diff line Loading @@ -27,6 +27,7 @@ use Config\Services; use Modules\Analytics\AnalyticsTrait; use Modules\Fediverse\Objects\OrderedCollectionObject; use Modules\Fediverse\Objects\OrderedCollectionPage; use Modules\Media\FileManagers\FileManagerInterface; use SimpleXMLElement; class EpisodeController extends BaseController Loading Loading @@ -166,6 +167,67 @@ class EpisodeController extends BaseController return $cachedView; } public function chapters(): String { // Prevent analytics hit when authenticated if (! auth()->loggedIn()) { $this->registerPodcastWebpageHit($this->episode->podcast_id); } $cacheName = implode( '_', array_filter([ 'page', "podcast#{$this->podcast->id}", "episode#{$this->episode->id}", 'chapters', service('request') ->getLocale(), is_unlocked($this->podcast->handle) ? 'unlocked' : null, auth() ->loggedIn() ? 'authenticated' : null, ]), ); if (! ($cachedView = cache($cacheName))) { // get chapters from json file $data = [ 'metatags' => get_episode_metatags($this->episode), 'podcast' => $this->podcast, 'episode' => $this->episode, ]; if (isset($this->episode->chapters->file_key)) { /** @var FileManagerInterface $fileManager */ $fileManager = service('file_manager'); $episodeChaptersJsonString = (string) $fileManager->getFileContents($this->episode->chapters->file_key); $chapters = json_decode($episodeChaptersJsonString, true); $data['chapters'] = $chapters; } $secondsToNextUnpublishedEpisode = (new EpisodeModel())->getSecondsToNextUnpublishedEpisode( $this->podcast->id, ); if (auth()->loggedIn()) { helper('form'); return view('episode/chapters', $data); } // The page cache is set to a decade so it is deleted manually upon podcast update return view('episode/chapters', $data, [ 'cache' => $secondsToNextUnpublishedEpisode ? $secondsToNextUnpublishedEpisode : DECADE, 'cache_name' => $cacheName, ]); } return $cachedView; } public function embed(string $theme = 'light-transparent'): string { header('Content-Security-Policy: frame-ancestors http://*:* https://*:*'); Loading app/Controllers/EpisodePreviewController.php +8 −0 Original line number Diff line number Diff line Loading @@ -63,4 +63,12 @@ class EpisodePreviewController extends BaseController 'episode' => $this->episode, ]); } public function chapters(): RedirectResponse | string { return view('episode/preview-chapters', [ 'podcast' => $this->episode->podcast, 'episode' => $this->episode, ]); } } app/Entities/Episode.php +0 −1 Original line number Diff line number Diff line Loading @@ -21,7 +21,6 @@ use App\Models\PostModel; use CodeIgniter\Entity\Entity; use CodeIgniter\Files\File; use CodeIgniter\HTTP\Files\UploadedFile; use CodeIgniter\HTTP\URI; use CodeIgniter\I18n\Time; use Config\Images; use Exception; Loading app/Language/en/Episode.php +2 −0 Original line number Diff line number Diff line Loading @@ -23,6 +23,7 @@ return [ 'back_to_episodes' => 'Back to episodes of {podcast}', 'comments' => 'Comments', 'activity' => 'Activity', 'chapters' => 'Chapters', 'description' => 'Episode description', 'number_of_comments' => '{numberOfComments, plural, one {# comment} Loading @@ -42,4 +43,5 @@ return [ 'publish' => 'Publish', 'publish_edit' => 'Edit publication', ], 'no_chapters' => 'No chapters are available for this episode.', ]; Loading
app/Config/Routes.php +6 −1 Original line number Diff line number Diff line Loading @@ -125,6 +125,9 @@ $routes->group('@(:podcastHandle)', static function ($routes): void { $routes->get('activity', 'EpisodeController::activity/$1/$2', [ 'as' => 'episode-activity', ]); $routes->get('chapters', 'EpisodeController::chapters/$1/$2', [ 'as' => 'episode-chapters', ]); $routes->options('comments', 'ActivityPubController::preflight'); $routes->get('comments', 'EpisodeController::comments/$1/$2', [ 'as' => 'episode-comments', Loading Loading @@ -196,10 +199,12 @@ $routes->get('/audio/@(:podcastHandle)/(:slug).(:alphanum)', 'EpisodeAudioContro $routes->get('/p/(:uuid)', 'EpisodePreviewController::index/$1', [ 'as' => 'episode-preview', ]); $routes->get('/p/(:uuid)/activity', 'EpisodePreviewController::activity/$1', [ 'as' => 'episode-preview-activity', ]); $routes->get('/p/(:uuid)/chapters', 'EpisodePreviewController::chapters/$1', [ 'as' => 'episode-preview-chapters', ]); // Other pages $routes->get('/credits', 'CreditsController', [ Loading
app/Controllers/EpisodeController.php +62 −0 Original line number Diff line number Diff line Loading @@ -27,6 +27,7 @@ use Config\Services; use Modules\Analytics\AnalyticsTrait; use Modules\Fediverse\Objects\OrderedCollectionObject; use Modules\Fediverse\Objects\OrderedCollectionPage; use Modules\Media\FileManagers\FileManagerInterface; use SimpleXMLElement; class EpisodeController extends BaseController Loading Loading @@ -166,6 +167,67 @@ class EpisodeController extends BaseController return $cachedView; } public function chapters(): String { // Prevent analytics hit when authenticated if (! auth()->loggedIn()) { $this->registerPodcastWebpageHit($this->episode->podcast_id); } $cacheName = implode( '_', array_filter([ 'page', "podcast#{$this->podcast->id}", "episode#{$this->episode->id}", 'chapters', service('request') ->getLocale(), is_unlocked($this->podcast->handle) ? 'unlocked' : null, auth() ->loggedIn() ? 'authenticated' : null, ]), ); if (! ($cachedView = cache($cacheName))) { // get chapters from json file $data = [ 'metatags' => get_episode_metatags($this->episode), 'podcast' => $this->podcast, 'episode' => $this->episode, ]; if (isset($this->episode->chapters->file_key)) { /** @var FileManagerInterface $fileManager */ $fileManager = service('file_manager'); $episodeChaptersJsonString = (string) $fileManager->getFileContents($this->episode->chapters->file_key); $chapters = json_decode($episodeChaptersJsonString, true); $data['chapters'] = $chapters; } $secondsToNextUnpublishedEpisode = (new EpisodeModel())->getSecondsToNextUnpublishedEpisode( $this->podcast->id, ); if (auth()->loggedIn()) { helper('form'); return view('episode/chapters', $data); } // The page cache is set to a decade so it is deleted manually upon podcast update return view('episode/chapters', $data, [ 'cache' => $secondsToNextUnpublishedEpisode ? $secondsToNextUnpublishedEpisode : DECADE, 'cache_name' => $cacheName, ]); } return $cachedView; } public function embed(string $theme = 'light-transparent'): string { header('Content-Security-Policy: frame-ancestors http://*:* https://*:*'); Loading
app/Controllers/EpisodePreviewController.php +8 −0 Original line number Diff line number Diff line Loading @@ -63,4 +63,12 @@ class EpisodePreviewController extends BaseController 'episode' => $this->episode, ]); } public function chapters(): RedirectResponse | string { return view('episode/preview-chapters', [ 'podcast' => $this->episode->podcast, 'episode' => $this->episode, ]); } }
app/Entities/Episode.php +0 −1 Original line number Diff line number Diff line Loading @@ -21,7 +21,6 @@ use App\Models\PostModel; use CodeIgniter\Entity\Entity; use CodeIgniter\Files\File; use CodeIgniter\HTTP\Files\UploadedFile; use CodeIgniter\HTTP\URI; use CodeIgniter\I18n\Time; use Config\Images; use Exception; Loading
app/Language/en/Episode.php +2 −0 Original line number Diff line number Diff line Loading @@ -23,6 +23,7 @@ return [ 'back_to_episodes' => 'Back to episodes of {podcast}', 'comments' => 'Comments', 'activity' => 'Activity', 'chapters' => 'Chapters', 'description' => 'Episode description', 'number_of_comments' => '{numberOfComments, plural, one {# comment} Loading @@ -42,4 +43,5 @@ return [ 'publish' => 'Publish', 'publish_edit' => 'Edit publication', ], 'no_chapters' => 'No chapters are available for this episode.', ];