Loading app/Config/Mimes.php +1 −1 Original line number Diff line number Diff line Loading @@ -307,7 +307,7 @@ class Mimes ], 'svg' => ['image/svg+xml', 'application/xml', 'text/xml'], 'vcf' => 'text/x-vcard', 'srt' => ['text/srt', 'text/plain'], 'srt' => ['text/srt', 'text/plain', 'application/octet-stream'], 'vtt' => ['text/vtt', 'text/plain'], 'ico' => ['image/x-icon', 'image/x-ico', 'image/vnd.microsoft.icon'], ]; Loading app/Config/Routes.php +16 −0 Original line number Diff line number Diff line Loading @@ -237,6 +237,22 @@ $routes->group( 'as' => 'episode-delete', 'filter' => 'permission:podcast_episodes-delete', ]); $routes->get( 'transcript-delete', 'Episode::transcriptDelete/$1/$2', [ 'as' => 'transcript-delete', 'filter' => 'permission:podcast_episodes-edit', ] ); $routes->get( 'chapters-delete', 'Episode::chaptersDelete/$1/$2', [ 'as' => 'chapters-delete', 'filter' => 'permission:podcast_episodes-edit', ] ); }); }); Loading app/Controllers/Admin/Episode.php +48 −0 Original line number Diff line number Diff line Loading @@ -96,6 +96,8 @@ class Episode extends BaseController 'enclosure' => 'uploaded[enclosure]|ext_in[enclosure,mp3,m4a]', 'image' => 'is_image[image]|ext_in[image,jpg,png]|min_dims[image,1400,1400]|is_image_squared[image]', 'transcript' => 'ext_in[transcript,txt,html,srt,json]', 'chapters' => 'ext_in[chapters,json]', 'publication_date' => 'valid_date[Y-m-d H:i]|permit_empty', ]; Loading @@ -114,6 +116,8 @@ class Episode extends BaseController 'enclosure' => $this->request->getFile('enclosure'), 'description_markdown' => $this->request->getPost('description'), 'image' => $this->request->getFile('image'), 'transcript' => $this->request->getFile('transcript'), 'chapters' => $this->request->getFile('chapters'), 'parental_advisory' => $this->request->getPost('parental_advisory') !== 'undefined' ? $this->request->getPost('parental_advisory') Loading Loading @@ -189,6 +193,8 @@ class Episode extends BaseController 'uploaded[enclosure]|ext_in[enclosure,mp3,m4a]|permit_empty', 'image' => 'is_image[image]|ext_in[image,jpg,png]|min_dims[image,1400,1400]|is_image_squared[image]', 'transcript' => 'ext_in[transcript,txt,html,srt,json]', 'chapters' => 'ext_in[chapters,json]', 'publication_date' => 'valid_date[Y-m-d H:i]|permit_empty', ]; Loading Loading @@ -231,6 +237,14 @@ class Episode extends BaseController if ($image) { $this->episode->image = $image; } $transcript = $this->request->getFile('transcript'); if ($transcript->isValid()) { $this->episode->transcript = $transcript; } $chapters = $this->request->getFile('chapters'); if ($chapters->isValid()) { $this->episode->chapters = $chapters; } $episodeModel = new EpisodeModel(); Loading Loading @@ -262,6 +276,40 @@ class Episode extends BaseController ]); } public function transcriptDelete() { unlink($this->episode->transcript); $this->episode->transcript_uri = null; $episodeModel = new EpisodeModel(); if (!$episodeModel->update($this->episode->id, $this->episode)) { return redirect() ->back() ->withInput() ->with('errors', $episodeModel->errors()); } return redirect()->back(); } public function chaptersDelete() { unlink($this->episode->chapters); $this->episode->chapters_uri = null; $episodeModel = new EpisodeModel(); if (!$episodeModel->update($this->episode->id, $this->episode)) { return redirect() ->back() ->withInput() ->with('errors', $episodeModel->errors()); } return redirect()->back(); } public function delete() { (new EpisodeModel())->delete($this->episode->id); Loading app/Database/Migrations/2020-06-05-170000_add_episodes.php +10 −0 Original line number Diff line number Diff line Loading @@ -73,6 +73,16 @@ class AddEpisodes extends Migration 'constraint' => 255, 'null' => true, ], 'transcript_uri' => [ 'type' => 'VARCHAR', 'constraint' => 255, 'null' => true, ], 'chapters_uri' => [ 'type' => 'VARCHAR', 'constraint' => 255, 'null' => true, ], 'parental_advisory' => [ 'type' => 'ENUM', 'constraint' => ['clean', 'explicit'], Loading app/Entities/Episode.php +118 −0 Original line number Diff line number Diff line Loading @@ -35,6 +35,16 @@ class Episode extends Entity */ protected $enclosure; /** * @var \CodeIgniter\Files\File */ protected $transcript; /** * @var \CodeIgniter\Files\File */ protected $chapters; /** * @var string */ Loading @@ -55,6 +65,16 @@ class Episode extends Entity */ protected $enclosure_opengraph_url; /** * @var string */ protected $transcript_url; /** * @var string */ protected $chapters_url; /** * Holds text only description, striped of any markdown or html special characters * Loading Loading @@ -86,6 +106,8 @@ class Episode extends Entity 'description_markdown' => 'string', 'description_html' => 'string', 'image_uri' => '?string', 'transcript_uri' => '?string', 'chapters_uri' => '?string', 'parental_advisory' => '?string', 'number' => '?integer', 'season_number' => '?integer', Loading Loading @@ -170,11 +192,75 @@ class Episode extends Entity } } /** * Saves an episode transcript * * @param \CodeIgniter\HTTP\Files\UploadedFile|\CodeIgniter\Files\File $transcript * */ public function setTranscript($transcript) { if ( !empty($transcript) && (!($transcript instanceof \CodeIgniter\HTTP\Files\UploadedFile) || $transcript->isValid()) ) { helper('media'); $this->attributes['transcript_uri'] = save_podcast_media( $transcript, $this->getPodcast()->name, $this->attributes['slug'] . '-transcript' ); } return $this; } /** * Saves an episode chapters * * @param \CodeIgniter\HTTP\Files\UploadedFile|\CodeIgniter\Files\File $chapters * */ public function setChapters($chapters) { if ( !empty($chapters) && (!($chapters instanceof \CodeIgniter\HTTP\Files\UploadedFile) || $chapters->isValid()) ) { helper('media'); $this->attributes['chapters_uri'] = save_podcast_media( $chapters, $this->getPodcast()->name, $this->attributes['slug'] . '-chapters' ); } return $this; } public function getEnclosure() { return new \CodeIgniter\Files\File($this->getEnclosureMediaPath()); } public function getTranscript() { return $this->attributes['transcript_uri'] ? new \CodeIgniter\Files\File($this->getTranscriptMediaPath()) : null; } public function getChapters() { return $this->attributes['chapters_uri'] ? new \CodeIgniter\Files\File($this->getChaptersMediaPath()) : null; } public function getEnclosureMediaPath() { helper('media'); Loading @@ -182,6 +268,24 @@ class Episode extends Entity return media_path($this->attributes['enclosure_uri']); } public function getTranscriptMediaPath() { helper('media'); return $this->attributes['transcript_uri'] ? media_path($this->attributes['transcript_uri']) : null; } public function getChaptersMediaPath() { helper('media'); return $this->attributes['chapters_uri'] ? media_path($this->attributes['chapters_uri']) : null; } public function getEnclosureUrl() { helper('analytics'); Loading Loading @@ -230,6 +334,20 @@ class Episode extends Entity return $this->getEnclosureUrl() . '?_from=-+Open+Graph+-'; } public function getTranscriptUrl() { return $this->attributes['transcript_uri'] ? base_url($this->getTranscriptMediaPath()) : null; } public function getChaptersUrl() { return $this->attributes['chapters_uri'] ? base_url($this->getChaptersMediaPath()) : null; } public function getLink() { return base_url( Loading Loading
app/Config/Mimes.php +1 −1 Original line number Diff line number Diff line Loading @@ -307,7 +307,7 @@ class Mimes ], 'svg' => ['image/svg+xml', 'application/xml', 'text/xml'], 'vcf' => 'text/x-vcard', 'srt' => ['text/srt', 'text/plain'], 'srt' => ['text/srt', 'text/plain', 'application/octet-stream'], 'vtt' => ['text/vtt', 'text/plain'], 'ico' => ['image/x-icon', 'image/x-ico', 'image/vnd.microsoft.icon'], ]; Loading
app/Config/Routes.php +16 −0 Original line number Diff line number Diff line Loading @@ -237,6 +237,22 @@ $routes->group( 'as' => 'episode-delete', 'filter' => 'permission:podcast_episodes-delete', ]); $routes->get( 'transcript-delete', 'Episode::transcriptDelete/$1/$2', [ 'as' => 'transcript-delete', 'filter' => 'permission:podcast_episodes-edit', ] ); $routes->get( 'chapters-delete', 'Episode::chaptersDelete/$1/$2', [ 'as' => 'chapters-delete', 'filter' => 'permission:podcast_episodes-edit', ] ); }); }); Loading
app/Controllers/Admin/Episode.php +48 −0 Original line number Diff line number Diff line Loading @@ -96,6 +96,8 @@ class Episode extends BaseController 'enclosure' => 'uploaded[enclosure]|ext_in[enclosure,mp3,m4a]', 'image' => 'is_image[image]|ext_in[image,jpg,png]|min_dims[image,1400,1400]|is_image_squared[image]', 'transcript' => 'ext_in[transcript,txt,html,srt,json]', 'chapters' => 'ext_in[chapters,json]', 'publication_date' => 'valid_date[Y-m-d H:i]|permit_empty', ]; Loading @@ -114,6 +116,8 @@ class Episode extends BaseController 'enclosure' => $this->request->getFile('enclosure'), 'description_markdown' => $this->request->getPost('description'), 'image' => $this->request->getFile('image'), 'transcript' => $this->request->getFile('transcript'), 'chapters' => $this->request->getFile('chapters'), 'parental_advisory' => $this->request->getPost('parental_advisory') !== 'undefined' ? $this->request->getPost('parental_advisory') Loading Loading @@ -189,6 +193,8 @@ class Episode extends BaseController 'uploaded[enclosure]|ext_in[enclosure,mp3,m4a]|permit_empty', 'image' => 'is_image[image]|ext_in[image,jpg,png]|min_dims[image,1400,1400]|is_image_squared[image]', 'transcript' => 'ext_in[transcript,txt,html,srt,json]', 'chapters' => 'ext_in[chapters,json]', 'publication_date' => 'valid_date[Y-m-d H:i]|permit_empty', ]; Loading Loading @@ -231,6 +237,14 @@ class Episode extends BaseController if ($image) { $this->episode->image = $image; } $transcript = $this->request->getFile('transcript'); if ($transcript->isValid()) { $this->episode->transcript = $transcript; } $chapters = $this->request->getFile('chapters'); if ($chapters->isValid()) { $this->episode->chapters = $chapters; } $episodeModel = new EpisodeModel(); Loading Loading @@ -262,6 +276,40 @@ class Episode extends BaseController ]); } public function transcriptDelete() { unlink($this->episode->transcript); $this->episode->transcript_uri = null; $episodeModel = new EpisodeModel(); if (!$episodeModel->update($this->episode->id, $this->episode)) { return redirect() ->back() ->withInput() ->with('errors', $episodeModel->errors()); } return redirect()->back(); } public function chaptersDelete() { unlink($this->episode->chapters); $this->episode->chapters_uri = null; $episodeModel = new EpisodeModel(); if (!$episodeModel->update($this->episode->id, $this->episode)) { return redirect() ->back() ->withInput() ->with('errors', $episodeModel->errors()); } return redirect()->back(); } public function delete() { (new EpisodeModel())->delete($this->episode->id); Loading
app/Database/Migrations/2020-06-05-170000_add_episodes.php +10 −0 Original line number Diff line number Diff line Loading @@ -73,6 +73,16 @@ class AddEpisodes extends Migration 'constraint' => 255, 'null' => true, ], 'transcript_uri' => [ 'type' => 'VARCHAR', 'constraint' => 255, 'null' => true, ], 'chapters_uri' => [ 'type' => 'VARCHAR', 'constraint' => 255, 'null' => true, ], 'parental_advisory' => [ 'type' => 'ENUM', 'constraint' => ['clean', 'explicit'], Loading
app/Entities/Episode.php +118 −0 Original line number Diff line number Diff line Loading @@ -35,6 +35,16 @@ class Episode extends Entity */ protected $enclosure; /** * @var \CodeIgniter\Files\File */ protected $transcript; /** * @var \CodeIgniter\Files\File */ protected $chapters; /** * @var string */ Loading @@ -55,6 +65,16 @@ class Episode extends Entity */ protected $enclosure_opengraph_url; /** * @var string */ protected $transcript_url; /** * @var string */ protected $chapters_url; /** * Holds text only description, striped of any markdown or html special characters * Loading Loading @@ -86,6 +106,8 @@ class Episode extends Entity 'description_markdown' => 'string', 'description_html' => 'string', 'image_uri' => '?string', 'transcript_uri' => '?string', 'chapters_uri' => '?string', 'parental_advisory' => '?string', 'number' => '?integer', 'season_number' => '?integer', Loading Loading @@ -170,11 +192,75 @@ class Episode extends Entity } } /** * Saves an episode transcript * * @param \CodeIgniter\HTTP\Files\UploadedFile|\CodeIgniter\Files\File $transcript * */ public function setTranscript($transcript) { if ( !empty($transcript) && (!($transcript instanceof \CodeIgniter\HTTP\Files\UploadedFile) || $transcript->isValid()) ) { helper('media'); $this->attributes['transcript_uri'] = save_podcast_media( $transcript, $this->getPodcast()->name, $this->attributes['slug'] . '-transcript' ); } return $this; } /** * Saves an episode chapters * * @param \CodeIgniter\HTTP\Files\UploadedFile|\CodeIgniter\Files\File $chapters * */ public function setChapters($chapters) { if ( !empty($chapters) && (!($chapters instanceof \CodeIgniter\HTTP\Files\UploadedFile) || $chapters->isValid()) ) { helper('media'); $this->attributes['chapters_uri'] = save_podcast_media( $chapters, $this->getPodcast()->name, $this->attributes['slug'] . '-chapters' ); } return $this; } public function getEnclosure() { return new \CodeIgniter\Files\File($this->getEnclosureMediaPath()); } public function getTranscript() { return $this->attributes['transcript_uri'] ? new \CodeIgniter\Files\File($this->getTranscriptMediaPath()) : null; } public function getChapters() { return $this->attributes['chapters_uri'] ? new \CodeIgniter\Files\File($this->getChaptersMediaPath()) : null; } public function getEnclosureMediaPath() { helper('media'); Loading @@ -182,6 +268,24 @@ class Episode extends Entity return media_path($this->attributes['enclosure_uri']); } public function getTranscriptMediaPath() { helper('media'); return $this->attributes['transcript_uri'] ? media_path($this->attributes['transcript_uri']) : null; } public function getChaptersMediaPath() { helper('media'); return $this->attributes['chapters_uri'] ? media_path($this->attributes['chapters_uri']) : null; } public function getEnclosureUrl() { helper('analytics'); Loading Loading @@ -230,6 +334,20 @@ class Episode extends Entity return $this->getEnclosureUrl() . '?_from=-+Open+Graph+-'; } public function getTranscriptUrl() { return $this->attributes['transcript_uri'] ? base_url($this->getTranscriptMediaPath()) : null; } public function getChaptersUrl() { return $this->attributes['chapters_uri'] ? base_url($this->getChaptersMediaPath()) : null; } public function getLink() { return base_url( Loading