diff --git a/brain/controller/DashControl.php b/brain/controller/DashControl.php
index 4fd0e13..c75a724 100644
--- a/brain/controller/DashControl.php
+++ b/brain/controller/DashControl.php
@@ -158,9 +158,9 @@ class DashControl
$page = $book->findPageById($uuid);
$pageOptions = Sorting::page($page);
$preview =
- $settings['global']['theme'] .
- '/' .
- $page['layout'] .
+ $settings['global']['theme'].
+ '/'.
+ $page['layout'].
'.twig';
$html = $display->render($preview, $pageOptions);
$response->getBody()->write($html);
@@ -192,7 +192,6 @@ class DashControl
'title' => 'Reset Password',
];
break;
-
default:
$template = 'dash/start.twig';
if (Session::active()) {
diff --git a/brain/data/Book.php b/brain/data/Book.php
index fb6f22e..237f66a 100644
--- a/brain/data/Book.php
+++ b/brain/data/Book.php
@@ -2,12 +2,11 @@
namespace brain\data;
-use brain\data\Contents;
-use brain\data\Settings;
-use brain\utility\DocTools;
-
use function _\filter;
use function _\find;
+use brain\utility\DocTools;
+use brain\utility\FileUploader;
+use brain\utility\StringTools;
class Book
{
@@ -18,7 +17,8 @@ class Book
public function findPageById(string $uuid)
{
$content = $this->getContents();
- $page = find($content, ["uuid" => $uuid]);
+ $page = find($content, ['uuid' => $uuid]);
+
return $page;
}
@@ -26,9 +26,9 @@ class Book
{
$content = $this->getContents();
if (isset($slug)) {
- $page = find($content, ["slug" => $slug]);
+ $page = find($content, ['slug' => $slug]);
} else {
- $page = find($content, ["layout" => "index"]);
+ $page = find($content, ['layout' => 'index']);
}
return $page;
@@ -37,78 +37,78 @@ class Book
public function editPage($task, $request)
{
$content = $this->getContents();
- if ($task == "delete") {
- //$parsed = json_decode(file_get_contents("php://input"), true);
- //$body = find($content, ["uuid" => $parsed["id"]]);
+ if ($task == 'delete') {
+ // $parsed = json_decode(file_get_contents("php://input"), true);
+ // $body = find($content, ["uuid" => $parsed["id"]]);
$body = $request->getParsedBody();
} else {
$body = $request->getParsedBody();
}
- $page = find($content, ["uuid" => $body["uuid"]]);
+ $page = find($content, ['uuid' => $body['uuid']]);
$files = $request->getUploadedFiles();
- $member = Session::get("member");
+ $member = Session::get('member');
- if ($task != "create") {
+ if ($task != 'create') {
$path =
- date("Y", date($page["rawCreated"])) .
- "/" .
- date("m", date($page["rawCreated"]));
+ date('Y', date($page['rawCreated'])).
+ '/'.
+ date('m', date($page['rawCreated']));
} else {
- $path = date("Y") . "/" . date("m");
+ $path = date('Y').'/'.date('m');
}
$page_feature = '';
$page_files = '';
- if (isset($files["page_files"])) {
- $imageList = "";
- $fileList = "";
- //var_dump($files["page_files"] );
- foreach ($files["page_files"] as $file) {
+ if (isset($files['page_files'])) {
+ $imageList = '';
+ $fileList = '';
+ // var_dump($files["page_files"] );
+ foreach ($files['page_files'] as $file) {
$type = $file->getClientMediaType();
switch ($type) {
- case "image/jpeg":
- case "image/png":
- case "image/gif":
- case "image/svg":
- $imagesPath = "/assets/images/blog/" . $path . "/";
+ case 'image/jpeg':
+ case 'image/png':
+ case 'image/gif':
+ case 'image/svg':
+ $imagesPath = '/assets/images/blog/'.$path.'/';
$imageList =
- $imageList . $imagesPath . urlencode($file->getClientFileName()) . ", ";
+ $imageList.$imagesPath.urlencode($file->getClientFileName()).', ';
FileUploader::uploadFile(
- "../public/assets/images/blog/" . $path . "/",
+ '../public/assets/images/blog/'.$path.'/',
$file
);
break;
- case "video/mp4":
- $videosPath = "/assets/video/blog/" . $path . "/";
+ case 'video/mp4':
+ $videosPath = '/assets/video/blog/'.$path.'/';
$imageList =
- $imageList . $videosPath . urlencode($file->getClientFileName()) . ", ";
+ $imageList.$videosPath.urlencode($file->getClientFileName()).', ';
FileUploader::uploadFile(
- "../public/assets/video/blog/" . $path . "/",
+ '../public/assets/video/blog/'.$path.'/',
$file
);
break;
- case "audio/mpeg":
- $soundPath = "/assets/sound/blog/" . $path . "/";
- $fileList = $fileList . $soundPath . urlencode($file->getClientFileName()) . ", ";
+ case 'audio/mpeg':
+ $soundPath = '/assets/sound/blog/'.$path.'/';
+ $fileList = $fileList.$soundPath.urlencode($file->getClientFileName()).', ';
FileUploader::uploadFile(
- "../public/assets/sound/blog/" . $path . "/",
+ '../public/assets/sound/blog/'.$path.'/',
$file
);
break;
case 'application/pdf':
case 'text/plain':
case 'text/rtf':
- $docPath = "/assets/docs/blog/" . $path . "/";
- $fileList = $fileList . $docPath . urlencode($file->getClientFileName()) . ", ";
+ $docPath = '/assets/docs/blog/'.$path.'/';
+ $fileList = $fileList.$docPath.urlencode($file->getClientFileName()).', ';
FileUploader::uploadFile(
- "../public/assets/docs/blog/" . $path . "/",
+ '../public/assets/docs/blog/'.$path.'/',
$file
);
break;
@@ -117,49 +117,49 @@ class Book
$page_feature = $imageList;
$page_files = $fileList;
} else {
- //if no files, just reset string from page object
- $page_feature = $page["feature"];
- $page_files = $page["files"];
+ // if no files, just reset string from page object
+ $page_feature = $page['feature'];
+ $page_files = $page['files'];
}
- if ($task == "delete") {
- $deleted = "true";
- $body["menu"] = "false";
- $body["published"] = "false";
- $body["featured"] = "false";
+ if ($task == 'delete') {
+ $deleted = 'true';
+ $body['menu'] = 'false';
+ $body['published'] = 'false';
+ $body['featured'] = 'false';
} else {
- $deleted = isset($page["deleted"]) ? $page["deleted"] : "false";
+ $deleted = isset($page['deleted']) ? $page['deleted'] : 'false';
}
$created =
- $task != "create"
- ? new \Moment\Moment($page["rawCreated"])
+ $task != 'create'
+ ? new \Moment\Moment($page['rawCreated'])
: new \Moment\Moment();
$updated = new \Moment\Moment();
- //grab current index from settings and update
- $id = $task != "create" ? $body["id"] : Settings::getCurrentIndex();
- $uuid = $task != "create" ? $body["uuid"] : StringTools::createUUID();
+ // grab current index from settings and update
+ $id = $task != 'create' ? $body['id'] : Settings::getCurrentIndex();
+ $uuid = $task != 'create' ? $body['uuid'] : StringTools::createUUID();
// now that variables are done, set to body object and then convert to markdown to save
- $body["id"] = $id;
- $body["uuid"] = $uuid;
- $body["feature"] = $page_feature;
- $body["files"] = $page_files;
- $body["path"] = $path;
- $body["author"] = $member["handle"];
- $body["created"] = $created->format("Y-m-d\TH:i:sP");
- $body["updated"] = $updated->format("Y-m-d\TH:i:sP");
- $body["deleted"] = $deleted;
+ $body['id'] = $id;
+ $body['uuid'] = $uuid;
+ $body['feature'] = $page_feature;
+ $body['files'] = $page_files;
+ $body['path'] = $path;
+ $body['author'] = $member['handle'];
+ $body['created'] = $created->format("Y-m-d\TH:i:sP");
+ $body['updated'] = $updated->format("Y-m-d\TH:i:sP");
+ $body['deleted'] = $deleted;
$write = DocTools::objectToMD($body);
// if layout is index, change path to file
- if ($body["layout"] == "index") {
- $writePath = "../content/pages/start/index.md";
+ if ($body['layout'] == 'index') {
+ $writePath = '../content/pages/start/index.md';
} else {
- $writePath = "../content/pages/" . $path . "/" . $body["slug"] . ".md";
+ $writePath = '../content/pages/'.$path.'/'.$body['slug'].'.md';
}
$status = DocTools::writePages($task, $path, $writePath, $write);
@@ -167,45 +167,45 @@ class Book
if ($status) {
$config = new Settings();
$settings = $config->getSettings();
- $message = "";
+ $message = '';
if (
- $settings["global"]["renderOnSave"] == "true" &&
- $settings["global"]["dynamicRender"] == "false"
+ $settings['global']['renderOnSave'] == 'true' &&
+ $settings['global']['dynamicRender'] == 'false'
) {
$render = new Render();
$render->renderTags();
$render->renderArchive();
$render->renderPages();
- $message = "Filed edited and rendered. NOICE.";
+ $message = 'Filed edited and rendered. NOICE.';
} else {
- $message = "File edited. Nice work";
+ $message = 'File edited. Nice work';
}
$response = [
- "message" => $message,
- "type" => $task == "write" ? "postUpdated" : "postAdded",
- "id" => $uuid,
+ 'message' => $message,
+ 'type' => $task == 'write' ? 'postUpdated' : 'postAdded',
+ 'id' => $uuid,
];
- //TODO: When form submission is successful, make new form token
- //Session token doesn't reset on the front end, so turning this off for now
- //$form_token = md5(uniqid(microtime(), true));
- //Session::set("form_token", $form_token);
+ // TODO: When form submission is successful, make new form token
+ // Session token doesn't reset on the front end, so turning this off for now
+ // $form_token = md5(uniqid(microtime(), true));
+ // Session::set("form_token", $form_token);
- //once saved, update menu
- $body["path"] = $path;
+ // once saved, update menu
+ $body['path'] = $path;
Settings::updateMenu($body);
Settings::updateTags();
- //if new page added, update current index in Settings file
- if ($task == "create") {
+ // if new page added, update current index in Settings file
+ if ($task == 'create') {
Settings::updateIndex();
}
} else {
$response = [
- "message" => "Uh oh. File save problem. Don't panic",
- "type" => "postError",
- "id" => $uuid,
+ 'message' => "Uh oh. File save problem. Don't panic",
+ 'type' => 'postError',
+ 'id' => $uuid,
];
}
@@ -217,22 +217,22 @@ class Book
$content = $this->getContents();
$published = filter($content, function ($item) {
- return $item["published"] == true && $item["deleted"] == false;
+ return $item['published'] == true && $item['deleted'] == false;
});
$deleted = filter($content, function ($item) {
- return $item["deleted"] == true;
+ return $item['deleted'] == true;
});
- //$all = $content;
+ // $all = $content;
$all = filter($content, function ($item) {
- return $item["deleted"] == false;
+ return $item['deleted'] == false;
});
- $filter = isset($sort) ? $sort : "all";
+ $filter = isset($sort) ? $sort : 'all';
switch ($filter) {
- case "published":
+ case 'published':
$filtered = $published;
break;
- case "deleted":
+ case 'deleted':
$filtered = $deleted;
break;
default:
@@ -251,11 +251,11 @@ class Book
if ($range != 0) {
$range = $range + 1;
}
- for ($i = 0; $i <= $limit; $i++) {
+ for ($i = 0; $i <= $limit; ++$i) {
if (isset($filtered[$i + $range])) {
array_push($folder, $filtered[$i + $range]);
} else {
- //chill out
+ // chill out
}
}
}
@@ -271,26 +271,28 @@ class Book
}
return [
- "pages" => $folder,
- "numOfPages" => $numOfPages,
- "entryCount" => count($filtered),
- "paginate" => [
- "sort" => $sort,
- "nextPage" => $next,
- "prevPage" => $prev,
+ 'pages' => $folder,
+ 'numOfPages' => $numOfPages,
+ 'entryCount' => count($filtered),
+ 'paginate' => [
+ 'sort' => $sort,
+ 'nextPage' => $next,
+ 'prevPage' => $prev,
],
- "stats" => [
- "all" => count($all),
- "published" => count($published),
- "deleted" => count($deleted),
+ 'stats' => [
+ 'all' => count($all),
+ 'published' => count($published),
+ 'deleted' => count($deleted),
],
];
}
+
public function getContents()
{
- //test new contents data class
- //$new = (new Contents("../content/pages"))->getAll();
- $contents = (new Contents("../content/pages"))->getAll();
+ // test new contents data class
+ // $new = (new Contents("../content/pages"))->getAll();
+ $contents = (new Contents('../content/pages'))->getAll();
+
return $contents;
}
}
diff --git a/brain/utility/FileUploader.php b/brain/utility/FileUploader.php
index 52421ba..c40b2a5 100644
--- a/brain/utility/FileUploader.php
+++ b/brain/utility/FileUploader.php
@@ -1,10 +1,7 @@
getClientFileName(), $directory);
- //$extension = pathinfo($file->getClientFilename(), PATHINFO_EXTENSION);
+ // $upload = move_uploaded_file($file->getClientFileName(), $directory);
+ // $extension = pathinfo($file->getClientFilename(), PATHINFO_EXTENSION);
- // see http://php.net/manual/en/function.random-bytes.php
- //$basename = bin2hex(random_bytes(8));
- //$filename = sprintf("%s.%0.8s", $basename, $extension);
+ // see http://php.net/manual/en/function.random-bytes.php
+ // $basename = bin2hex(random_bytes(8));
+ // $filename = sprintf("%s.%0.8s", $basename, $extension);
- //echo "**FILE** " . $file->getClientFileName();
+ // echo "**FILE** " . $file->getClientFileName();
- $file->moveTo($directory . "/" . urlencode($file->getClientFileName()));
+ $file->moveTo($directory.'/'.urlencode($file->getClientFileName()));
} catch (RuntimeException $e) {
- echo "ERROR " . $e->getMessage();
+ echo 'ERROR '.$e->getMessage();
- //echo "failed to upload image: " . $e->getMessage();
- //throw new Error("Failed to upload image file");
+ // echo "failed to upload image: " . $e->getMessage();
+ // throw new Error("Failed to upload image file");
}
}
}
diff --git a/brain/views/dash/navigation.twig b/brain/views/dash/navigation.twig
index e2d2e2c..33e96d3 100644
--- a/brain/views/dash/navigation.twig
+++ b/brain/views/dash/navigation.twig
@@ -39,5 +39,5 @@
{% endblock %}
{% block javascripts %}
-
+
{% endblock %}
\ No newline at end of file
diff --git a/public/assets/css/dash.css b/public/assets/css/dash.css
index ff1c15e..5c567e0 100644
--- a/public/assets/css/dash.css
+++ b/public/assets/css/dash.css
@@ -1954,21 +1954,8 @@ svg.icons {
-moz-animation: spin 2s linear infinite;
animation: spin 2s linear infinite;
}
-@-moz-keyframes spin {
- 100% {
- -moz-transform: rotate(360deg);
- }
-}
-@-webkit-keyframes spin {
- 100% {
- -webkit-transform: rotate(360deg);
- }
-}
@keyframes spin {
- 100% {
- -webkit-transform: rotate(360deg);
- transform: rotate(360deg);
- }
+ transform: rotate(360deg);
}
#notifications #notifyMessage .notify-icon {
background: #32302f;
diff --git a/public/assets/scripts/Start.js b/public/assets/scripts/Start.js
index beb0441..cda5f3b 100644
--- a/public/assets/scripts/Start.js
+++ b/public/assets/scripts/Start.js
@@ -1,8531 +1,2 @@
-// modules are defined as an array
-// [ module function, map of requires ]
-//
-// map of requires is short require name -> numeric require
-//
-// anything defined in a previous bundle is accessed via the
-// orig method which is the require for previous bundles
-
-(function (modules, entry, mainEntry, parcelRequireName, globalName) {
- /* eslint-disable no-undef */
- var globalObject =
- typeof globalThis !== 'undefined'
- ? globalThis
- : typeof self !== 'undefined'
- ? self
- : typeof window !== 'undefined'
- ? window
- : typeof global !== 'undefined'
- ? global
- : {};
- /* eslint-enable no-undef */
-
- // Save the require from previous bundle to this closure if any
- var previousRequire =
- typeof globalObject[parcelRequireName] === 'function' &&
- globalObject[parcelRequireName];
-
- var cache = previousRequire.cache || {};
- // Do not use `require` to prevent Webpack from trying to bundle this call
- var nodeRequire =
- typeof module !== 'undefined' &&
- typeof module.require === 'function' &&
- module.require.bind(module);
-
- function newRequire(name, jumped) {
- if (!cache[name]) {
- if (!modules[name]) {
- // if we cannot find the module within our internal map or
- // cache jump to the current global require ie. the last bundle
- // that was added to the page.
- var currentRequire =
- typeof globalObject[parcelRequireName] === 'function' &&
- globalObject[parcelRequireName];
- if (!jumped && currentRequire) {
- return currentRequire(name, true);
- }
-
- // If there are other bundles on this page the require from the
- // previous one is saved to 'previousRequire'. Repeat this as
- // many times as there are bundles until the module is found or
- // we exhaust the require chain.
- if (previousRequire) {
- return previousRequire(name, true);
- }
-
- // Try the node require function if it exists.
- if (nodeRequire && typeof name === 'string') {
- return nodeRequire(name);
- }
-
- var err = new Error("Cannot find module '" + name + "'");
- err.code = 'MODULE_NOT_FOUND';
- throw err;
- }
-
- localRequire.resolve = resolve;
- localRequire.cache = {};
-
- var module = (cache[name] = new newRequire.Module(name));
-
- modules[name][0].call(
- module.exports,
- localRequire,
- module,
- module.exports,
- this
- );
- }
-
- return cache[name].exports;
-
- function localRequire(x) {
- return newRequire(localRequire.resolve(x));
- }
-
- function resolve(x) {
- return modules[name][1][x] || x;
- }
- }
-
- function Module(moduleName) {
- this.id = moduleName;
- this.bundle = newRequire;
- this.exports = {};
- }
-
- newRequire.isParcelRequire = true;
- newRequire.Module = Module;
- newRequire.modules = modules;
- newRequire.cache = cache;
- newRequire.parent = previousRequire;
- newRequire.register = function (id, exports) {
- modules[id] = [
- function (require, module) {
- module.exports = exports;
- },
- {},
- ];
- };
-
- Object.defineProperty(newRequire, 'root', {
- get: function () {
- return globalObject[parcelRequireName];
- },
- });
-
- globalObject[parcelRequireName] = newRequire;
-
- for (var i = 0; i < entry.length; i++) {
- newRequire(entry[i]);
- }
-
- if (mainEntry) {
- // Expose entry point to Node, AMD or browser globals
- // Based on https://github.com/ForbesLindesay/umd/blob/master/template.js
- var mainExports = newRequire(mainEntry);
-
- // CommonJS
- if (typeof exports === 'object' && typeof module !== 'undefined') {
- module.exports = mainExports;
-
- // RequireJS
- } else if (typeof define === 'function' && define.amd) {
- define(function () {
- return mainExports;
- });
-
- //