diff --git a/.prettierrc b/.prettierrc index 57b161e..5caa4b9 100644 --- a/.prettierrc +++ b/.prettierrc @@ -1,36 +1,36 @@ { - "overrides": [ - { - "files": ".prettierrc", - "options": { "parser": "json" } - }, - { - "files": "*.scss", - "options": { - "tabWidth": 4, - "semi": false, - "singleQuote": true, - "printWidth": 90 - } - }, - { - "files": "*.js", - "options": { - "arrowParens": "avoid", - "bracketSpacing": true, - "htmlWhitespaceSensitivity": "css", - "insertPragma": false, - "bracketSameLine": false, - "jsxSingleQuote": true, - "proseWrap": "preserve", - "requirePragma": false, - "semi": true, - "singleQuote": true, - "trailingComma": "none", - "useTabs": true, - "tabWidth": 4, - "printWidth": 90 - } - } - ] + "overrides": [ + { + "files": ".prettierrc", + "options": { "parser": "json" } + }, + { + "files": "*.css", + "options": { + "tabWidth": 2, + "semi": false, + "singleQuote": false, + "printWidth": 90 + } + }, + { + "files": "*.js", + "options": { + "arrowParens": "avoid", + "bracketSpacing": true, + "htmlWhitespaceSensitivity": "css", + "insertPragma": false, + "bracketSameLine": false, + "jsxSingleQuote": true, + "proseWrap": "preserve", + "requirePragma": false, + "semi": true, + "singleQuote": true, + "trailingComma": "none", + "useTabs": true, + "tabWidth": 4, + "printWidth": 90 + } + } + ] } diff --git a/app/Http/Controllers/API/PageAPIController.php b/app/Http/Controllers/API/PageAPIController.php index 1b96588..4cd4c02 100644 --- a/app/Http/Controllers/API/PageAPIController.php +++ b/app/Http/Controllers/API/PageAPIController.php @@ -22,4 +22,11 @@ class PageAPIController extends Controller $result = $this->pages->update($body); 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'); + } } diff --git a/app/Http/Controllers/Dash/IndexController.php b/app/Http/Controllers/Dash/IndexController.php index 3b652d0..fdc7d5c 100644 --- a/app/Http/Controllers/Dash/IndexController.php +++ b/app/Http/Controllers/Dash/IndexController.php @@ -64,13 +64,18 @@ class IndexController extends Controller 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', [ "status" => $this->auth::status(), "mode" => $mode, "page" => $page, - "views" => $this->themes->getCustomViews($page['layout']), - "title" => $page['title'] + "views" => $views, + "title" => $title, ]); } } diff --git a/app/Providers/FipamoServiceProvider.php b/app/Providers/FipamoServiceProvider.php index 7579e41..50c019b 100644 --- a/app/Providers/FipamoServiceProvider.php +++ b/app/Providers/FipamoServiceProvider.php @@ -22,11 +22,11 @@ class FipamoServiceProvider extends ServiceProvider { //services $this->app->bind(SettingsService::class, function ($app) { - return new SettingsService(); + return new SettingsService(new DocService()); }); $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) { @@ -34,7 +34,7 @@ class FipamoServiceProvider extends ServiceProvider }); $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) { diff --git a/app/Repositories/PageRepository.php b/app/Repositories/PageRepository.php index 8441b61..9ab1b89 100644 --- a/app/Repositories/PageRepository.php +++ b/app/Repositories/PageRepository.php @@ -50,6 +50,7 @@ class PageRepository implements PageRepositoryInterface public function create($page) { + return $this->editPage($page, null, 'create'); } public function update($page) @@ -90,7 +91,7 @@ class PageRepository implements PageRepositoryInterface $updated = Carbon::now(); // 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(); //set variables post body for saving $body->id = $id; @@ -131,6 +132,7 @@ class PageRepository implements PageRepositoryInterface // if new page added, update current index in Settings file if ($task == 'create') { //Settings::updateIndex(); + $this->settings->updatePageIndex(); } return [ diff --git a/app/Services/DocService.php b/app/Services/DocService.php index 2ff6b06..6914889 100644 --- a/app/Services/DocService.php +++ b/app/Services/DocService.php @@ -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)) { file_put_contents($fileLocation, json_encode($fileContents)); } else { diff --git a/app/Services/SettingsService.php b/app/Services/SettingsService.php index 2f3a949..2d40dc6 100644 --- a/app/Services/SettingsService.php +++ b/app/Services/SettingsService.php @@ -4,23 +4,49 @@ namespace App\Services; class SettingsService { - protected $config; + protected $settings; protected $folks; 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() { - return $this->config['global']; + $this->settings = $this->loadSettings(); + return $this->settings['global']; } public function getFolks() { 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); + } } diff --git a/app/Services/StringService.php b/app/Services/StringService.php index 63d575e..dfe13b8 100644 --- a/app/Services/StringService.php +++ b/app/Services/StringService.php @@ -8,7 +8,7 @@ class StringService { } - public static function creatUUID() + public static function createUUID() { if (function_exists('com_create_guid') === true) { return trim(com_create_guid(), '{}'); diff --git a/public/assets/css/dash/page-editor.css b/public/assets/css/dash/page-editor.css index 94f7295..4bc1c09 100644 --- a/public/assets/css/dash/page-editor.css +++ b/public/assets/css/dash/page-editor.css @@ -62,11 +62,7 @@ main > section[role="text-editor"] > div[role="text-editor-control"] button { border-radius: 0; } -main - > section[role="text-editor"] - > div[role="text-editor-control"] - button - > i { +main > section[role="text-editor"] > div[role="text-editor-control"] button > i { font-size: 1.6em; } @@ -128,27 +124,16 @@ main left: 0; } -main - > section[role="file-manager"] - > div[role="page-files-list"] - > div.audio-item { - background: url("/assets/images/global/upload-audio.png") no-repeat center - center / cover; +main > section[role="file-manager"] > div[role="page-files-list"] > div.audio-item { + background: url("/assets/images/global/upload-audio.png") no-repeat center center / + cover; } -main - > section[role="file-manager"] - > div[role="page-files-list"] - > div.file-item { - background: url("/assets/images/global/upload-doc.png") no-repeat center - center / cover; +main > section[role="file-manager"] > div[role="page-files-list"] > div.file-item { + background: url("/assets/images/global/upload-doc.png") no-repeat center center / cover; } -main - > section[role="file-manager"] - > div[role="page-files-list"] - > div.file-item - > a { +main > section[role="file-manager"] > div[role="page-files-list"] > div.file-item > a { position: absolute; bottom: 0; background: var(--secondary); @@ -245,10 +230,7 @@ main border-radius: 0 3px 3px 0; } -main - section[role="page-meta"] - div[role="page-meta-wrapper"] - button[data-active="false"] { +main section[role="page-meta"] div[role="page-meta-wrapper"] button[data-active="false"] { background: var(--primary); } @@ -319,10 +301,7 @@ main > section[role="text-editor"] > div[role="edit-post-wrapper"] { margin: 10px 0; } -main - > section[role="text-editor"] - > div[role="edit-post-wrapper"] - textarea:focus { +main > section[role="text-editor"] > div[role="edit-post-wrapper"] textarea:focus { outline: none; border-color: var(--highlight); } @@ -347,10 +326,7 @@ main section[role="text-editor"] div[role="edit-post-wrapper"] #highlight { margin: 0; } -main - section[role="text-editor"] - div[role="edit-post-wrapper"] - #highlight-content { +main section[role="text-editor"] div[role="edit-post-wrapper"] #highlight-content { word-wrap: normal; white-space: pre-wrap; line-break: normal; @@ -363,10 +339,7 @@ main > section[role="text-editor"] > div[role="edit-post-wrapper"] > #edit { caret-color: var(--highlight); } -main - > section[role="text-editor"] - > div[role="edit-post-wrapper"] - > #highlight { +main > section[role="text-editor"] > div[role="edit-post-wrapper"] > #highlight { z-index: 0; } diff --git a/resources/views/back/page.blade.php b/resources/views/back/page.blade.php index 5965cd2..f7c98b5 100644 --- a/resources/views/back/page.blade.php +++ b/resources/views/back/page.blade.php @@ -33,12 +33,12 @@ @section('main-content')
- @if($page['feature'] == null) + @if($feature == '')
-
+
@else @@ -152,7 +152,7 @@ LAYOUTS