diff --git a/app/Helpers/ThemeHelper.php b/app/Helpers/ThemeHelper.php index ff5420f..094bb6e 100644 --- a/app/Helpers/ThemeHelper.php +++ b/app/Helpers/ThemeHelper.php @@ -13,10 +13,16 @@ class ThemeHelper return $this->getThemeName(); } + public function hasStylesheet() + { + $cssFilename = sprintf('%s/%s/theme.css', $this->getThemePublicPath(), $this->getThemeName()); + return file_exists($cssFilename); + } + public function info() { $themeName = $this->getThemeName(); - $jsonFile = sprintf('%s/%s/theme.json', $this->getThemeBasePath(), $this->sanitiseThemeName($themeName)); + $jsonFile = sprintf('%s/%s/theme.json', $this->getThemePrivatePath(), $this->sanitiseThemeName($themeName)); if (file_exists($jsonFile)) { return json_decode(file_get_contents($jsonFile), true); @@ -47,17 +53,22 @@ class ThemeHelper { return sprintf( '%s/%s/%s.blade.php', - $this->getThemeBasePath(), + $this->getThemePrivatePath(), $themeName, str_replace('.', DIRECTORY_SEPARATOR, $viewPath) ); } - private function getThemeBasePath() + private function getThemePrivatePath() { return sprintf('%s/resources/views/themes', dirname(dirname(__DIR__))); } + private function getThemePublicPath() + { + return sprintf('%s/public/themes', dirname(dirname(__DIR__))); + } + private function getThemeName() { $themeName = ThemeHelper::DEFAULT_THEME; diff --git a/resources/views/themes/base/layout.blade.php b/resources/views/themes/base/layout.blade.php index 56bd5e3..2442d36 100644 --- a/resources/views/themes/base/layout.blade.php +++ b/resources/views/themes/base/layout.blade.php @@ -14,6 +14,11 @@ + + @if (\App\Facade\Theme::hasStylesheet()) + + @endif + @stack('styles')