Merge pull request #644 from OllieJC/custom

Add custom CSS and JS settings
This commit is contained in:
KodeStar 2022-03-11 20:28:28 +00:00 committed by GitHub
commit d7742df802
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 63 additions and 2 deletions

View file

@ -127,6 +127,9 @@ class Setting extends Model
}
$value = Form::select('value', $options, null, ['class' => 'form-control']);
break;
case 'textarea':
$value = Form::textarea('value', null, ['class' => 'form-control', 'cols' => '44', 'rows' => '15']);
break;
default:
$value = Form::text('value', null, ['class' => 'form-control']);
break;

View file

@ -44,6 +44,16 @@ class SettingsSeeder extends Seeder
$setting_group->title = 'app.settings.miscellaneous';
$setting_group->save();
}
if(!$setting_group = SettingGroup::find(4)) {
$setting_group = new SettingGroup;
$setting_group->id = 4;
$setting_group->title = 'app.settings.advanced';
$setting_group->order = 3;
$setting_group->save();
} else {
$setting_group->title = 'app.settings.advanced';
$setting_group->save();
}
if($version = Setting::find(1)) {
$version->label = 'app.settings.version';
@ -194,6 +204,38 @@ class SettingsSeeder extends Seeder
$setting->system = true;
$setting->save();
}
if(!$setting = Setting::find(10)) {
$setting = new Setting;
$setting->id = 10;
$setting->group_id = 4;
$setting->key = 'custom_css';
$setting->type = 'textarea';
$setting->label = 'app.settings.custom_css';
$setting->value = '';
$setting->save();
} else {
$setting->type = 'textarea';
$setting->group_id = 4;
$setting->label = 'app.settings.custom_css';
$setting->save();
}
if(!$setting = Setting::find(11)) {
$setting = new Setting;
$setting->id = 11;
$setting->group_id = 4;
$setting->key = 'custom_js';
$setting->type = 'textarea';
$setting->label = 'app.settings.custom_js';
$setting->value = '';
$setting->save();
} else {
$setting->type = 'textarea';
$setting->group_id = 4;
$setting->label = 'app.settings.custom_js';
$setting->save();
}
if(!$home_tag = \App\Item::find(0)) {
$home_tag = new \App\Item;

View file

@ -12,6 +12,8 @@ return [
'settings.system' => 'System',
'settings.appearance' => 'Appearance',
'settings.miscellaneous' => 'Miscellaneous',
'settings.advanced' => 'Advanced',
'settings.support' => 'Support',
'settings.donate' => 'Donate',
@ -29,11 +31,13 @@ return [
'settings.search' => 'search',
'settings.no_items' => 'No items found',
'settings.label' => 'Label',
'settings.value' => 'Value',
'settings.edit' => 'Edit',
'settings.view' => 'View',
'settings.custom_css' => 'Custom CSS',
'settings.custom_js' => 'Custom JavaScript',
'options.none' => '- not set -',
'options.google' => 'Google',

View file

@ -34,6 +34,10 @@
@else
<base href="{{ url('') }}">
@endif
<style id="custom_css">
/* editable using the 'Settings > Advanced > Custom CSS' option */
{!! \App\Setting::fetch('custom_css') !!}
</style>
</head>
<body>
<div id="app"{!! $alt_bg !!}>
@ -114,5 +118,9 @@
<script src="{{ asset('js/app.js?v=4') }}"></script>
@yield('scripts')
<script id="custom_js">
/* editable using the 'Settings > Advanced > Custom JavaScript' option */
{!! \App\Setting::fetch('custom_js') !!}
</script>
</body>
</html>

View file

@ -25,7 +25,11 @@
<tr>
<td>{{ __($setting->label) }}</td>
<td>
@if($setting->type === "textarea")
<pre>{{ $setting->list_value }}</pre>
@else
{!! $setting->list_value !!}
@endif
</td>
<td class="text-center">
@if((bool)$setting->system !== true)
@ -49,4 +53,4 @@
</section>
@endforeach
@endsection
@endsection