mirror of
https://github.com/pixelfed/pixelfed.git
synced 2024-11-22 06:21:27 +00:00
Remove admin .env editor
This commit is contained in:
parent
9093549dc2
commit
f3f35f590d
3 changed files with 0 additions and 121 deletions
|
@ -199,30 +199,6 @@ trait AdminSettingsController
|
||||||
return view('admin.settings.backups', compact('files'));
|
return view('admin.settings.backups', compact('files'));
|
||||||
}
|
}
|
||||||
|
|
||||||
public function settingsConfig(Request $request)
|
|
||||||
{
|
|
||||||
$editor = config('pixelfed.admin.env_editor');
|
|
||||||
$config = !$editor ? false : file_get_contents(base_path('.env'));
|
|
||||||
$backup = !$editor ? false : (is_file(base_path('.env.backup')) ? file_get_contents(base_path('.env.backup')) : false);
|
|
||||||
return view('admin.settings.config', compact('editor', 'config', 'backup'));
|
|
||||||
}
|
|
||||||
|
|
||||||
public function settingsConfigStore(Request $request)
|
|
||||||
{
|
|
||||||
if(config('pixelfed.admin.env_editor') !== true) {
|
|
||||||
abort(400);
|
|
||||||
}
|
|
||||||
return ['msg' => 200];
|
|
||||||
}
|
|
||||||
|
|
||||||
public function settingsConfigRestore(Request $request)
|
|
||||||
{
|
|
||||||
if(config('pixelfed.admin.env_editor') !== true) {
|
|
||||||
abort(400);
|
|
||||||
}
|
|
||||||
return ['msg' => 200];
|
|
||||||
}
|
|
||||||
|
|
||||||
public function settingsMaintenance(Request $request)
|
public function settingsMaintenance(Request $request)
|
||||||
{
|
{
|
||||||
return view('admin.settings.maintenance');
|
return view('admin.settings.maintenance');
|
||||||
|
|
|
@ -1,94 +0,0 @@
|
||||||
@extends('admin.partial.template')
|
|
||||||
|
|
||||||
@include('admin.settings.sidebar')
|
|
||||||
|
|
||||||
@section('section')
|
|
||||||
<div class="title">
|
|
||||||
<h3 class="font-weight-bold">Configuration Settings</h3>
|
|
||||||
@if($editor == false)
|
|
||||||
<hr>
|
|
||||||
<div class="card bg-light shadow-none rounded-0">
|
|
||||||
<div class="card-body text-center py-5">
|
|
||||||
<p class="lead text-muted font-weight-bold">Configuration Editor is disabled</p>
|
|
||||||
<p class="mb-0">To enable it, add <code>ADMIN_ENV_EDITOR=true</code> to <code>.env</code><br>then run <code>php artisan config:cache</code></p>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
@else
|
|
||||||
<p class="lead">Edit configuration settings</p>
|
|
||||||
<p class="alert alert-warning">
|
|
||||||
<strong>Warning:</strong> If you have opcache enabled, you may need to restart php for the changes to take effect.
|
|
||||||
</p>
|
|
||||||
</div>
|
|
||||||
<hr>
|
|
||||||
<div>
|
|
||||||
<div id="editor">{{$config}}</div>
|
|
||||||
<hr>
|
|
||||||
<div class="d-flex justify-content-between px-3">
|
|
||||||
@if($backup)
|
|
||||||
<button class="btn btn-outline-secondary font-weight-bold py-1 btn-restore">Restore backup .env</button>
|
|
||||||
@else
|
|
||||||
<div></div>
|
|
||||||
@endif
|
|
||||||
<button class="btn btn-primary font-weight-bold py-1 btn-save">Save</button>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
@endif
|
|
||||||
@endsection
|
|
||||||
@if($editor == true)
|
|
||||||
@push('scripts')
|
|
||||||
<script src="{{mix('js/ace.js')}}"></script>
|
|
||||||
<script>
|
|
||||||
let editor = ace.edit("editor");
|
|
||||||
editor.session.setUseWrapMode(true);
|
|
||||||
editor.setTheme("ace/theme/monokai");
|
|
||||||
editor.session.setMode("ace/mode/dot");
|
|
||||||
|
|
||||||
$('.btn-restore').on('click', function(e) {
|
|
||||||
e.preventDefault();
|
|
||||||
let confirm = window.confirm('Are you sure you want to restore your backup .env?');
|
|
||||||
if(!confirm) {
|
|
||||||
swal('Cancelled', 'You have cancelled the .env backup restore.', 'warning');
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
axios.post('/i/admin/settings/config/restore', {
|
|
||||||
}).then(res => {
|
|
||||||
swal('Success', 'Configuration successfully restored!', 'success');
|
|
||||||
setTimeout(function() {
|
|
||||||
window.location.href = window.location.href;
|
|
||||||
}, 3000);
|
|
||||||
});
|
|
||||||
})
|
|
||||||
|
|
||||||
$('.btn-save').on('click', function(e) {
|
|
||||||
e.preventDefault();
|
|
||||||
let confirm = window.confirm('Are you sure you want to overwrite your current .env?');
|
|
||||||
if(!confirm) {
|
|
||||||
swal('Cancelled', 'You have cancelled the .env update.', 'warning');
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
axios.post('/i/admin/settings/config', {
|
|
||||||
res: editor.getValue()
|
|
||||||
}).then(res => {
|
|
||||||
swal('Success', 'Configuration successfully updated!', 'success');
|
|
||||||
setTimeout(function() {
|
|
||||||
window.location.href = window.location.href;
|
|
||||||
}, 3000);
|
|
||||||
});
|
|
||||||
})
|
|
||||||
</script>
|
|
||||||
@endpush
|
|
||||||
|
|
||||||
@push('styles')
|
|
||||||
<style type="text/css" media="screen">
|
|
||||||
#editor {
|
|
||||||
display: block;
|
|
||||||
top: 0;
|
|
||||||
right: 0;
|
|
||||||
bottom: 0;
|
|
||||||
left: 0;
|
|
||||||
width: 100%;
|
|
||||||
min-height: 400px;
|
|
||||||
}
|
|
||||||
</style>
|
|
||||||
@endpush
|
|
||||||
@endif
|
|
|
@ -47,9 +47,6 @@ Route::domain(config('pixelfed.domain.admin'))->prefix('i/admin')->group(functio
|
||||||
Route::get('media/show/{id}', 'AdminController@mediaShow');
|
Route::get('media/show/{id}', 'AdminController@mediaShow');
|
||||||
Route::get('settings', 'AdminController@settings')->name('admin.settings');
|
Route::get('settings', 'AdminController@settings')->name('admin.settings');
|
||||||
Route::post('settings', 'AdminController@settingsHomeStore');
|
Route::post('settings', 'AdminController@settingsHomeStore');
|
||||||
Route::get('settings/config', 'AdminController@settingsConfig')->name('admin.settings.config');
|
|
||||||
Route::post('settings/config', 'AdminController@settingsConfigStore');
|
|
||||||
Route::post('settings/config/restore', 'AdminController@settingsConfigRestore');
|
|
||||||
Route::get('settings/features', 'AdminController@settingsFeatures')->name('admin.settings.features');
|
Route::get('settings/features', 'AdminController@settingsFeatures')->name('admin.settings.features');
|
||||||
Route::get('settings/pages', 'AdminController@settingsPages')->name('admin.settings.pages');
|
Route::get('settings/pages', 'AdminController@settingsPages')->name('admin.settings.pages');
|
||||||
Route::get('settings/pages/edit', 'PageController@edit')->name('admin.settings.pages.edit');
|
Route::get('settings/pages/edit', 'PageController@edit')->name('admin.settings.pages.edit');
|
||||||
|
|
Loading…
Reference in a new issue