diff --git a/CHANGELOG.md b/CHANGELOG.md index d4c27f17e..6c2cb7794 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,6 @@ +* **Build 160** (2014-11-01) + - Various fixes to the Backend Brand settings page. + * **Build 158** (2014-10-23) - Fixes an issue where new Themes attached to a project were not being installed on update. - Fixes issue where XDebug aborts the thread for maximum function count. diff --git a/modules/backend/layouts/_custom_styles.htm b/modules/backend/layouts/_custom_styles.htm index 643d16010..c0ad6169a 100644 --- a/modules/backend/layouts/_custom_styles.htm +++ b/modules/backend/layouts/_custom_styles.htm @@ -3,6 +3,6 @@ ?> diff --git a/modules/backend/models/BrandSettings.php b/modules/backend/models/BrandSettings.php index c6dc998f7..e99acde50 100644 --- a/modules/backend/models/BrandSettings.php +++ b/modules/backend/models/BrandSettings.php @@ -3,6 +3,7 @@ use File; use Lang; use Model; +use Cache; use Less_Parser; /** @@ -26,6 +27,8 @@ class BrandSettings extends Model 'logo' => ['System\Models\File'] ]; + const CACHE_KEY = 'backend::brand.custom_css'; + // Pumpkin const PRIMARY_LIGHT = '#e67e22'; @@ -57,9 +60,9 @@ class BrandSettings extends Model $this->secondary_color_dark = self::SECONDARY_DARK; } - public function beforeValidate() + public function afterSave() { - $this->rendered_css = self::renderCss(); + Cache::forget(self::CACHE_KEY); } public static function getLogo() @@ -73,6 +76,17 @@ class BrandSettings extends Model } public static function renderCss() + { + if (Cache::has(self::CACHE_KEY)) { + return Cache::get(self::CACHE_KEY); + } + + $customCss = self::compileCss(); + Cache::forever(self::CACHE_KEY, $customCss); + return $customCss; + } + + public static function compileCss() { $parser = new Less_Parser(['compress' => true]);