public assets

main
Robert 3 weeks ago
parent fbabdb4df4
commit b7b18a924d
  1. 15
      src/Framework/Assets.php
  2. 5
      src/Framework/View.php

@ -36,7 +36,8 @@ class Assets
*/
private static function attemptsRootDir(?string $path): bool {
// up from src and back up to public
$open_base_dir_path = dirname(BaseDir, 1) . '/public/';
$open_base_dir_path = BaseDir. '/public/';
if ($path === null || $path === '') {
return false;
}
@ -107,7 +108,7 @@ class Assets
public static function wrapAsset(string $file, string $scope = 'project') {
$scope = StringFacade::strtolower($scope);
if ($scope === 'cdn') {
$proto = bootstrap\safer_io::get_clean_server_var('SERVER_PROTOCOL');
$proto = $_SERVER['SERVER_PROTOCOL'];
if ($proto === null) {
$protocol = '://';
} else {
@ -116,7 +117,7 @@ class Assets
return (str_contains($file, '://') === true) ? $file : $protocol . $file;
}
if ($scope === 'project' || $scope === 'app') {
$path = PROJECT_ASSETS_DIR . "/";
$path = PROJECT_ASSETS_DIR;
$ism = self::isMinified($path, $file);
return ($ism !== false) ? PROJECT_ASSETS_BASE_REF . "/" . $ism : false;
}
@ -138,14 +139,14 @@ class Assets
if ($scope === 'cdn') {
return "";
} else if ($scope === 'project' || $scope === 'app') {
$path = PROJECT_ASSETS_DIR . "/";
$path = PROJECT_ASSETS_DIR;
} else if ($scope === 'assets') {
$path = ASSETS_DIR . "/";
} else {
return "";
}
$check = self::is_minified($path, $file);
return ($check !==false) ? self::get_ver($path . $check) : false;
$check = self::isMinified($path, $file);
return ($check !==false) ? self::getVer($path . $check) : false;
}
/**
@ -218,7 +219,7 @@ class Assets
}
$safe_path = Security::filterUri($path);
$safe_file = Security::filterUri($file);
if (str_contains($safe_file, '.auto.js')) {
$production = (isLive());
$safe_file = str_replace('.auto.js', '', $safe_file);

@ -140,8 +140,9 @@ final class View
{
if (!empty($render_page)) {
$render_page = str_replace('.php', '', $render_page);
$templ = "/Templates/{$render_page}";
if (bootstrap\requires::safer_file_exists(IO_CORNERSTONE_PROJECT . $templ . '.php') !== false) {
$templ = "Templates/{$render_page}";
if (Requires::saferFileExists(IO_CORNERSTONE_PROJECT . $templ . '.php') !== false) {
$this->template = $templ;
return true;
}

Loading…
Cancel
Save