From bae7096ca14374651cb94e46586b80335de1bfb3 Mon Sep 17 00:00:00 2001 From: cgfhtw Date: Tue, 24 Oct 2023 15:04:45 +0200 Subject: [PATCH] Better Primeview esm path --- application/config/routes.php | 3 --- .../public/{Primevue.php => js/Components.php} | 15 ++++++--------- 2 files changed, 6 insertions(+), 12 deletions(-) rename application/controllers/public/{Primevue.php => js/Components.php} (74%) diff --git a/application/config/routes.php b/application/config/routes.php index b1dcc13fb..9fad59d88 100644 --- a/application/config/routes.php +++ b/application/config/routes.php @@ -63,9 +63,6 @@ $route['api/v1/system/[S|s]prache/(:any)'] = 'api/v1/system/sprache2/$1'; $route['studentenverwaltung/(:any)/(:any)'] = 'Studentenverwaltung/index'; -$route['public/js/components/primevue/(:any)/(:any)'] = 'public/Primevue/index/$1/$2'; -$route['public/js/components/primevue/(:any)/(:any)/(:any)'] = 'public/Primevue/index/$2/$3/$1'; - // load routes from extensions $subdir = 'application/config/extensions'; $dirlist = scandir($subdir); diff --git a/application/controllers/public/Primevue.php b/application/controllers/public/js/Components.php similarity index 74% rename from application/controllers/public/Primevue.php rename to application/controllers/public/js/Components.php index a1ae40692..830e7ea65 100644 --- a/application/controllers/public/Primevue.php +++ b/application/controllers/public/js/Components.php @@ -2,24 +2,21 @@ if (! defined('BASEPATH')) exit('No direct script access allowed'); -class Primevue extends FHC_Controller +class Components extends FHC_Controller { /** * @return void */ - public function index($path, $file, $extrapath = null) + public function primevue(...$args) { - if ($extrapath) - $path = $extrapath . '/' . $path; - $target = FHCPATH . 'vendor/npm-asset/primevue/' . $path . '/' . $file; + $path = implode('/', $args); + $target = FHCPATH . 'vendor/npm-asset/primevue/' . $path; if (!file_exists($target)) return show_404(); - $newUrl = '../../'; - if ($extrapath) - $newUrl .= '../'; + $newUrl = str_repeat('../', count($args)); - $ext = substr($file, -7) == '.min.js' ? '.esm.min.js' : '.esm.js'; + $ext = substr($path, -7) == '.min.js' ? '.esm.min.js' : '.esm.js'; $contents = file_get_contents($target);