display per session status clean up

This commit is contained in:
Ro 2021-04-14 12:48:57 -07:00
parent 9cf0cbfbe4
commit bc6fc33592
6 changed files with 53 additions and 25 deletions

View file

@ -36,8 +36,6 @@ class APIControl
break;
}
//there's only one verion of the api for now
$result = [];
switch (isset($args["third"]) ? $args["third"] : "none") {
case "login":
$result = Auth::login($body);

View file

@ -55,15 +55,15 @@ class DashControl
"status" => Session::active(),
];
} else {
header("Location: /dashboard");
die();
$pageOptions = [
"title" => "Fipamo | Create Page",
"mode" => $mode,
"status" => Session::active(),
];
}
} else {
$template = "dash/start.twig";
$pageOptions = [
"title" => "Welcome to Fipamo",
"status" => Session::active(),
];
header("Location: /dashboard");
die();
}
break;

View file

@ -171,23 +171,21 @@ class Book
$writePath = "../content/pages/" . $path . "/" . $body["slug"] . ".md";
}
if ($task == "create") {
if (!is_dir("../content/pages/" . $path)) {
//Directory does not exist, so lets create it.
mkdir("../content/pages/" . $path, 0755, true);
}
file_put_contents($writePath, $write);
} else {
($new = fopen($writePath, "w")) or die("Unable to open file!");
fwrite($new, $write);
fclose($new);
}
$status = DocTools::write($task, $path, $writePath, $write);
$response = [
"message" => "File edited. Nice work",
"type" => $task == "write" ? "postUpdated" : "postAdded",
"id" => $uuid,
];
if ($status) {
$response = [
"message" => "File edited. Nice work",
"type" => $task == "write" ? "postUpdated" : "postAdded",
"id" => $uuid,
];
} else {
$response = [
"message" => "Uh oh. File save problem. Don't panic",
"type" => "postError",
"id" => $uuid,
];
}
return $response;
}

View file

@ -0,0 +1,29 @@
<?php
class DocTools
{
public function __construct()
{
}
public static function write($task, $path, $fileLocation, $fileContents)
{
try {
if ($task == "create") {
if (!is_dir("../content/pages/" . $path)) {
//Directory does not exist, so lets create it.
mkdir("../content/pages/" . $path, 0755, true);
}
file_put_contents($fileLocation, $fileContents);
} else {
($new = fopen($fileLocation, "w")) or die("Unable to open file!");
fwrite($new, $fileContents);
fclose($new);
}
return true;
} catch (Error $error) {
return false;
}
}
}

View file

@ -12,6 +12,7 @@ include "../brain/data/Auth.inc.php";
include "../brain/utility/StringTools.inc.php";
include "../brain/data/Session.inc.php";
include "../brain/utility/FileUploader.inc.php";
include "../brain/utility/DocTools.inc.php";
$app = AppFactory::create();
$twig = Twig::create("../brain/views/");

View file

@ -93,6 +93,7 @@ export default class Base {
notify.alert(err, false);
});
}
/**
handleRestore(e) {
e.stopPropagation();
e.preventDefault();
@ -113,6 +114,7 @@ export default class Base {
notify.alert(err, false);
});
}
**/
handleOptions(e) {
e.stopPropagation();
e.preventDefault();