Cache BrandSettings compiled CSS

This commit is contained in:
Sam Georges 2014-10-16 19:47:37 +11:00
parent fbaab26bfb
commit 1203043a45
4 changed files with 10 additions and 3 deletions

View File

@ -1,4 +1,5 @@
* **Build 15x** (2014-10-x) * **Build 15x** (2014-10-x)
- Back-end area can now be customized with colors and logo, via System > Customize Back-end.
- Added twig filters `|trans` for `Lang::get(...)` and `|transchoice` for `Lang::choice(...)`. - Added twig filters `|trans` for `Lang::get(...)` and `|transchoice` for `Lang::choice(...)`.
- `SettingsModel` behavior now uses a cached database query. - `SettingsModel` behavior now uses a cached database query.

View File

@ -3,6 +3,6 @@
?> ?>
<?php if (BrandSettings::isConfigured()): ?> <?php if (BrandSettings::isConfigured()): ?>
<style> <style>
<?= BrandSettings::renderCss() ?> <?= BrandSettings::get('rendered_css') ?>
</style> </style>
<?php endif ?> <?php endif ?>

View File

@ -57,6 +57,11 @@ class BrandSettings extends Model
$this->secondary_color_dark = self::SECONDARY_DARK; $this->secondary_color_dark = self::SECONDARY_DARK;
} }
public function beforeValidate()
{
$this->rendered_css = self::renderCss();
}
public static function getLogo() public static function getLogo()
{ {
$settings = self::instance(); $settings = self::instance();
@ -78,7 +83,7 @@ class BrandSettings extends Model
'secondary-color-dark' => self::get('secondary_color_dark', self::SECONDARY_DARK), 'secondary-color-dark' => self::get('secondary_color_dark', self::SECONDARY_DARK),
]); ]);
$parser->parse(File::get(__DIR__.'/brandsettings/custom.less')); $parser->parse(File::get(__DIR__.'/brandsettings/custom.less').self::get('custom_css'));
$css = $parser->getCss(); $css = $parser->getCss();
return $css; return $css;

View File

@ -54,5 +54,6 @@ tabs:
type: codeeditor type: codeeditor
tab: Styles tab: Styles
size: giant size: giant
language: css