forked from projects/fipamo
publish site from settings active
with the setting page set up, now the the settings api can be added, beginning with the ability to render all files from settings. the base settings api class is set up, so now the rest of the methods can be added
This commit is contained in:
parent
0951005341
commit
eda377aba3
8 changed files with 119 additions and 48 deletions
27
app/Http/Controllers/API/SettingsAPIController.php
Normal file
27
app/Http/Controllers/API/SettingsAPIController.php
Normal file
|
@ -0,0 +1,27 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Http\Controllers\API;
|
||||||
|
|
||||||
|
use App\Http\Controllers\Controller;
|
||||||
|
use Illuminate\Http\Request;
|
||||||
|
use App\Services\SettingsService;
|
||||||
|
use App\Services\RenderService;
|
||||||
|
|
||||||
|
class SettingsAPIController extends Controller
|
||||||
|
{
|
||||||
|
protected $settings;
|
||||||
|
protected $render;
|
||||||
|
|
||||||
|
public function __construct(SettingsService $settingsService, RenderService $renderService)
|
||||||
|
{
|
||||||
|
$this->settings = $settingsService;
|
||||||
|
$this->render = $renderService;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function publish(Request $request)
|
||||||
|
{
|
||||||
|
$body = json_decode($request->getContent());
|
||||||
|
$result = $this->render->publishAll();
|
||||||
|
return response()->json($result)->header('Content-Type', 'application/json');
|
||||||
|
}
|
||||||
|
}
|
|
@ -25,6 +25,35 @@ class RenderService
|
||||||
$this->theme = $this->settings->getGlobal()['theme'];
|
$this->theme = $this->settings->getGlobal()['theme'];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function publishAll()
|
||||||
|
{
|
||||||
|
$message = [];
|
||||||
|
$dynamicRender = $this->settings->getGlobal()['dynamicRender'];
|
||||||
|
if (isset($dynamicRender) && $dynamicRender === 'true') {
|
||||||
|
$message = [
|
||||||
|
'message' => 'Auto Rendering is already enabled!',
|
||||||
|
'type' => 'RENDER_SUCCESS',
|
||||||
|
];
|
||||||
|
} else {
|
||||||
|
try {
|
||||||
|
$this->archive();
|
||||||
|
$this->tags();
|
||||||
|
$this->pages();
|
||||||
|
$message = [
|
||||||
|
'message' => 'Site Rendered. GOOD EFFORT',
|
||||||
|
'type' => 'RENDER_SUCCESS',
|
||||||
|
];
|
||||||
|
} catch (Error $error) {
|
||||||
|
$message = [
|
||||||
|
'message' => 'Issue With Rendering. DONT PANIC',
|
||||||
|
'type' => 'RENDER_ERROR',
|
||||||
|
];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return $message;
|
||||||
|
}
|
||||||
|
|
||||||
public function archive()
|
public function archive()
|
||||||
{
|
{
|
||||||
$template = $this->theme . '.archive';
|
$template = $this->theme . '.archive';
|
||||||
|
|
9
public/assets/scripts/dash/app/EditSettings.js
Normal file
9
public/assets/scripts/dash/app/EditSettings.js
Normal file
|
@ -0,0 +1,9 @@
|
||||||
|
import Settings from './controllers/SettingsIndex.js';
|
||||||
|
|
||||||
|
document.addEventListener(
|
||||||
|
'DOMContentLoaded',
|
||||||
|
function () {
|
||||||
|
new Settings();
|
||||||
|
},
|
||||||
|
false
|
||||||
|
);
|
|
@ -1,44 +1,44 @@
|
||||||
import FipamoAdminAPI from "../../libraries/FipamoAdminAPI";
|
import FipamoAdminAPI from '../../libraries/FipamoAdminAPI.js';
|
||||||
import Notficaton from "../ui/Notifications";
|
import Notficaton from '../ui/Notifications.js';
|
||||||
const notify = new Notficaton();
|
const notify = new Notficaton();
|
||||||
export default class Mailer {
|
export default class Mailer {
|
||||||
//--------------------------
|
//--------------------------
|
||||||
// constructor
|
// constructor
|
||||||
//--------------------------
|
//--------------------------
|
||||||
constructor() {}
|
constructor() {}
|
||||||
//--------------------------
|
//--------------------------
|
||||||
// methods
|
// methods
|
||||||
//--------------------------
|
//--------------------------
|
||||||
sendMail() {
|
sendMail() {
|
||||||
let mailData = {
|
let mailData = {
|
||||||
content: "This is a test email"
|
content: 'This is a test email'
|
||||||
};
|
};
|
||||||
let admin = new FipamoAdminAPI();
|
let admin = new FipamoAdminAPI();
|
||||||
admin
|
admin
|
||||||
.sendMail(mailData)
|
.sendMail(mailData)
|
||||||
.then((result) => {
|
.then(result => {
|
||||||
notify.alert(result.message, true);
|
notify.alert(result.message, true);
|
||||||
})
|
})
|
||||||
.catch((err) => {
|
.catch(err => {
|
||||||
notify.alert(err.message, false);
|
notify.alert(err.message, false);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
testMail() {
|
testMail() {
|
||||||
let mailData = {
|
let mailData = {
|
||||||
content: "This is a test email",
|
content: 'This is a test email',
|
||||||
mail_task: "TESTING"
|
mail_task: 'TESTING'
|
||||||
};
|
};
|
||||||
let admin = new FipamoAdminAPI();
|
let admin = new FipamoAdminAPI();
|
||||||
admin
|
admin
|
||||||
.sendMail(mailData)
|
.sendMail(mailData)
|
||||||
.then((result) => {
|
.then(result => {
|
||||||
notify.alert(result.message, true);
|
notify.alert(result.message, true);
|
||||||
})
|
})
|
||||||
.catch((err) => {
|
.catch(err => {
|
||||||
notify.alert(err.message, false);
|
notify.alert(err.message, false);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
//--------------------------
|
//--------------------------
|
||||||
// event handlers
|
// event handlers
|
||||||
//--------------------------
|
//--------------------------
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,9 +1,9 @@
|
||||||
import SettingsActions from '../actions/SettingsActions';
|
import SettingsActions from '../actions/SettingsActions.js';
|
||||||
import Maintenance from './MaintenanceManager';
|
import Maintenance from './MaintenanceManager.js';
|
||||||
import FipamoAdminAPI, { TASK_SYNC_SETTNIGS } from '../../libraries/FipamoAdminAPI';
|
import FipamoAdminAPI, { TASK_SYNC_SETTNIGS } from '../../libraries/FipamoAdminAPI.js';
|
||||||
import * as DataEvent from '../../../src/com/events/DataEvent';
|
import * as DataEvent from '../../../dash/app/events/DataEvent.js';
|
||||||
import Mailer from '../actions/Mailer';
|
import Mailer from '../actions/Mailer.js';
|
||||||
import Notifications from '../ui/Notifications';
|
import Notifications from '../ui/Notifications.js';
|
||||||
const notify = new Notifications();
|
const notify = new Notifications();
|
||||||
export default class SettingsIndex {
|
export default class SettingsIndex {
|
||||||
//--------------------------
|
//--------------------------
|
||||||
|
|
|
@ -189,7 +189,7 @@ class FipamoAdminAPI {
|
||||||
//API_PUBLISH_PAGES,
|
//API_PUBLISH_PAGES,
|
||||||
this.baseURL ? this.baseURL + API_PUBLISH_PAGES : API_PUBLISH_PAGES,
|
this.baseURL ? this.baseURL + API_PUBLISH_PAGES : API_PUBLISH_PAGES,
|
||||||
TASK_PUBLISH_SITE,
|
TASK_PUBLISH_SITE,
|
||||||
REQUEST_TYPE_POST,
|
REQUEST_TYPE_PUT,
|
||||||
CONTENT_TYPE_JSON,
|
CONTENT_TYPE_JSON,
|
||||||
data
|
data
|
||||||
)
|
)
|
||||||
|
|
|
@ -110,3 +110,6 @@
|
||||||
</section>
|
</section>
|
||||||
</article>
|
</article>
|
||||||
@endsection
|
@endsection
|
||||||
|
@section('scripting')
|
||||||
|
<script type="module" src="/assets/scripts/dash/app/EditSettings.js"></script>
|
||||||
|
@endsection
|
||||||
|
|
|
@ -4,6 +4,7 @@ use Illuminate\Support\Facades\Route;
|
||||||
use App\Http\Controllers\API\AuthAPIController;
|
use App\Http\Controllers\API\AuthAPIController;
|
||||||
use App\Http\Controllers\API\PageAPIController;
|
use App\Http\Controllers\API\PageAPIController;
|
||||||
use App\Http\Controllers\API\FileUploadAPIController;
|
use App\Http\Controllers\API\FileUploadAPIController;
|
||||||
|
use App\Http\Controllers\API\SettingsAPIController;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|--------------------------------------------------------------------------
|
|--------------------------------------------------------------------------
|
||||||
|
@ -23,3 +24,5 @@ Route::put("/v1/page/write", [PageAPIController::class, 'write']);
|
||||||
Route::post("/v1/page/create", [PageAPIController::class, 'create']);
|
Route::post("/v1/page/create", [PageAPIController::class, 'create']);
|
||||||
//handle file uploads
|
//handle file uploads
|
||||||
Route::post("/v1/files", [FileUploadAPIController::class, 'upload']);
|
Route::post("/v1/files", [FileUploadAPIController::class, 'upload']);
|
||||||
|
//settings
|
||||||
|
Route::put("/v1/settings/publish", [SettingsAPIController::class, 'publish']);
|
||||||
|
|
Loading…
Reference in a new issue