forked from projects/fipamo
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" }
|
||||
},
|
||||
{
|
||||
"files": "*.scss",
|
||||
"files": "*.css",
|
||||
"options": {
|
||||
"tabWidth": 4,
|
||||
"tabWidth": 2,
|
||||
"semi": false,
|
||||
"singleQuote": true,
|
||||
"singleQuote": false,
|
||||
"printWidth": 90
|
||||
}
|
||||
},
|
||||
|
|
|
@ -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');
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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,
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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) {
|
||||
|
|
|
@ -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 [
|
||||
|
|
|
@ -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 {
|
||||
|
|
|
@ -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->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);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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(), '{}');
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
|
@ -33,12 +33,12 @@
|
|||
|
||||
@section('main-content')
|
||||
<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">
|
||||
<label for="page-files-upload">DRAG AND DROP FILES OR CLICK TO SELECT</label>
|
||||
</div>
|
||||
<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>
|
||||
<div role="page-files-list"></div>
|
||||
@else
|
||||
|
@ -152,7 +152,7 @@
|
|||
<strong>LAYOUTS</strong>
|
||||
<select id="page-templates">
|
||||
@foreach($views as $view)
|
||||
@if($view == $page['layout'])
|
||||
@if($view == $layout)
|
||||
<option value={{ $view }} selected>{{ $view }}</option>
|
||||
@else
|
||||
<option value={{ $view }}>{{ $view }}</option>
|
||||
|
|
|
@ -1,27 +1,34 @@
|
|||
|
||||
@php
|
||||
|
||||
if($page['menu'])
|
||||
if(isset($page['menu']) && $page['menu'])
|
||||
{
|
||||
$menu = 'true';
|
||||
}else{
|
||||
$menu = 'false';
|
||||
}
|
||||
|
||||
if($page['featured'])
|
||||
if(isset($page['featured']) && $page['featured'])
|
||||
{
|
||||
$featured = 'true';
|
||||
}else{
|
||||
$featured = 'false';
|
||||
}
|
||||
|
||||
if($page['published'])
|
||||
if(isset($page['published']) && $page['published'])
|
||||
{
|
||||
$published = 'true';
|
||||
}else{
|
||||
$published = 'false';
|
||||
}
|
||||
|
||||
if(isset($page['uuid']))
|
||||
{
|
||||
$uuid = $page['uuid'];
|
||||
}else{
|
||||
$uuid = 1;
|
||||
}
|
||||
|
||||
@endphp
|
||||
|
||||
<br>
|
||||
|
@ -37,7 +44,7 @@ if($page['published'])
|
|||
<svg id="option-published-icon" role="icon">
|
||||
<use id="option-published-icon" xlink:href="/assets/images/global/sprite.svg#entypo-globe"/>
|
||||
</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">
|
||||
<use id="option-preview-icon" xlink:href="/assets/images/global/sprite.svg#entypo-eye"/>
|
||||
</svg>
|
||||
|
|
|
@ -18,5 +18,8 @@ use App\Http\Controllers\API\FileUploadAPIController;
|
|||
|
||||
//check if session is active
|
||||
Route::get("/v1/status", [AuthAPIController::class, 'status']);
|
||||
//handle page editing actions
|
||||
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']);
|
||||
|
|
Loading…
Reference in a new issue