From 6b7632cda3dc09d3ad45ca61df6f633f13b12de5 Mon Sep 17 00:00:00 2001 From: Toby Zerner Date: Sun, 31 May 2015 11:18:19 +0930 Subject: [PATCH] Move theme config to database --- framework/core/less/forum/app.less | 2 -- framework/core/less/lib/config.less | 11 ----------- framework/core/less/lib/variables.less | 7 ++++++- .../core/src/Core/Seeders/ConfigTableSeeder.php | 16 ++++++++++------ framework/core/src/Forum/Actions/IndexAction.php | 9 ++++++++- 5 files changed, 24 insertions(+), 21 deletions(-) delete mode 100644 framework/core/less/lib/config.less diff --git a/framework/core/less/forum/app.less b/framework/core/less/forum/app.less index d71f6f25c..9fd60924b 100644 --- a/framework/core/less/forum/app.less +++ b/framework/core/less/forum/app.less @@ -1,5 +1,3 @@ -@import "@{lib-path}/config.less"; - @lib-path: "../lib"; @import "@{lib-path}/bootstrap.less"; diff --git a/framework/core/less/lib/config.less b/framework/core/less/lib/config.less deleted file mode 100644 index e80bbd00e..000000000 --- a/framework/core/less/lib/config.less +++ /dev/null @@ -1,11 +0,0 @@ -// --------------------------------- -// CONFIG - -// Color palette: -// #8F3B3B #9E5541 #99793F #8F8A49 #778F53 #638F53 #537F8F #536F90 #76538F #8F5373 #797979 - -@fl-primary-color: #536F90; -@fl-secondary-color: #536F90; - -@fl-dark-mode: false; -@fl-colored-hdr: false; diff --git a/framework/core/less/lib/variables.less b/framework/core/less/lib/variables.less index eb9ea4c05..d85161fd7 100644 --- a/framework/core/less/lib/variables.less +++ b/framework/core/less/lib/variables.less @@ -1,3 +1,8 @@ +@fl-primary-color: #536F90; +@fl-secondary-color: #536F90; +@fl-dark-mode: false; +@fl-colored-hdr: false; + // --------------------------------- // HELPERS @@ -22,7 +27,7 @@ @fl-shadow-color: rgba(0, 0, 0, 0.35); } .define-body-variables(true) { - @fl-body-primary-color: mix(@fl-primary-color, #000); + @fl-body-primary-color: mix(@fl-primary-color, #000, 80%); @fl-body-secondary-color: hsl(@fl-secondary-hue, min(20%, @fl-secondary-sat), 13%); @fl-body-bg: hsl(@fl-secondary-hue, min(20%, @fl-secondary-sat), 10%); diff --git a/framework/core/src/Core/Seeders/ConfigTableSeeder.php b/framework/core/src/Core/Seeders/ConfigTableSeeder.php index 27daca92d..96d58846e 100644 --- a/framework/core/src/Core/Seeders/ConfigTableSeeder.php +++ b/framework/core/src/Core/Seeders/ConfigTableSeeder.php @@ -14,12 +14,16 @@ class ConfigTableSeeder extends Seeder public function run() { $config = [ - 'api_url' => 'http://flarum.dev/api', - 'base_url' => 'http://flarum.dev', - 'forum_title' => 'Flarum Demo Forum', - 'welcome_message' => 'Flarum is now at a point where you can have basic conversations, so here is a little demo for you to break.', - 'welcome_title' => 'Welcome to Flarum Demo Forum', - 'extensions_enabled' => '[]', + 'api_url' => 'http://flarum.dev/api', + 'base_url' => 'http://flarum.dev', + 'forum_title' => 'Flarum Demo Forum', + 'welcome_message' => 'Flarum is now at a point where you can have basic conversations, so here is a little demo for you to break.', + 'welcome_title' => 'Welcome to Flarum Demo Forum', + 'extensions_enabled' => '[]', + 'theme_primary_color' => '#536F90', + 'theme_secondary_color' => '#536F90', + 'theme_dark_mode' => false, + 'theme_colored_header' => false, ]; DB::table('config')->insert(array_map(function ($key, $value) { diff --git a/framework/core/src/Forum/Actions/IndexAction.php b/framework/core/src/Forum/Actions/IndexAction.php index 30ba095c6..18f70afec 100644 --- a/framework/core/src/Forum/Actions/IndexAction.php +++ b/framework/core/src/Forum/Actions/IndexAction.php @@ -9,6 +9,7 @@ use View; use DB; use Flarum\Forum\Events\RenderView; use Flarum\Api\Request as ApiRequest; +use Flarum\Core; class IndexAction extends BaseAction { @@ -36,7 +37,7 @@ class IndexAction extends BaseAction } $view = View::make('flarum.forum::index') - ->with('title', Config::get('flarum::forum_title', 'Flarum Demo Forum')) + ->with('title', Core::config('forum_title')) ->with('config', $config) ->with('layout', 'flarum.forum::forum') ->with('data', $data) @@ -49,6 +50,12 @@ class IndexAction extends BaseAction $root.'/js/forum/dist/app.js', $root.'/less/forum/app.less' ]); + $assetManager->addLess(' + @fl-primary-color: '.Core::config('theme_primary_color').'; + @fl-secondary-color: '.Core::config('theme_secondary_color').'; + @fl-dark-mode: '.(Core::config('theme_dark_mode') ? 'true' : 'false').'; + @fl-colored_header: '.(Core::config('theme_colored_header') ? 'true' : 'false').'; + '); event(new RenderView($view, $assetManager, $this));