forked from projects/fipamo
added settings page
it's time to get the setting api running so site options can be editied so the first step is to get the settings page up and running. the sorting class is getting a bit heavy, but it will hold the method for gathering settings page info for now.
This commit is contained in:
parent
2420ea193c
commit
0951005341
8 changed files with 198 additions and 7 deletions
|
@ -5,6 +5,7 @@ namespace App\Http\Controllers\Dash;
|
|||
use App\Interfaces\PageRepositoryInterface;
|
||||
use App\Services\AuthService;
|
||||
use App\Services\ThemeService;
|
||||
use App\Services\SortingService;
|
||||
use App\Http\Controllers\Controller;
|
||||
|
||||
class IndexController extends Controller
|
||||
|
@ -12,15 +13,18 @@ class IndexController extends Controller
|
|||
protected PageRepositoryInterface $pages;
|
||||
protected AuthService $auth;
|
||||
protected ThemeService $themes;
|
||||
protected SortingService $sort;
|
||||
|
||||
public function __construct(
|
||||
PageRepositoryInterface $pageRepository,
|
||||
AuthService $authService,
|
||||
ThemeService $themeService,
|
||||
SortingService $sortingService
|
||||
) {
|
||||
$this->pages = $pageRepository;
|
||||
$this->auth = $authService;
|
||||
$this->themes = $themeService;
|
||||
$this->sort = $sortingService;
|
||||
}
|
||||
|
||||
public function login()
|
||||
|
@ -79,4 +83,9 @@ class IndexController extends Controller
|
|||
"title" => $title,
|
||||
]);
|
||||
}
|
||||
|
||||
public function settings()
|
||||
{
|
||||
return view('back.settings', $this->sort->settings());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -63,6 +63,7 @@ class FipamoServiceProvider extends ServiceProvider
|
|||
new SettingsService(new DocService()),
|
||||
new ContentService(),
|
||||
new StringService(),
|
||||
new ThemeService(new SettingsService(new DocService()))
|
||||
),
|
||||
new SettingsService(new DocService()),
|
||||
new ContentService(),
|
||||
|
@ -74,6 +75,7 @@ class FipamoServiceProvider extends ServiceProvider
|
|||
new SettingsService(new DocService()),
|
||||
new ContentService(),
|
||||
new StringService(),
|
||||
new ThemeService(new SettingsService(new DocService()))
|
||||
);
|
||||
});
|
||||
|
||||
|
|
|
@ -32,6 +32,12 @@ class SettingsService
|
|||
return $this->settings['global'];
|
||||
}
|
||||
|
||||
public function getEmail()
|
||||
{
|
||||
$this->settings = $this->loadSettings();
|
||||
return $this->settings['email'];
|
||||
}
|
||||
|
||||
public function getMenu()
|
||||
{
|
||||
$this->settings = $this->loadSettings();
|
||||
|
|
|
@ -2,6 +2,8 @@
|
|||
|
||||
namespace App\Services;
|
||||
|
||||
use Carbon\Carbon;
|
||||
|
||||
use function _\find;
|
||||
use function _\filter;
|
||||
|
||||
|
@ -12,15 +14,18 @@ class SortingService
|
|||
private $settings;
|
||||
private $contents;
|
||||
private $strings;
|
||||
private $themes;
|
||||
|
||||
public function __construct(
|
||||
SettingsService $settingsService,
|
||||
ContentService $contentService,
|
||||
StringService $stringService
|
||||
StringService $stringService,
|
||||
ThemeService $themeService,
|
||||
) {
|
||||
$this->settings = $settingsService;
|
||||
$this->contents = $contentService;
|
||||
$this->strings = $stringService;
|
||||
$this->themes = $themeService;
|
||||
}
|
||||
|
||||
public function tags()
|
||||
|
@ -177,13 +182,11 @@ class SortingService
|
|||
]);
|
||||
}
|
||||
}
|
||||
|
||||
$meta = [
|
||||
'who' => $page['author'],
|
||||
'when' => $page['created'],
|
||||
'tags' => $tags,
|
||||
];
|
||||
|
||||
// if page feature isn't empty, find image from list and set it as background image
|
||||
// if it is empty, just use global background
|
||||
if ($page['feature'] != '' || $page['feature'] != null) {
|
||||
|
@ -199,7 +202,6 @@ class SortingService
|
|||
}
|
||||
}
|
||||
}
|
||||
//TODO: get rid of if statement and always return recent and featured
|
||||
$recent = [];
|
||||
$featured = [];
|
||||
$limit = 4;
|
||||
|
@ -248,4 +250,32 @@ class SortingService
|
|||
];
|
||||
return $pageOptions;
|
||||
}
|
||||
|
||||
public function settings()
|
||||
{
|
||||
$global = $this->settings->getGlobal();
|
||||
$email = $this->settings->getEmail();
|
||||
$updated = new Carbon($global['last_backup']);
|
||||
$status = session('member') != '' ? true : false;
|
||||
$pageOptions = [
|
||||
'title' => 'Settings',
|
||||
'private' => $global['private'],
|
||||
'renderOnSave' => $global['renderOnSave'],
|
||||
'background' => $global['background'],
|
||||
'member' => session('member'),
|
||||
'ftoken' => session('form_token'),
|
||||
'siteTitle' => $global['title'],
|
||||
'baseUrl' => $global['base_url'],
|
||||
'desc' => $global['descriptions'],
|
||||
'lastBackup' => $updated->format('Y M D d'),
|
||||
'currentTheme' => $global['theme'],
|
||||
'themes' => $this->themes->getThemes(),
|
||||
'apiStatus' => isset($global['externalAPI']) ? $global['externalAPI'] : 'false',
|
||||
'dynamicRenderStatus' => isset($global['dynamicRender']) ? $global['dynamicRender'] : 'false',
|
||||
'mailOption' => $email['active'],
|
||||
'mailConfig' => $email,
|
||||
'status' => $status,
|
||||
];
|
||||
return $pageOptions;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"name": "fipamo-default",
|
||||
"display-name": "Fipamo Oh Won",
|
||||
"name": "fipamo-default-v2",
|
||||
"display-name": "Fipamo Oh Too",
|
||||
"author": "Are0h",
|
||||
"description": "The most dangerous default theme in the known universe.",
|
||||
"version": "1.0.0"
|
||||
|
|
112
resources/views/back/settings.blade.php
Normal file
112
resources/views/back/settings.blade.php
Normal file
|
@ -0,0 +1,112 @@
|
|||
@extends('frame')
|
||||
|
||||
@section('title', 'The Dash | '. $title)
|
||||
|
||||
@section('main-content')
|
||||
<article class="settings">
|
||||
<section class="member-settings">
|
||||
<div class="member-avatar">
|
||||
<div class="avatar" style="background: url({{ $member['avatar'] }} ) no-repeat center center / cover"></div>
|
||||
<input id="avatar-upload" type="file" name="avatar-upload"/>
|
||||
</div>
|
||||
<div class="site-background">
|
||||
<div class="background" style="background: url({{ $background }} ) no-repeat center center / cover"></div>
|
||||
<input id="background-upload" type="file" name="backgrond-upload"/>
|
||||
</div>
|
||||
<div>
|
||||
<input type='text' name='handle' id='settings-handle' placeholder='handle' value="{{ $member['handle'] }}" autofocus/>
|
||||
<input type='text' name='email' id='settings-email' placeholder='email' value="{{ $member['email'] }}" autofocus/>
|
||||
<input type='text' name='base-url' id='settings-url' placeholder='url' value="{{ $baseUrl }}" autofocus/>
|
||||
<input type='text' name='base-title' id='settings-title' placeholder='site title' value="{{ $siteTitle }}" autofocus/>
|
||||
<textarea id="settings-desc" type='text' name='settings_desc' class='settings-dec' placeholder='description stuff' , autofocus>{{ $desc }}</textarea>
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<button id="create-backup">
|
||||
<i class="ti ti-disc"></i>
|
||||
<span>BACK UP YOUR SITE</span>
|
||||
</button><br/>
|
||||
@if($lastBackup != '')
|
||||
LAST BACK UP<br/>
|
||||
<a href="/api/v1/files">{{ $lastBackup }}</a><br/>
|
||||
@else
|
||||
<span>span No back ups. Frowny face.</span>
|
||||
@endif
|
||||
</div>
|
||||
<div class="features">
|
||||
@if(isset($apiStatus) && $apiStatus == 'true')
|
||||
<button id="api-access-toggle" title="allow external api" data-enabled="true">
|
||||
<i class="ti ti-phone-incoming"></i>
|
||||
<span id="api-status">API ACCESS ENABLED</span>
|
||||
</button>
|
||||
@else
|
||||
<button id="api-access-toggle" title="allow external api" data-enabled="false">
|
||||
<i class="ti ti-phone-incoming"></i>
|
||||
<span id="api-status">API ACCESS NOT ENABLED</span>
|
||||
</button>
|
||||
|
||||
@endif
|
||||
@if(isset($dynamicRenderStatus) && $dynamicRenderStatus == 'true')
|
||||
<button id="dynamic-render-toggle" title="allow external api" data-enabled="true">
|
||||
<i class="ti ti-arrow-merge"></i>
|
||||
<span id="dynamic-render-status">DYNAMIC PAGE RENDERING</span>
|
||||
</button>
|
||||
|
||||
@else
|
||||
<button id="dynamic-render-toggle" title="allow external api" data-enabled="false">
|
||||
<i class="ti ti-arrow-merge"></i>
|
||||
<span id="dynamic-render-status">STATIC PAGE RENDERING</span>
|
||||
</button>
|
||||
|
||||
@endif
|
||||
</div>
|
||||
<div class="theme">
|
||||
<label>Themes</label><br/>
|
||||
@foreach($themes as $theme)
|
||||
@if($theme['name'] == $currentTheme)
|
||||
<button id="{{ $theme['name'] }}" class="theme-select" data-enabled="true">
|
||||
<i class="ti ti-brush"></i>
|
||||
<span>{{ $theme['display-name'] }}</span>
|
||||
</button>
|
||||
@else
|
||||
<button href="#" id="{{ $theme['name'] }}" class="theme-select" data-enabled="false">
|
||||
<i class="ti ti-brush-off"></i>
|
||||
<span>{{ $theme['display-name'] }}</span>
|
||||
</button>
|
||||
@endif
|
||||
@endforeach
|
||||
</div>
|
||||
<div class="mail">
|
||||
<label>Email</label><br/>
|
||||
@if($mailOption == "option-none" or $mailOption == "")
|
||||
<a href="#" class="mail-option" id="option-none" data-enabled="true">NONE</a>
|
||||
@else
|
||||
<a href="#" class="mail-option" id="option-none" data-enabled="false">NONE</a>
|
||||
@endif
|
||||
@if($mailOption == "option-mg" or $mailOption == "")
|
||||
<a href="#" class="mail-option" id="option-mg" data-enabled="true">MAILGUN</a>
|
||||
@else
|
||||
<a href="#" class="mail-option" id="option-mg" data-enabled="false">MAILGUN</a>
|
||||
@endif
|
||||
@if($mailOption == "option-smtp" or $mailOption == "")
|
||||
<a href="#" class="mail-option" id="option-smtp" data-enabled="true">SMTP</a>
|
||||
@else
|
||||
<a href="#" class="mail-option" id="option-smtp" data-enabled="false">SMTP</a>
|
||||
@endif
|
||||
@include('forms.mailforms')
|
||||
<button id="send-mail">
|
||||
<i class="ti ti-mailbox"></i>
|
||||
<span>TEST MAIL</span>
|
||||
</button>
|
||||
</div>
|
||||
<div>
|
||||
<label>API KEY</label>
|
||||
<br/>
|
||||
{{ $member['key'] }}
|
||||
<br/>
|
||||
<label>FORM TOKEN</label><br/>
|
||||
{{ $ftoken }}
|
||||
</div>
|
||||
</section>
|
||||
</article>
|
||||
@endsection
|
31
resources/views/forms/mailforms.blade.php
Normal file
31
resources/views/forms/mailforms.blade.php
Normal file
|
@ -0,0 +1,31 @@
|
|||
@if($mailOption == "option-smtp")
|
||||
<div id="mail-smtp" data-enabled='true'>
|
||||
<input type='text' name='smtp-domain' id='smtp-domain' placeholder='domain'value="{{$mailConfig['smtp']['domain']}}"/>
|
||||
<input type='text' name='smtp-email' id='smtp-email' placeholder='email' value="{{$mailConfig['smtp']['email']}}" />
|
||||
<input type='text' name='smtp-pass' id='smtp-pass' placeholder='password' value="{{$mailConfig['smtp']['password']}}"/>
|
||||
</div>
|
||||
<div id="mail-mg" data-enabled='false'>
|
||||
<input type='text' name='mg-domain' id='mg-domain' placeholder='domain' value="{{$mailConfig['mailgun']['domain']}}" />
|
||||
<input type='text' name='mg-key' id='mg-key' placeholder='api key' value="{{$mailConfig['mailgun']['key']}}"/>
|
||||
</div>
|
||||
@elseif($mailOption == 'option-mg')
|
||||
<div id="mail-smtp" data-enabled='false'>
|
||||
<input type='text' name='smtp-domain' id='smtp-domain' placeholder='domain'value="{{$mailConfig['smtp']['domain']}}"/>
|
||||
<input type='text' name='smtp-email' id='smtp-email' placeholder='email' value="{{$mailConfig['smtp']['email']}}" />
|
||||
<input type='text' name='smtp-pass' id='smtp-pass' placeholder='password' value="{{$mailConfig['smtp']['password']}}"/>
|
||||
</div>
|
||||
<div id="mail-mg" data-enabled='true'>
|
||||
<input type='text' name='mg-domain' id='mg-domain' placeholder='domain' value="{{$mailConfig['mailgun']['domain']}}" />
|
||||
<input type='text' name='mg-key' id='mg-key' placeholder='api key' value="{{$mailConfig['mailgun']['key']}}"/>
|
||||
</div>
|
||||
@else
|
||||
<div id="mail-smtp" data-enabled='false'>
|
||||
<input type='text' name='smtp-domain' id='smtp-domain' placeholder='domain'value="{{$mailConfig['smtp']['domain']}}"/>
|
||||
<input type='text' name='smtp-email' id='smtp-email' placeholder='email' value="{{$mailConfig['smtp']['email']}}" />
|
||||
<input type='text' name='smtp-pass' id='smtp-pass' placeholder='password' value="{{$mailConfig['smtp']['password']}}"/>
|
||||
</div>
|
||||
<div id="mail-mg" data-enabled='false'>
|
||||
<input type='text' name='mg-domain' id='mg-domain' placeholder='domain' value="{{$mailConfig['mailgun']['domain']}}" />
|
||||
<input type='text' name='mg-key' id='mg-key' placeholder='api key' value="{{$mailConfig['mailgun']['key']}}"/>
|
||||
</div>
|
||||
@endif
|
|
@ -30,6 +30,7 @@ Route::group(['prefix' => 'dashboard', 'middleware' => 'member.check'], function
|
|||
Route::get("/start", [IndexController::class, 'start'])->name('start');
|
||||
Route::get("/pages/{pageFilter?}/{pageNum?}", [IndexController::class, 'book']);
|
||||
Route::get("/page/{mode}/{uuid}", [IndexController::class, 'page']);
|
||||
Route::get("/settings", [IndexController::class, 'settings']);
|
||||
Route::get("/logout", [AuthController::class, 'exit']);
|
||||
});
|
||||
|
||||
|
|
Loading…
Reference in a new issue