Skip to content

Commit

Permalink
Merge pull request #2 from LaswitchTech/dev
Browse files Browse the repository at this point in the history
Publishing v1.0.2
  • Loading branch information
LouisOuellet authored Jan 23, 2025
2 parents fac24b8 + 05881dc commit 9da7189
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 13 deletions.
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1.0.1
v1.0.2
18 changes: 9 additions & 9 deletions composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

18 changes: 15 additions & 3 deletions src/Router.php
Original file line number Diff line number Diff line change
Expand Up @@ -271,6 +271,10 @@ protected function genHTAccess(){
// Initialize .htaccess
$htaccess = $errors;

// Add MIME type for .mjs files
$htaccess .= "AddType application/javascript .mjs" . PHP_EOL;
$htaccess .= PHP_EOL;

// Apache Headers
$htaccess .= "<IfModule mod_headers.c>" . PHP_EOL;
$htaccess .= " RequestHeader unset Proxy" . PHP_EOL;
Expand All @@ -295,6 +299,10 @@ protected function genHTAccess(){
// Initialize .htaccess
$htaccess = $errors;

// Add MIME type for .mjs files
$htaccess .= "AddType application/javascript .mjs" . PHP_EOL;
$htaccess .= PHP_EOL;

// Apache Headers
$htaccess .= "<IfModule mod_headers.c>" . PHP_EOL;
$htaccess .= " RequestHeader unset Proxy" . PHP_EOL;
Expand Down Expand Up @@ -900,15 +908,14 @@ protected function menu($location = 'sidebar', $parent = null) {
if($parent){
if(!isset($param['parent']) || $param['parent'] !== $parent) continue;
}
if($param['template'] !== $this->getTemplate()) continue;
if(!isset($param['location'])) continue;
if(is_string($param['location']) && $param['location'] !== $location) continue;
if(is_array($param['location']) && !in_array($location,$param['location'])) continue;
if(!$param['public'] && !$this->isAuthenticated()) continue;
if(!$param['public'] && $param['permission'] && !$this->hasPermission("Route>" . $route, $param['level'])) continue;

$parts = array_filter(explode('/', $route));
if(empty($parts)) continue;
if(empty($parts)) $parts = [""];

$current = &$menu;
$accumulated_route = "";
Expand Down Expand Up @@ -959,7 +966,12 @@ protected function js(){
$js = $this->Configurator->get('js');
foreach($js as $file){
if(is_file($this->Configurator->root().'/webroot/'.trim($file,'/'))){
$html .= '<script src="/'.trim($file,'/').'"></script>' . PHP_EOL;
// Check if the file is a module by looking for the file extension
if(str_ends_with($file, '.mjs')){
$html .= '<script type="module" src="/'.trim($file,'/').'"></script>' . PHP_EOL;
} else {
$html .= '<script src="/'.trim($file,'/').'"></script>' . PHP_EOL;
}
}
}
return $html;
Expand Down

0 comments on commit 9da7189

Please sign in to comment.