Move theme config to database

This commit is contained in:
Toby Zerner 2015-05-31 11:18:19 +09:30
parent 6e1bf0d3de
commit 6b7632cda3
5 changed files with 24 additions and 21 deletions

View File

@ -1,5 +1,3 @@
@import "@{lib-path}/config.less";
@lib-path: "../lib";
@import "@{lib-path}/bootstrap.less";

View File

@ -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;

View File

@ -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%);

View File

@ -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) {

View File

@ -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));