Commit 4f1e773c authored by Yassine Doghri's avatar Yassine Doghri
Browse files

feat(episodes): schedule episode with future publication_date by using cache expiration time

- 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
parent 0ab17d10
Loading
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -37,6 +37,8 @@ Javascript dependencies:
  ([Free amCharts license](https://github.com/amcharts/amcharts4/blob/master/dist/script/LICENSE))
- [Choices.js](https://joshuajohnson.co.uk/Choices/)
  ([MIT License](https://github.com/jshjohnson/Choices/blob/master/LICENSE))
- [flatpickr](https://flatpickr.js.org/)
  ([MIT License](https://github.com/flatpickr/flatpickr/blob/master/LICENSE.md))

Other:

+1 −1
Original line number Diff line number Diff line
@@ -26,7 +26,7 @@ class BaseController extends Controller
     *
     * @var array
     */
    protected $helpers = ['auth', 'breadcrumb', 'svg', 'components'];
    protected $helpers = ['auth', 'breadcrumb', 'svg', 'components', 'misc'];

    /**
     * Constructor.
+12 −13
Original line number Diff line number Diff line
@@ -10,6 +10,7 @@ namespace App\Controllers\Admin;

use App\Models\EpisodeModel;
use App\Models\PodcastModel;
use CodeIgniter\I18n\Time;

class Episode extends BaseController
{
@@ -95,9 +96,7 @@ 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]',
            'publication_date' => 'valid_date[Y-m-d]|permit_empty',
            'publication_time' =>
                'regex_match[/^(0[0-9]|1[0-9]|2[0-3]):[0-5][0-9]$/]|permit_empty',
            'publication_date' => 'valid_date[Y-m-d H:i]|permit_empty',
        ];

        if (!$this->validate($rules)) {
@@ -125,11 +124,12 @@ class Episode extends BaseController
            'block' => $this->request->getPost('block') == 'yes',
            'created_by' => user(),
            'updated_by' => user(),
        ]);
        $newEpisode->setPublishedAt(
            'published_at' => Time::createFromFormat(
                'Y-m-d H:i',
                $this->request->getPost('publication_date'),
            $this->request->getPost('publication_time')
        );
                $this->request->getPost('client_timezone')
            )->setTimezone('UTC'),
        ]);

        $episodeModel = new EpisodeModel();

@@ -185,9 +185,7 @@ 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]',
            'publication_date' => 'valid_date[Y-m-d]|permit_empty',
            'publication_time' =>
                'regex_match[/^(0[0-9]|1[0-9]|2[0-3]):[0-5][0-9]$/]|permit_empty',
            'publication_date' => 'valid_date[Y-m-d H:i]|permit_empty',
        ];

        if (!$this->validate($rules)) {
@@ -210,10 +208,11 @@ class Episode extends BaseController
            : null;
        $this->episode->type = $this->request->getPost('type');
        $this->episode->block = $this->request->getPost('block') == 'yes';
        $this->episode->setPublishedAt(
        $this->episode->published_at = Time::createFromFormat(
            'Y-m-d H:i',
            $this->request->getPost('publication_date'),
            $this->request->getPost('publication_time')
        );
            $this->request->getPost('client_timezone')
        )->setTimezone('UTC');
        $this->episode->updated_by = user();

        $enclosure = $this->request->getFile('enclosure');
+1 −4
Original line number Diff line number Diff line
@@ -388,11 +388,8 @@ class Podcast extends BaseController
                    : $nsItunes->block === 'yes',
                'created_by' => user(),
                'updated_by' => user(),
                'published_at' => strtotime($item->pubDate),
            ]);
            $newEpisode->setPublishedAt(
                date('Y-m-d', strtotime($item->pubDate)),
                date('H:i:s', strtotime($item->pubDate))
            );

            $episodeModel = new EpisodeModel();

+1 −1
Original line number Diff line number Diff line
@@ -26,7 +26,7 @@ class BaseController extends Controller
     *
     * @var array
     */
    protected $helpers = ['analytics', 'svg', 'components'];
    protected $helpers = ['analytics', 'svg', 'components', 'misc'];

    /**
     * Constructor.
Loading