cleaned up new page creation
editing page works but making new pages was still wonky, so that was fixed and now page creation works fine made some minor tweaks to prettier config for css formatting
This commit is contained in:
parent
6a0c583a4f
commit
4f7bbcdf86
12 changed files with 140 additions and 93 deletions
|
@ -5,11 +5,11 @@
|
||||||
"options": { "parser": "json" }
|
"options": { "parser": "json" }
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"files": "*.scss",
|
"files": "*.css",
|
||||||
"options": {
|
"options": {
|
||||||
"tabWidth": 4,
|
"tabWidth": 2,
|
||||||
"semi": false,
|
"semi": false,
|
||||||
"singleQuote": true,
|
"singleQuote": false,
|
||||||
"printWidth": 90
|
"printWidth": 90
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
|
@ -22,4 +22,11 @@ class PageAPIController extends Controller
|
||||||
$result = $this->pages->update($body);
|
$result = $this->pages->update($body);
|
||||||
return response()->json($result)->header('Content-Type', 'application/json');
|
return response()->json($result)->header('Content-Type', 'application/json');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function create(Request $request)
|
||||||
|
{
|
||||||
|
$body = json_decode($request->getContent());
|
||||||
|
$result = $this->pages->create($body);
|
||||||
|
return response()->json($result)->header('Content-Type', 'application/json');
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -64,13 +64,18 @@ class IndexController extends Controller
|
||||||
|
|
||||||
public function page($mode, $uuid)
|
public function page($mode, $uuid)
|
||||||
{
|
{
|
||||||
$page = $this->pages->getById($uuid)->first();
|
$title;
|
||||||
|
$page = [];
|
||||||
|
$views = [];
|
||||||
|
$mode == 'edit' ? $page = $this->pages->getById($uuid)->first() : $page = [];
|
||||||
|
$mode == 'edit' ? $title = $page['title'] : $title = 'Add New';
|
||||||
|
$mode == 'edit' ? $views = $this->themes->getCustomViews($page['layout']) : $views[] = 'page';
|
||||||
return view('back.page', [
|
return view('back.page', [
|
||||||
"status" => $this->auth::status(),
|
"status" => $this->auth::status(),
|
||||||
"mode" => $mode,
|
"mode" => $mode,
|
||||||
"page" => $page,
|
"page" => $page,
|
||||||
"views" => $this->themes->getCustomViews($page['layout']),
|
"views" => $views,
|
||||||
"title" => $page['title']
|
"title" => $title,
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -22,11 +22,11 @@ class FipamoServiceProvider extends ServiceProvider
|
||||||
{
|
{
|
||||||
//services
|
//services
|
||||||
$this->app->bind(SettingsService::class, function ($app) {
|
$this->app->bind(SettingsService::class, function ($app) {
|
||||||
return new SettingsService();
|
return new SettingsService(new DocService());
|
||||||
});
|
});
|
||||||
|
|
||||||
$this->app->bind(AuthService::class, function ($app) {
|
$this->app->bind(AuthService::class, function ($app) {
|
||||||
return new AuthService(new SettingsService());
|
return new AuthService(new SettingsService(new DocService()));
|
||||||
});
|
});
|
||||||
|
|
||||||
$this->app->bind(ContentService::class, function ($app) {
|
$this->app->bind(ContentService::class, function ($app) {
|
||||||
|
@ -34,7 +34,7 @@ class FipamoServiceProvider extends ServiceProvider
|
||||||
});
|
});
|
||||||
|
|
||||||
$this->app->bind(ThemeService::class, function ($app) {
|
$this->app->bind(ThemeService::class, function ($app) {
|
||||||
return new ThemeService(new SettingsService());
|
return new ThemeService(new SettingsService(new DocService()));
|
||||||
});
|
});
|
||||||
|
|
||||||
$this->app->bind(PaginateService::class, function ($app) {
|
$this->app->bind(PaginateService::class, function ($app) {
|
||||||
|
|
|
@ -50,6 +50,7 @@ class PageRepository implements PageRepositoryInterface
|
||||||
|
|
||||||
public function create($page)
|
public function create($page)
|
||||||
{
|
{
|
||||||
|
return $this->editPage($page, null, 'create');
|
||||||
}
|
}
|
||||||
|
|
||||||
public function update($page)
|
public function update($page)
|
||||||
|
@ -90,7 +91,7 @@ class PageRepository implements PageRepositoryInterface
|
||||||
$updated = Carbon::now();
|
$updated = Carbon::now();
|
||||||
|
|
||||||
// grab current index from settings and update
|
// grab current index from settings and update
|
||||||
$id = $task != 'create' ? $body->id : $this->settings->getGlobal()['currentIndex'];
|
$id = $task != 'create' ? $body->id : $this->settings->getSettings()['library_stats']['current_index'];
|
||||||
$uuid = $task != 'create' ? $body->uuid : $this->strings::createUUID();
|
$uuid = $task != 'create' ? $body->uuid : $this->strings::createUUID();
|
||||||
//set variables post body for saving
|
//set variables post body for saving
|
||||||
$body->id = $id;
|
$body->id = $id;
|
||||||
|
@ -131,6 +132,7 @@ class PageRepository implements PageRepositoryInterface
|
||||||
// if new page added, update current index in Settings file
|
// if new page added, update current index in Settings file
|
||||||
if ($task == 'create') {
|
if ($task == 'create') {
|
||||||
//Settings::updateIndex();
|
//Settings::updateIndex();
|
||||||
|
$this->settings->updatePageIndex();
|
||||||
}
|
}
|
||||||
|
|
||||||
return [
|
return [
|
||||||
|
|
|
@ -28,8 +28,32 @@ class DocService
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function writeSettings($fileLocation, $fileContents)
|
public static function updateMenu($body)
|
||||||
{
|
{
|
||||||
|
$settings = self::$settings;
|
||||||
|
//$menu = $settings["menu"];
|
||||||
|
$item = [
|
||||||
|
'title' => $body['title'],
|
||||||
|
'id' => $body['id'],
|
||||||
|
'uuid' => $body['uuid'],
|
||||||
|
'slug' => $body['slug'],
|
||||||
|
'path' => $body['path'],
|
||||||
|
];
|
||||||
|
if ($body['menu'] == 'true') {
|
||||||
|
if (!find($settings['menu'], ['uuid' => $item['uuid']])) {
|
||||||
|
array_push($settings['menu'], $item);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if (find($settings['menu'], ['uuid' => $item['uuid']])) {
|
||||||
|
pull($settings['menu'], $item);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
DocTools::writeSettings('../config/settings.json', $settings);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function writeSettings($fileContents)
|
||||||
|
{
|
||||||
|
$fileLocation = env('SETTINGS_PATH');
|
||||||
if (!is_file($fileLocation)) {
|
if (!is_file($fileLocation)) {
|
||||||
file_put_contents($fileLocation, json_encode($fileContents));
|
file_put_contents($fileLocation, json_encode($fileContents));
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -4,23 +4,49 @@ namespace App\Services;
|
||||||
|
|
||||||
class SettingsService
|
class SettingsService
|
||||||
{
|
{
|
||||||
protected $config;
|
protected $settings;
|
||||||
protected $folks;
|
protected $folks;
|
||||||
protected $tags;
|
protected $tags;
|
||||||
|
protected $docs;
|
||||||
|
|
||||||
public function __construct()
|
public function __construct(DocService $docService)
|
||||||
{
|
{
|
||||||
$this->config = json_decode(file_get_contents(env('SETTINGS_PATH')), true);
|
|
||||||
$this->folks = json_decode(file_get_contents(env('FOLKS_PATH')), true);
|
$this->folks = json_decode(file_get_contents(env('FOLKS_PATH')), true);
|
||||||
|
$this->docs = $docService;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function loadSettings()
|
||||||
|
{
|
||||||
|
return json_decode(file_get_contents(env('SETTINGS_PATH')), true);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getSettings()
|
||||||
|
{
|
||||||
|
return $this->loadSettings();
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getGlobal()
|
public function getGlobal()
|
||||||
{
|
{
|
||||||
return $this->config['global'];
|
$this->settings = $this->loadSettings();
|
||||||
|
return $this->settings['global'];
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getFolks()
|
public function getFolks()
|
||||||
{
|
{
|
||||||
return $this->folks;
|
return $this->folks;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function updatePageIndex()
|
||||||
|
{
|
||||||
|
$this->settings = $this->loadSettings();
|
||||||
|
$this->settings['library_stats']['current_index']++;
|
||||||
|
$this->docs->writeSettings($this->settings);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function updateGlobalData($key, $value)
|
||||||
|
{
|
||||||
|
$this->settings = $this->loadSettings();
|
||||||
|
$this->settings['global'][$key] = $data;
|
||||||
|
$this->docs->writeSettings($this->settings);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,7 +8,7 @@ class StringService
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function creatUUID()
|
public static function createUUID()
|
||||||
{
|
{
|
||||||
if (function_exists('com_create_guid') === true) {
|
if (function_exists('com_create_guid') === true) {
|
||||||
return trim(com_create_guid(), '{}');
|
return trim(com_create_guid(), '{}');
|
||||||
|
|
|
@ -62,11 +62,7 @@ main > section[role="text-editor"] > div[role="text-editor-control"] button {
|
||||||
border-radius: 0;
|
border-radius: 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
main
|
main > section[role="text-editor"] > div[role="text-editor-control"] button > i {
|
||||||
> section[role="text-editor"]
|
|
||||||
> div[role="text-editor-control"]
|
|
||||||
button
|
|
||||||
> i {
|
|
||||||
font-size: 1.6em;
|
font-size: 1.6em;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -128,27 +124,16 @@ main
|
||||||
left: 0;
|
left: 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
main
|
main > section[role="file-manager"] > div[role="page-files-list"] > div.audio-item {
|
||||||
> section[role="file-manager"]
|
background: url("/assets/images/global/upload-audio.png") no-repeat center center /
|
||||||
> div[role="page-files-list"]
|
cover;
|
||||||
> div.audio-item {
|
|
||||||
background: url("/assets/images/global/upload-audio.png") no-repeat center
|
|
||||||
center / cover;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
main
|
main > section[role="file-manager"] > div[role="page-files-list"] > div.file-item {
|
||||||
> section[role="file-manager"]
|
background: url("/assets/images/global/upload-doc.png") no-repeat center center / cover;
|
||||||
> div[role="page-files-list"]
|
|
||||||
> div.file-item {
|
|
||||||
background: url("/assets/images/global/upload-doc.png") no-repeat center
|
|
||||||
center / cover;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
main
|
main > section[role="file-manager"] > div[role="page-files-list"] > div.file-item > a {
|
||||||
> section[role="file-manager"]
|
|
||||||
> div[role="page-files-list"]
|
|
||||||
> div.file-item
|
|
||||||
> a {
|
|
||||||
position: absolute;
|
position: absolute;
|
||||||
bottom: 0;
|
bottom: 0;
|
||||||
background: var(--secondary);
|
background: var(--secondary);
|
||||||
|
@ -245,10 +230,7 @@ main
|
||||||
border-radius: 0 3px 3px 0;
|
border-radius: 0 3px 3px 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
main
|
main section[role="page-meta"] div[role="page-meta-wrapper"] button[data-active="false"] {
|
||||||
section[role="page-meta"]
|
|
||||||
div[role="page-meta-wrapper"]
|
|
||||||
button[data-active="false"] {
|
|
||||||
background: var(--primary);
|
background: var(--primary);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -319,10 +301,7 @@ main > section[role="text-editor"] > div[role="edit-post-wrapper"] {
|
||||||
margin: 10px 0;
|
margin: 10px 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
main
|
main > section[role="text-editor"] > div[role="edit-post-wrapper"] textarea:focus {
|
||||||
> section[role="text-editor"]
|
|
||||||
> div[role="edit-post-wrapper"]
|
|
||||||
textarea:focus {
|
|
||||||
outline: none;
|
outline: none;
|
||||||
border-color: var(--highlight);
|
border-color: var(--highlight);
|
||||||
}
|
}
|
||||||
|
@ -347,10 +326,7 @@ main section[role="text-editor"] div[role="edit-post-wrapper"] #highlight {
|
||||||
margin: 0;
|
margin: 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
main
|
main section[role="text-editor"] div[role="edit-post-wrapper"] #highlight-content {
|
||||||
section[role="text-editor"]
|
|
||||||
div[role="edit-post-wrapper"]
|
|
||||||
#highlight-content {
|
|
||||||
word-wrap: normal;
|
word-wrap: normal;
|
||||||
white-space: pre-wrap;
|
white-space: pre-wrap;
|
||||||
line-break: normal;
|
line-break: normal;
|
||||||
|
@ -363,10 +339,7 @@ main > section[role="text-editor"] > div[role="edit-post-wrapper"] > #edit {
|
||||||
caret-color: var(--highlight);
|
caret-color: var(--highlight);
|
||||||
}
|
}
|
||||||
|
|
||||||
main
|
main > section[role="text-editor"] > div[role="edit-post-wrapper"] > #highlight {
|
||||||
> section[role="text-editor"]
|
|
||||||
> div[role="edit-post-wrapper"]
|
|
||||||
> #highlight {
|
|
||||||
z-index: 0;
|
z-index: 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -33,12 +33,12 @@
|
||||||
|
|
||||||
@section('main-content')
|
@section('main-content')
|
||||||
<section data-index="{{ $id }}" data-uuid="{{ $uuid }}" data-slug="{{ $slug }}" data-layout="{{ $layout }}" role="file-manager">
|
<section data-index="{{ $id }}" data-uuid="{{ $uuid }}" data-slug="{{ $slug }}" data-layout="{{ $layout }}" role="file-manager">
|
||||||
@if($page['feature'] == null)
|
@if($feature == '')
|
||||||
<div role="file-drop">
|
<div role="file-drop">
|
||||||
<label for="page-files-upload">DRAG AND DROP FILES OR CLICK TO SELECT</label>
|
<label for="page-files-upload">DRAG AND DROP FILES OR CLICK TO SELECT</label>
|
||||||
</div>
|
</div>
|
||||||
<label role="list-title">IMAGES AND VIDEO</label>
|
<label role="list-title">IMAGES AND VIDEO</label>
|
||||||
<div role="page-images-list"></div>
|
<div id="page-images-list" role="page-images-list"></div>
|
||||||
<label role="list-title">FILES</label>
|
<label role="list-title">FILES</label>
|
||||||
<div role="page-files-list"></div>
|
<div role="page-files-list"></div>
|
||||||
@else
|
@else
|
||||||
|
@ -152,7 +152,7 @@
|
||||||
<strong>LAYOUTS</strong>
|
<strong>LAYOUTS</strong>
|
||||||
<select id="page-templates">
|
<select id="page-templates">
|
||||||
@foreach($views as $view)
|
@foreach($views as $view)
|
||||||
@if($view == $page['layout'])
|
@if($view == $layout)
|
||||||
<option value={{ $view }} selected>{{ $view }}</option>
|
<option value={{ $view }} selected>{{ $view }}</option>
|
||||||
@else
|
@else
|
||||||
<option value={{ $view }}>{{ $view }}</option>
|
<option value={{ $view }}>{{ $view }}</option>
|
||||||
|
|
|
@ -1,27 +1,34 @@
|
||||||
|
|
||||||
@php
|
@php
|
||||||
|
|
||||||
if($page['menu'])
|
if(isset($page['menu']) && $page['menu'])
|
||||||
{
|
{
|
||||||
$menu = 'true';
|
$menu = 'true';
|
||||||
}else{
|
}else{
|
||||||
$menu = 'false';
|
$menu = 'false';
|
||||||
}
|
}
|
||||||
|
|
||||||
if($page['featured'])
|
if(isset($page['featured']) && $page['featured'])
|
||||||
{
|
{
|
||||||
$featured = 'true';
|
$featured = 'true';
|
||||||
}else{
|
}else{
|
||||||
$featured = 'false';
|
$featured = 'false';
|
||||||
}
|
}
|
||||||
|
|
||||||
if($page['published'])
|
if(isset($page['published']) && $page['published'])
|
||||||
{
|
{
|
||||||
$published = 'true';
|
$published = 'true';
|
||||||
}else{
|
}else{
|
||||||
$published = 'false';
|
$published = 'false';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(isset($page['uuid']))
|
||||||
|
{
|
||||||
|
$uuid = $page['uuid'];
|
||||||
|
}else{
|
||||||
|
$uuid = 1;
|
||||||
|
}
|
||||||
|
|
||||||
@endphp
|
@endphp
|
||||||
|
|
||||||
<br>
|
<br>
|
||||||
|
@ -37,7 +44,7 @@ if($page['published'])
|
||||||
<svg id="option-published-icon" role="icon">
|
<svg id="option-published-icon" role="icon">
|
||||||
<use id="option-published-icon" xlink:href="/assets/images/global/sprite.svg#entypo-globe"/>
|
<use id="option-published-icon" xlink:href="/assets/images/global/sprite.svg#entypo-globe"/>
|
||||||
</svg>
|
</svg>
|
||||||
</button><a href="/dashboard/page/preview/{{ $page['uuid'] }}" target="_blank"><button id="option-preview" class="option-inactive post-option-btn" data-active="false" title='preview page'>
|
</button><a href="/dashboard/page/preview/{{ $uuid }}" target="_blank"><button id="option-preview" class="option-inactive post-option-btn" data-active="false" title='preview page'>
|
||||||
<svg id="option-preview-icon" role="icon">
|
<svg id="option-preview-icon" role="icon">
|
||||||
<use id="option-preview-icon" xlink:href="/assets/images/global/sprite.svg#entypo-eye"/>
|
<use id="option-preview-icon" xlink:href="/assets/images/global/sprite.svg#entypo-eye"/>
|
||||||
</svg>
|
</svg>
|
||||||
|
|
|
@ -18,5 +18,8 @@ use App\Http\Controllers\API\FileUploadAPIController;
|
||||||
|
|
||||||
//check if session is active
|
//check if session is active
|
||||||
Route::get("/v1/status", [AuthAPIController::class, 'status']);
|
Route::get("/v1/status", [AuthAPIController::class, 'status']);
|
||||||
|
//handle page editing actions
|
||||||
Route::put("/v1/page/write", [PageAPIController::class, 'write']);
|
Route::put("/v1/page/write", [PageAPIController::class, 'write']);
|
||||||
|
Route::post("/v1/page/create", [PageAPIController::class, 'create']);
|
||||||
|
//handle file uploads
|
||||||
Route::post("/v1/files", [FileUploadAPIController::class, 'upload']);
|
Route::post("/v1/files", [FileUploadAPIController::class, 'upload']);
|
||||||
|
|
Loading…
Reference in a new issue