Loading app/Database/Migrations/2021-12-09-130000_add_clips.php +1 −2 Original line number Diff line number Diff line Loading @@ -39,10 +39,9 @@ class AddClips extends Migration 'type' => 'DECIMAL(7,3)', 'unsigned' => true, ], 'label' => [ 'title' => [ 'type' => 'VARCHAR', 'constraint' => 128, 'null' => true, ], 'type' => [ 'type' => 'ENUM', Loading app/Entities/Clip/BaseClip.php +2 −2 Original line number Diff line number Diff line Loading @@ -29,7 +29,7 @@ use Modules\Auth\Entities\User; * @property Podcast $podcast * @property int $episode_id * @property Episode $episode * @property string $label * @property string $title * @property double $start_time * @property double $end_time * @property double $duration Loading Loading @@ -68,7 +68,7 @@ class BaseClip extends Entity 'id' => 'integer', 'podcast_id' => 'integer', 'episode_id' => 'integer', 'label' => 'string', 'title' => 'string', 'start_time' => 'double', 'duration' => 'double', 'type' => 'string', Loading app/Helpers/rss_helper.php +2 −2 Original line number Diff line number Diff line Loading @@ -255,7 +255,7 @@ if (! function_exists('get_rss_feed')) { $comments->addAttribute('uri', url_to('episode-comments', $podcast->handle, $episode->slug)); $comments->addAttribute('contentType', 'application/podcast-activity+json'); if ($episode->transcript->file_url !== '') { if ($episode->transcript !== null) { $transcriptElement = $item->addChild('transcript', null, $podcastNamespace); $transcriptElement->addAttribute('url', $episode->transcript->file_url); $transcriptElement->addAttribute( Loading @@ -275,7 +275,7 @@ if (! function_exists('get_rss_feed')) { foreach ($episode->soundbites as $soundbite) { // TODO: differentiate video from soundbites? $soundbiteElement = $item->addChild('soundbite', $soundbite->label, $podcastNamespace); $soundbiteElement = $item->addChild('soundbite', $soundbite->title, $podcastNamespace); $soundbiteElement->addAttribute('start_time', (string) $soundbite->start_time); $soundbiteElement->addAttribute('duration', (string) $soundbite->duration); } Loading app/Models/ClipModel.php +48 −28 Original line number Diff line number Diff line Loading @@ -39,7 +39,7 @@ class ClipModel extends Model 'id', 'podcast_id', 'episode_id', 'label', 'title', 'start_time', 'duration', 'type', Loading Loading @@ -89,33 +89,6 @@ class ClipModel extends Model parent::__construct($db, $validation); } /** * Gets all clips for an episode * * @return Soundbite[] */ public function getEpisodeSoundbites(int $podcastId, int $episodeId): array { $cacheName = "podcast#{$podcastId}_episode#{$episodeId}_soundbites"; if (! ($found = cache($cacheName))) { $found = $this->where([ 'episode_id' => $episodeId, 'podcast_id' => $podcastId, 'type' => 'audio', ]) ->orderBy('start_time') ->findAll(); foreach ($found as $key => $soundbite) { $found[$key] = new Soundbite($soundbite->toArray()); } cache() ->save($cacheName, $found, DECADE); } return $found; } public function getVideoClipById(int $videoClipId): ?VideoClip { $cacheName = "video-clip#{$videoClipId}"; Loading Loading @@ -184,6 +157,53 @@ class ClipModel extends Model return $found; } public function getSoundbiteById(int $soundbiteId): ?Soundbite { $cacheName = "soundbite#{$soundbiteId}"; if (! ($found = cache($cacheName))) { $clip = $this->find($soundbiteId); if ($clip === null) { return null; } // @phpstan-ignore-next-line $found = new Soundbite($clip->toArray()); cache() ->save($cacheName, $found, DECADE); } return $found; } /** * Gets all clips for an episode * * @return Soundbite[] */ public function getEpisodeSoundbites(int $podcastId, int $episodeId): array { $cacheName = "podcast#{$podcastId}_episode#{$episodeId}_soundbites"; if (! ($found = cache($cacheName))) { $found = $this->where([ 'episode_id' => $episodeId, 'podcast_id' => $podcastId, 'type' => 'audio', ]) ->orderBy('start_time') ->findAll(); foreach ($found as $key => $soundbite) { $found[$key] = new Soundbite($soundbite->toArray()); } cache() ->save($cacheName, $found, DECADE); } return $found; } public function deleteSoundbite(int $podcastId, int $episodeId, int $clipId): BaseResult | bool { cache() Loading app/Resources/js/admin.ts +1 −2 Original line number Diff line number Diff line Loading @@ -10,11 +10,11 @@ import "./modules/markdown-preview"; import "./modules/markdown-write-preview"; import MultiSelect from "./modules/MultiSelect"; import "./modules/permalink-edit"; import "./modules/play-soundbite"; import PublishMessageWarning from "./modules/PublishMessageWarning"; import Select from "./modules/Select"; import SidebarToggler from "./modules/SidebarToggler"; import Slugify from "./modules/Slugify"; import Soundbites from "./modules/Soundbites"; import ThemePicker from "./modules/ThemePicker"; import Time from "./modules/Time"; import Tooltip from "./modules/Tooltip"; Loading @@ -31,7 +31,6 @@ SidebarToggler(); ClientTimezone(); DateTimePicker(); Time(); Soundbites(); Clipboard(); ThemePicker(); PublishMessageWarning(); Loading Loading
app/Database/Migrations/2021-12-09-130000_add_clips.php +1 −2 Original line number Diff line number Diff line Loading @@ -39,10 +39,9 @@ class AddClips extends Migration 'type' => 'DECIMAL(7,3)', 'unsigned' => true, ], 'label' => [ 'title' => [ 'type' => 'VARCHAR', 'constraint' => 128, 'null' => true, ], 'type' => [ 'type' => 'ENUM', Loading
app/Entities/Clip/BaseClip.php +2 −2 Original line number Diff line number Diff line Loading @@ -29,7 +29,7 @@ use Modules\Auth\Entities\User; * @property Podcast $podcast * @property int $episode_id * @property Episode $episode * @property string $label * @property string $title * @property double $start_time * @property double $end_time * @property double $duration Loading Loading @@ -68,7 +68,7 @@ class BaseClip extends Entity 'id' => 'integer', 'podcast_id' => 'integer', 'episode_id' => 'integer', 'label' => 'string', 'title' => 'string', 'start_time' => 'double', 'duration' => 'double', 'type' => 'string', Loading
app/Helpers/rss_helper.php +2 −2 Original line number Diff line number Diff line Loading @@ -255,7 +255,7 @@ if (! function_exists('get_rss_feed')) { $comments->addAttribute('uri', url_to('episode-comments', $podcast->handle, $episode->slug)); $comments->addAttribute('contentType', 'application/podcast-activity+json'); if ($episode->transcript->file_url !== '') { if ($episode->transcript !== null) { $transcriptElement = $item->addChild('transcript', null, $podcastNamespace); $transcriptElement->addAttribute('url', $episode->transcript->file_url); $transcriptElement->addAttribute( Loading @@ -275,7 +275,7 @@ if (! function_exists('get_rss_feed')) { foreach ($episode->soundbites as $soundbite) { // TODO: differentiate video from soundbites? $soundbiteElement = $item->addChild('soundbite', $soundbite->label, $podcastNamespace); $soundbiteElement = $item->addChild('soundbite', $soundbite->title, $podcastNamespace); $soundbiteElement->addAttribute('start_time', (string) $soundbite->start_time); $soundbiteElement->addAttribute('duration', (string) $soundbite->duration); } Loading
app/Models/ClipModel.php +48 −28 Original line number Diff line number Diff line Loading @@ -39,7 +39,7 @@ class ClipModel extends Model 'id', 'podcast_id', 'episode_id', 'label', 'title', 'start_time', 'duration', 'type', Loading Loading @@ -89,33 +89,6 @@ class ClipModel extends Model parent::__construct($db, $validation); } /** * Gets all clips for an episode * * @return Soundbite[] */ public function getEpisodeSoundbites(int $podcastId, int $episodeId): array { $cacheName = "podcast#{$podcastId}_episode#{$episodeId}_soundbites"; if (! ($found = cache($cacheName))) { $found = $this->where([ 'episode_id' => $episodeId, 'podcast_id' => $podcastId, 'type' => 'audio', ]) ->orderBy('start_time') ->findAll(); foreach ($found as $key => $soundbite) { $found[$key] = new Soundbite($soundbite->toArray()); } cache() ->save($cacheName, $found, DECADE); } return $found; } public function getVideoClipById(int $videoClipId): ?VideoClip { $cacheName = "video-clip#{$videoClipId}"; Loading Loading @@ -184,6 +157,53 @@ class ClipModel extends Model return $found; } public function getSoundbiteById(int $soundbiteId): ?Soundbite { $cacheName = "soundbite#{$soundbiteId}"; if (! ($found = cache($cacheName))) { $clip = $this->find($soundbiteId); if ($clip === null) { return null; } // @phpstan-ignore-next-line $found = new Soundbite($clip->toArray()); cache() ->save($cacheName, $found, DECADE); } return $found; } /** * Gets all clips for an episode * * @return Soundbite[] */ public function getEpisodeSoundbites(int $podcastId, int $episodeId): array { $cacheName = "podcast#{$podcastId}_episode#{$episodeId}_soundbites"; if (! ($found = cache($cacheName))) { $found = $this->where([ 'episode_id' => $episodeId, 'podcast_id' => $podcastId, 'type' => 'audio', ]) ->orderBy('start_time') ->findAll(); foreach ($found as $key => $soundbite) { $found[$key] = new Soundbite($soundbite->toArray()); } cache() ->save($cacheName, $found, DECADE); } return $found; } public function deleteSoundbite(int $podcastId, int $episodeId, int $clipId): BaseResult | bool { cache() Loading
app/Resources/js/admin.ts +1 −2 Original line number Diff line number Diff line Loading @@ -10,11 +10,11 @@ import "./modules/markdown-preview"; import "./modules/markdown-write-preview"; import MultiSelect from "./modules/MultiSelect"; import "./modules/permalink-edit"; import "./modules/play-soundbite"; import PublishMessageWarning from "./modules/PublishMessageWarning"; import Select from "./modules/Select"; import SidebarToggler from "./modules/SidebarToggler"; import Slugify from "./modules/Slugify"; import Soundbites from "./modules/Soundbites"; import ThemePicker from "./modules/ThemePicker"; import Time from "./modules/Time"; import Tooltip from "./modules/Tooltip"; Loading @@ -31,7 +31,6 @@ SidebarToggler(); ClientTimezone(); DateTimePicker(); Time(); Soundbites(); Clipboard(); ThemePicker(); PublishMessageWarning(); Loading