From 8ea3221fdc8c512e919f1b50e864311ec4021a66 Mon Sep 17 00:00:00 2001 From: Robert Date: Fri, 16 Dec 2022 09:07:03 -0500 Subject: [PATCH] fixed assets path --- src/bootstrap/site_helper.php | 6 +----- src/classes/assets.php | 2 +- src/classes/html_document.php | 28 ++++++++++++++++++++++++---- 3 files changed, 26 insertions(+), 10 deletions(-) diff --git a/src/bootstrap/site_helper.php b/src/bootstrap/site_helper.php index c9ae66d..942c4c7 100644 --- a/src/bootstrap/site_helper.php +++ b/src/bootstrap/site_helper.php @@ -208,15 +208,11 @@ final class site_helper { $up_one = dirname(self::$ROOT, 1); $project = self::$PRJ; -/** - * @todo Remove once DONE: TTS_BASE_REF - */ - define('TTS_BASE_REF', ''); // REmove once DONE if (!empty(self::get_route())) { define('TTS_SITE_URL', self::tts_site_url()); define('TTS_PROJECT_BASE_REF', TTS_SITE_URL . $project); define("TTS_BROWSER", \tts\safer_io::get_clean_server_var('HTTP_USER_AGENT')); - define('PROJECT_ASSETS_BASE_REF', '/assets'); + define('PROJECT_ASSETS_BASE_REF', "/assets/" . $project); define("PROJECT_ASSETS_DIR", $up_one . "/public/assets/" . $project); } else { // Web Server URI not found diff --git a/src/classes/assets.php b/src/classes/assets.php index fbeada4..52a6d36 100644 --- a/src/classes/assets.php +++ b/src/classes/assets.php @@ -14,7 +14,7 @@ final class assets { public static function get_ajax_files(string $ajax_folder): string { $safe_folder = \tts\security::filter_uri($ajax_folder); - + $ret = "var assets_files = [];" . PHP_EOL; $js = glob($safe_folder . "*.{js,css}", GLOB_BRACE); foreach($js as $file) { diff --git a/src/classes/html_document.php b/src/classes/html_document.php index f722731..bc43c4b 100644 --- a/src/classes/html_document.php +++ b/src/classes/html_document.php @@ -32,15 +32,35 @@ class html_document { $css = \tts\main\configure::get('html', 'css'); if (\tts\common::get_count($css) > 0) { foreach($css as $file=>$path) { - if (is_array($file) || is_array($path)) continue; - $this->add_css($file, $path); + if (is_array($file)) continue; + if (is_array($path)) { + if (isset($path['path'])) { + $path_type = $path['path']; + unset($path['path']); + } else { + $path_type = "project"; + } + $this->add_css($file, $path_type, $path); + } else { + $this->add_css($file, $path); + } } } $js = \tts\main\configure::get('html', 'javascript'); if (\tts\common::get_count($js) >0) { foreach($js as $file=>$path) { - if (is_array($file) || is_array($path)) continue; - $this->add_js($file, $path); + if (is_array($file)) continue; + if (is_array($path)) { + if (isset($path['path'])) { + $path_type = $path['path']; + unset($path['path']); + } else { + $path_type = "project"; + } + $this->add_js($file, $path_type, $path); + } else { + $this->add_js($file, $path); + } } } }