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:
ro 2024-03-19 15:34:01 -06:00
parent 0951005341
commit eda377aba3
No known key found for this signature in database
GPG key ID: 29B551CDBD4D3B50
8 changed files with 119 additions and 48 deletions

View 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');
}
}

View file

@ -25,6 +25,35 @@ class RenderService
$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()
{
$template = $this->theme . '.archive';

View file

@ -0,0 +1,9 @@
import Settings from './controllers/SettingsIndex.js';
document.addEventListener(
'DOMContentLoaded',
function () {
new Settings();
},
false
);

View file

@ -1,5 +1,5 @@
import FipamoAdminAPI from "../../libraries/FipamoAdminAPI";
import Notficaton from "../ui/Notifications";
import FipamoAdminAPI from '../../libraries/FipamoAdminAPI.js';
import Notficaton from '../ui/Notifications.js';
const notify = new Notficaton();
export default class Mailer {
//--------------------------
@ -11,30 +11,30 @@ export default class Mailer {
//--------------------------
sendMail() {
let mailData = {
content: "This is a test email"
content: 'This is a test email'
};
let admin = new FipamoAdminAPI();
admin
.sendMail(mailData)
.then((result) => {
.then(result => {
notify.alert(result.message, true);
})
.catch((err) => {
.catch(err => {
notify.alert(err.message, false);
});
}
testMail() {
let mailData = {
content: "This is a test email",
mail_task: "TESTING"
content: 'This is a test email',
mail_task: 'TESTING'
};
let admin = new FipamoAdminAPI();
admin
.sendMail(mailData)
.then((result) => {
.then(result => {
notify.alert(result.message, true);
})
.catch((err) => {
.catch(err => {
notify.alert(err.message, false);
});
}

View file

@ -1,9 +1,9 @@
import SettingsActions from '../actions/SettingsActions';
import Maintenance from './MaintenanceManager';
import FipamoAdminAPI, { TASK_SYNC_SETTNIGS } from '../../libraries/FipamoAdminAPI';
import * as DataEvent from '../../../src/com/events/DataEvent';
import Mailer from '../actions/Mailer';
import Notifications from '../ui/Notifications';
import SettingsActions from '../actions/SettingsActions.js';
import Maintenance from './MaintenanceManager.js';
import FipamoAdminAPI, { TASK_SYNC_SETTNIGS } from '../../libraries/FipamoAdminAPI.js';
import * as DataEvent from '../../../dash/app/events/DataEvent.js';
import Mailer from '../actions/Mailer.js';
import Notifications from '../ui/Notifications.js';
const notify = new Notifications();
export default class SettingsIndex {
//--------------------------

View file

@ -189,7 +189,7 @@ class FipamoAdminAPI {
//API_PUBLISH_PAGES,
this.baseURL ? this.baseURL + API_PUBLISH_PAGES : API_PUBLISH_PAGES,
TASK_PUBLISH_SITE,
REQUEST_TYPE_POST,
REQUEST_TYPE_PUT,
CONTENT_TYPE_JSON,
data
)

View file

@ -110,3 +110,6 @@
</section>
</article>
@endsection
@section('scripting')
<script type="module" src="/assets/scripts/dash/app/EditSettings.js"></script>
@endsection

View file

@ -4,6 +4,7 @@ use Illuminate\Support\Facades\Route;
use App\Http\Controllers\API\AuthAPIController;
use App\Http\Controllers\API\PageAPIController;
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']);
//handle file uploads
Route::post("/v1/files", [FileUploadAPIController::class, 'upload']);
//settings
Route::put("/v1/settings/publish", [SettingsAPIController::class, 'publish']);