diff --git a/update.php b/update.php index 40df0c95..4f02eb1c 100755 --- a/update.php +++ b/update.php @@ -15,24 +15,8 @@ if (!$force && !file_exists($needsUpdateFile)) @unlink($needsUpdateFile); - chdir(ROOT_DIR); Shell::exec('git fetch && git reset --hard origin/master'); -$scss = new \Leafo\ScssPhp\Compiler(); - -$scss->setImportPaths([ROOT_DIR.'/web/scss']); - -$compress = true; -if ($compress) -{ - $scss->setFormatter('Leafo\ScssPhp\Formatter\Crunched'); -} -else -{ - $scss->setFormatter('Leafo\ScssPhp\Formatter\Expanded'); - $scss->setLineNumberStyle(Leafo\ScssPhp\Compiler::LINE_COMMENTS); -} - -file_put_contents(ROOT_DIR.'/web/css/all.css', $scss->compile(file_get_contents(ROOT_DIR.'/web/scss/all.scss'))); +View::compileCss(); diff --git a/view/View.class.php b/view/View.class.php index 1c7ea88f..ded5068f 100644 --- a/view/View.class.php +++ b/view/View.class.php @@ -89,4 +89,25 @@ class View { return static::$metaImg ?: '//lbry.io/img/lbry-dark-1600x528.png'; } + + public static function compileCss() + { + $scssCompiler = new \Leafo\ScssPhp\Compiler(); + + $scssCompiler->setImportPaths([ROOT_DIR.'/web/scss']); + + $compress = true; + if ($compress) + { + $scssCompiler->setFormatter('Leafo\ScssPhp\Formatter\Crunched'); + } + else + { + $scssCompiler->setFormatter('Leafo\ScssPhp\Formatter\Expanded'); + $scssCompiler->setLineNumberStyle(Leafo\ScssPhp\Compiler::LINE_COMMENTS); + } + + $css = $scssCompiler->compile(file_get_contents(ROOT_DIR.'/web/scss/all.scss')); + file_put_contents(ROOT_DIR.'/web/css/all.css', $css); + } } \ No newline at end of file diff --git a/web/index.php b/web/index.php index b7a8fe36..e739592c 100644 --- a/web/index.php +++ b/web/index.php @@ -9,6 +9,10 @@ try { i18n::register(); Session::init(); + if (!IS_PRODUCTION) + { + View::compileCss(); + } Controller::dispatch(strtok($_SERVER['REQUEST_URI'], '?')); } catch(Exception $e)