Loading src/.gitignore +3 −0 Original line number Diff line number Diff line Loading @@ -125,3 +125,6 @@ nb-configuration.xml /results/ /phpunit*.xml /.phpunit.*.cache # Media files public/media/* src/app/Config/Routes.php +8 −7 Original line number Diff line number Diff line Loading @@ -5,8 +5,7 @@ $routes = Services::routes(); // Load the system's routing file first, so that the app and ENVIRONMENT // can override as needed. if (file_exists(SYSTEMPATH . 'Config/Routes.php')) { if (file_exists(SYSTEMPATH . 'Config/Routes.php')) { require SYSTEMPATH . 'Config/Routes.php'; } Loading @@ -20,7 +19,8 @@ $routes->setDefaultController('Home'); $routes->setDefaultMethod('index'); $routes->setTranslateURIDashes(false); $routes->set404Override(); $routes->setAutoRoute(true); $routes->setAutoRoute(false); $routes->addPlaceholder('podcastName', '^@[a-z0-9\_]{1,191}$'); /** * -------------------------------------------------------------------- Loading @@ -31,6 +31,8 @@ $routes->setAutoRoute(true); // We get a performance increase by specifying the default // route since we don't have to scan directories. $routes->get('/', 'Home::index'); $routes->add('/podcasts/create', 'Podcasts::create'); $routes->add('/(:podcastName)', 'Podcasts::podcastByHandle/$1'); /** * -------------------------------------------------------------------- Loading @@ -45,7 +47,6 @@ $routes->get('/', 'Home::index'); * You will have access to the $routes object within that file without * needing to reload it. */ if (file_exists(APPPATH . 'Config/' . ENVIRONMENT . '/Routes.php')) { if (file_exists(APPPATH . 'Config/' . ENVIRONMENT . '/Routes.php')) { require APPPATH . 'Config/' . ENVIRONMENT . '/Routes.php'; } src/app/Controllers/Podcast.php→src/app/Controllers/Podcasts.php +22 −7 Original line number Diff line number Diff line Loading @@ -5,7 +5,7 @@ use App\Models\LanguageModel; use App\Models\PodcastModel; use RuntimeException; class Podcast extends BaseController class Podcasts extends BaseController { public function index() { Loading @@ -15,10 +15,11 @@ class Podcast extends BaseController public function create() { $model = new PodcastModel(); helper(['form', 'url']); if (!$this->validate([ 'title' => 'required', 'name' => 'required|alpha_dash', 'name' => 'required|regex_match[^[a-z0-9\_]{1,191}$]', 'description' => 'required|max_length[4000]', 'image' => 'uploaded[image]|is_image[image]|ext_in[image,jpg,png]|max_dims[image,3000,3000]', 'owner_email' => 'required|valid_email|permit_empty', Loading @@ -38,20 +39,23 @@ class Podcast extends BaseController 'browser_lang' => $browser_lang, ]; echo view('podcast/create', $data); echo view('podcasts/create', $data); } else { $image = $this->request->getFile('image'); if (!$image->isValid()) { throw new RuntimeException($image->getErrorString() . '(' . $image->getError() . ')'); } $image_path = $image->store(); $podcast_name = $this->request->getVar('name'); $image_name = 'cover.' . $image->getExtension(); $image_storage_folder = 'media/' . $podcast_name . '/'; $image->move($image_storage_folder, $image_name); $model->save([ 'title' => $this->request->getVar('title'), 'name' => $this->request->getVar('name'), 'name' => $podcast_name, 'description' => $this->request->getVar('description'), 'episode_description_footer' => $this->request->getVar('episode_description_footer'), 'image' => $image_path, 'image' => $image_storage_folder . $image_name, 'language' => $this->request->getVar('language'), 'category' => $this->request->getVar('category'), 'explicit' => $this->request->getVar('explicit') or false, Loading @@ -65,7 +69,18 @@ class Podcast extends BaseController 'custom_html_head' => $this->request->getVar('custom_html_head'), ]); echo view('podcast/success'); return redirect()->to(base_url('/@' . $podcast_name)); } } public function podcastByHandle($handle) { $model = new PodcastModel(); $podcast_name = substr($handle, 1); $data['podcast'] = $model->where('name', $podcast_name)->first(); return view('podcasts/view.php', $data); } } src/app/Views/podcast/success.phpdeleted 100644 → 0 +0 −1 Original line number Diff line number Diff line Success! src/app/Views/podcast/create.php→src/app/Views/podcasts/create.php +1 −2 Original line number Diff line number Diff line <?=helper('form')?> <?=$this->extend('layouts/default')?> <?=$this->section('content')?> Loading @@ -9,7 +8,7 @@ <?=\Config\Services::validation()->listErrors()?> </div> <?=form_open_multipart('/podcast/create', ["method" => "post", "class" => "flex flex-col max-w-md"])?> <?=form_open_multipart('podcasts/create', ["method" => "post", "class" => "flex flex-col max-w-md"])?> <?=csrf_field()?> <div class="flex flex-col mb-4"> Loading Loading
src/.gitignore +3 −0 Original line number Diff line number Diff line Loading @@ -125,3 +125,6 @@ nb-configuration.xml /results/ /phpunit*.xml /.phpunit.*.cache # Media files public/media/*
src/app/Config/Routes.php +8 −7 Original line number Diff line number Diff line Loading @@ -5,8 +5,7 @@ $routes = Services::routes(); // Load the system's routing file first, so that the app and ENVIRONMENT // can override as needed. if (file_exists(SYSTEMPATH . 'Config/Routes.php')) { if (file_exists(SYSTEMPATH . 'Config/Routes.php')) { require SYSTEMPATH . 'Config/Routes.php'; } Loading @@ -20,7 +19,8 @@ $routes->setDefaultController('Home'); $routes->setDefaultMethod('index'); $routes->setTranslateURIDashes(false); $routes->set404Override(); $routes->setAutoRoute(true); $routes->setAutoRoute(false); $routes->addPlaceholder('podcastName', '^@[a-z0-9\_]{1,191}$'); /** * -------------------------------------------------------------------- Loading @@ -31,6 +31,8 @@ $routes->setAutoRoute(true); // We get a performance increase by specifying the default // route since we don't have to scan directories. $routes->get('/', 'Home::index'); $routes->add('/podcasts/create', 'Podcasts::create'); $routes->add('/(:podcastName)', 'Podcasts::podcastByHandle/$1'); /** * -------------------------------------------------------------------- Loading @@ -45,7 +47,6 @@ $routes->get('/', 'Home::index'); * You will have access to the $routes object within that file without * needing to reload it. */ if (file_exists(APPPATH . 'Config/' . ENVIRONMENT . '/Routes.php')) { if (file_exists(APPPATH . 'Config/' . ENVIRONMENT . '/Routes.php')) { require APPPATH . 'Config/' . ENVIRONMENT . '/Routes.php'; }
src/app/Controllers/Podcast.php→src/app/Controllers/Podcasts.php +22 −7 Original line number Diff line number Diff line Loading @@ -5,7 +5,7 @@ use App\Models\LanguageModel; use App\Models\PodcastModel; use RuntimeException; class Podcast extends BaseController class Podcasts extends BaseController { public function index() { Loading @@ -15,10 +15,11 @@ class Podcast extends BaseController public function create() { $model = new PodcastModel(); helper(['form', 'url']); if (!$this->validate([ 'title' => 'required', 'name' => 'required|alpha_dash', 'name' => 'required|regex_match[^[a-z0-9\_]{1,191}$]', 'description' => 'required|max_length[4000]', 'image' => 'uploaded[image]|is_image[image]|ext_in[image,jpg,png]|max_dims[image,3000,3000]', 'owner_email' => 'required|valid_email|permit_empty', Loading @@ -38,20 +39,23 @@ class Podcast extends BaseController 'browser_lang' => $browser_lang, ]; echo view('podcast/create', $data); echo view('podcasts/create', $data); } else { $image = $this->request->getFile('image'); if (!$image->isValid()) { throw new RuntimeException($image->getErrorString() . '(' . $image->getError() . ')'); } $image_path = $image->store(); $podcast_name = $this->request->getVar('name'); $image_name = 'cover.' . $image->getExtension(); $image_storage_folder = 'media/' . $podcast_name . '/'; $image->move($image_storage_folder, $image_name); $model->save([ 'title' => $this->request->getVar('title'), 'name' => $this->request->getVar('name'), 'name' => $podcast_name, 'description' => $this->request->getVar('description'), 'episode_description_footer' => $this->request->getVar('episode_description_footer'), 'image' => $image_path, 'image' => $image_storage_folder . $image_name, 'language' => $this->request->getVar('language'), 'category' => $this->request->getVar('category'), 'explicit' => $this->request->getVar('explicit') or false, Loading @@ -65,7 +69,18 @@ class Podcast extends BaseController 'custom_html_head' => $this->request->getVar('custom_html_head'), ]); echo view('podcast/success'); return redirect()->to(base_url('/@' . $podcast_name)); } } public function podcastByHandle($handle) { $model = new PodcastModel(); $podcast_name = substr($handle, 1); $data['podcast'] = $model->where('name', $podcast_name)->first(); return view('podcasts/view.php', $data); } }
src/app/Views/podcast/success.phpdeleted 100644 → 0 +0 −1 Original line number Diff line number Diff line Success!
src/app/Views/podcast/create.php→src/app/Views/podcasts/create.php +1 −2 Original line number Diff line number Diff line <?=helper('form')?> <?=$this->extend('layouts/default')?> <?=$this->section('content')?> Loading @@ -9,7 +8,7 @@ <?=\Config\Services::validation()->listErrors()?> </div> <?=form_open_multipart('/podcast/create', ["method" => "post", "class" => "flex flex-col max-w-md"])?> <?=form_open_multipart('podcasts/create', ["method" => "post", "class" => "flex flex-col max-w-md"])?> <?=csrf_field()?> <div class="flex flex-col mb-4"> Loading