mirror of
https://code.castopod.org/adaures/castopod
synced 2025-05-15 10:45:46 +00:00

- merge publication date fields into one field instanciated with flatpickr datetime picker - get user timezone to convert user publication_date input to UTC - remove setPublishedAt() method from episode entity - add publication pill component to display the episode publication date info - clear cache after episode insert - use CI is_really_writable() helper in install instead of is_writable() - fix latest episodes layout - update tsconfig to only include ts folders - update DEPENDENCIES.md to include flatpickr - add format_duration helper to format episode enclosure duration instead of translating it (causes translation bug) - add Time.ts module to convert UTC time to user localized time for episode publication dates - fix some layout issues - update php and js dependencies to latest versions closes #47
62 lines
1.8 KiB
PHP
62 lines
1.8 KiB
PHP
<?php
|
|
|
|
/**
|
|
* @copyright 2020 Podlibre
|
|
* @license https://www.gnu.org/licenses/agpl-3.0.en.html AGPL3
|
|
* @link https://castopod.org/
|
|
*/
|
|
|
|
namespace App\Controllers;
|
|
|
|
use App\Models\EpisodeModel;
|
|
use App\Models\PodcastModel;
|
|
use CodeIgniter\Controller;
|
|
|
|
class Feed extends Controller
|
|
{
|
|
public function index($podcastName)
|
|
{
|
|
helper('rss');
|
|
|
|
$podcast = (new PodcastModel())->where('name', $podcastName)->first();
|
|
if (!$podcast) {
|
|
throw \CodeIgniter\Exceptions\PageNotFoundException::forPageNotFound();
|
|
}
|
|
|
|
$service = null;
|
|
try {
|
|
$service = \Opawg\UserAgentsPhp\UserAgentsRSS::find(
|
|
$_SERVER['HTTP_USER_AGENT']
|
|
);
|
|
} catch (\Exception $e) {
|
|
// If things go wrong the show must go on and the user must be able to download the file
|
|
log_message('critical', $e);
|
|
}
|
|
|
|
$cacheName =
|
|
"podcast{$podcast->id}_feed" .
|
|
($service ? "_{$service['slug']}" : '');
|
|
|
|
if (!($found = cache($cacheName))) {
|
|
$found = get_rss_feed(
|
|
$podcast,
|
|
$service ? '?s=' . urlencode($service['name']) : ''
|
|
);
|
|
|
|
// The page cache is set to expire after next episode publication or a decade by default so it is deleted manually upon podcast update
|
|
$secondsToNextUnpublishedEpisode = (new EpisodeModel())->getSecondsToNextUnpublishedEpisode(
|
|
$podcast->id
|
|
);
|
|
|
|
cache()->save(
|
|
$cacheName,
|
|
$found,
|
|
$secondsToNextUnpublishedEpisode
|
|
? $secondsToNextUnpublishedEpisode
|
|
: DECADE
|
|
);
|
|
}
|
|
return $this->response->setXML($found);
|
|
}
|
|
}
|