diff --git a/.gitignore b/.gitignore
index f9c3f4e..3321148 100644
--- a/.gitignore
+++ b/.gitignore
@@ -12,7 +12,7 @@ public/*
public/assets/*
!public/assets/css
public/assets/css/*
-!public/assets/css/dash.css
+!public/assets/css/dash
!public/assets/scripts
public/assets/scripts/*
!public/assets/scripts/Start.js
diff --git a/.php-cs-fixer.php b/.php-cs-fixer.php
index adf5ae8..cd8588c 100644
--- a/.php-cs-fixer.php
+++ b/.php-cs-fixer.php
@@ -1,6 +1,8 @@
setRiskyAllowed(true)
->setRules([
'@PSR12' => true,
'array_indentation' => true,
@@ -20,7 +22,7 @@ return (new PhpCsFixer\Config())
'multiline_whitespace_before_semicolons' => [
'strategy' => 'no_multi_line',
],
- 'single_quote' => true,
+ 'single_quote' => false,
'binary_operator_spaces' => [
'default' => 'single_space',
@@ -50,7 +52,6 @@ return (new PhpCsFixer\Config())
'extra',
'parenthesis_brace_block',
'throw',
-
]
],
'no_multiline_whitespace_around_double_arrow' => true,
@@ -68,5 +69,6 @@ return (new PhpCsFixer\Config())
'ordered_imports' => [
'sort_algorithm' => 'none',
],
+ //Other rules here...
])
->setLineEnding("\n");
diff --git a/.stylelintrc b/.stylelintrc
index 4448120..0a08a15 100644
--- a/.stylelintrc
+++ b/.stylelintrc
@@ -1,6 +1,3 @@
{
- "extends": [
- "stylelint-config-standard-scss",
- "stylelint-config-prettier-scss"
- ]
+ "extends": ["stylelint-config-standard"]
}
diff --git a/README.md b/README.md
index 89aadd7..b554f92 100644
--- a/README.md
+++ b/README.md
@@ -1,13 +1,9 @@
-![This is Fipamo](https://playvicio.us/base-assets/images/fipamo-brand.png)
-
# Fipamo means to save
The Fipamo project was born from a need for a simple, easy to use no data blog platform that doesn't require much effort to set up and maintain. Fipamo uses Markdown to handle posts and renders them to flat html so you can serve them from anywhere. No complicated set ups. No long list of dependencies. Just set up and go.
Because nobody has time for all that.
-## Check the (WIP) Docs to get you started.
+## Check the (WIP) Docs to get you started.
-[Getting Started](https://code.playvicio.us/Are0h/Fipamo/wiki/00---Start)
-[Install](https://code.playvicio.us/Are0h/Fipamo/wiki/01---Install)
-[Using Fipamo](https://code.playvicio.us/Are0h/Fipamo/wiki/02-Usage)
+[Getting Started](https://koodu.ubiqueros.com/are0h/Fipamo/wiki/00---Start)
diff --git a/brain/api/v1/FilesAPI.php b/brain/api/v1/FilesAPI.php
new file mode 100644
index 0000000..01962a0
--- /dev/null
+++ b/brain/api/v1/FilesAPI.php
@@ -0,0 +1,73 @@
+getUploadedFiles(); //grab uploaded files
+ $options = $request->getParsedBody();
+ $file = $upload['upload_files'][0]; //front end sends one by one for progress tracking, so grab first
+ $type = $file->getClientMediaType();
+ $filesPath = '';
+ $path = date('Y') . '/' . date('m');
+ $response = [];
+
+ switch ($type) {
+ case 'image/jpeg':
+ case 'image/png':
+ case 'image/gif':
+ case 'image/svg':
+ if (isset($options["source"])) {
+ if ($options["source"] == "avatar-upload") {
+ $filesPath = '/assets/images/user/' . $path . '/';
+ Member::updateData(
+ 'avi',
+ $filesPath . $file->getClientFileName()
+ );
+ } else {
+ $filesPath = '/assets/images/user/' . $path . '/';
+ Settings::updateGlobalData(
+ 'background',
+ $filesPath . '/' . $file->getClientFileName()
+ );
+ }
+ } else {
+ $filesPath = '/assets/images/blog/' . $path . '/';
+ }
+
+ break;
+ case 'video/mp4':
+ $filesPath = '/assets/video/blog/' . $path . '/';
+ break;
+ case 'audio/mpeg':
+ $filesPath = '/assets/sound/blog/' . $path . '/';
+ break;
+ case 'application/pdf':
+ case 'text/plain':
+ case 'text/rtf':
+ $filesPath = '/assets/docs/blog/' . $path . '/';
+ break;
+ }
+
+ FileUploader::uploadFile('../public' . $filesPath, $file);
+
+ $response = [
+ 'message' => "File Uploaded. Great!",
+ "filePath" => $filesPath . urlencode($file->getClientFileName()),
+ "fileName" => urlencode($file->getClientFileName()),
+ 'type' => $type,
+ ];
+
+ return $response;
+ }
+}
diff --git a/brain/api/v1/PagesAPI.php b/brain/api/v1/PagesAPI.php
index d979cf9..753418e 100644
--- a/brain/api/v1/PagesAPI.php
+++ b/brain/api/v1/PagesAPI.php
@@ -111,7 +111,7 @@ class PagesAPI
case 'delete':
case 'create':
case 'write':
- $body = $request->getParsedBody();
+ $body = json_decode(file_get_contents("php://input"), true);
$passed = true;
if (!isset($body['form_token'])) {
$result = [
@@ -120,7 +120,6 @@ class PagesAPI
];
} else {
if ($body['form_token'] == Session::get('form_token')) {
- //TODO: Verify form fields
$keys = [
'id',
'uuid',
@@ -135,12 +134,15 @@ class PagesAPI
'featured',
'published',
'form_token',
- 'feature_image',
+ 'imageList',
+ "fileList",
+ "remote"
];
foreach ($body as $key => $item) {
if (!in_array($key, $keys)) {
//found unnecessary key, so reject submission
+ var_dump($key);
$passed = false;
}
}
diff --git a/brain/controller/APIControl.php b/brain/controller/APIControl.php
index dd60058..2256f61 100644
--- a/brain/controller/APIControl.php
+++ b/brain/controller/APIControl.php
@@ -6,6 +6,7 @@ use Psr\Http\Message\ResponseInterface;
use Psr\Http\Message\ServerRequestInterface;
use brain\api\v1\AuthAPI;
use brain\api\v1\PagesAPI;
+use brain\api\v1\FilesAPI;
use brain\api\v1\SettingsAPI;
use brain\api\v1\InitAPI;
use brain\api\v1\MailerAPI;
@@ -22,7 +23,7 @@ class APIControl
$filename = '';
switch (isset($args['third']) ? $args['third'] : 'none') {
case 'status':
- $result = AuthAPI::status();
+ $result = AuthAPI::status();
break;
case 'page':
@@ -188,6 +189,24 @@ class APIControl
];
}
+ break;
+ case "files":
+ $token = $request->getHeader('fipamo-access-token');
+ if (isset($token[0])) {
+ if (Session::verifyToken($token[0])) {
+ $result = FilesAPI::uploadFiles($request, $args);
+ } else {
+ $result = [
+ 'message' => 'Invalid token, API access denied, homie',
+ 'type' => 'API_ERROR',
+ ];
+ }
+ } else {
+ $result = [
+ 'message' => 'No token, API access denied, homie',
+ 'type' => 'API_ERROR',
+ ];
+ }
break;
case 'settings':
if (isset($body)) {
@@ -225,7 +244,6 @@ class APIControl
];
break;
}
-
$response->getBody()->write(json_encode($result));
return $response->withHeader('Content-Type', 'application/json');
}
diff --git a/brain/controller/DashControl.php b/brain/controller/DashControl.php
index e507a89..13b0921 100644
--- a/brain/controller/DashControl.php
+++ b/brain/controller/DashControl.php
@@ -7,6 +7,8 @@ use brain\data\Session;
use brain\data\Settings;
use brain\data\Themes;
use brain\utility\Setup;
+use brain\utility\Sorting;
+use Carbon\Carbon;
use Psr\Http\Message\ResponseInterface;
use Psr\Http\Message\ServerRequestInterface;
use Slim\Views\Twig;
@@ -31,9 +33,9 @@ class DashControl
$template = 'dash/settings.twig';
$member = Session::get('member');
$form_token = Session::get('form_token');
- $updated = new \Moment\Moment($settings['global']['last_backup']);
+ $updated = new Carbon($settings['global']['last_backup']);
$pageOptions = [
- 'title' => 'Dash Settings',
+ 'title' => 'Settings',
'private' => $settings['global']['private'],
'renderOnSave' => $settings['global']['renderOnSave'],
'background' => $settings['global']['background'],
@@ -69,7 +71,7 @@ class DashControl
$settings = $config->getSettings();
$template = 'dash/navigation.twig';
$pageOptions = [
- 'title' => 'Edit Dash Navigation',
+ 'title' => 'Edit Menu',
'status' => Session::active(),
'menu' => $settings['menu'],
];
@@ -110,6 +112,9 @@ class DashControl
case 'edit':
$page = (new Book())->findPageById($uuid);
$views = [];
+ if (!isset($page['layout'])) {
+ $page['layout'] = "page";
+ }
if (str_contains($page['layout'], 'index')) {
$views = (new Themes())->getCustomIndex();
} else {
@@ -136,7 +141,7 @@ class DashControl
}
$pageOptions = [
- 'title' => 'Fipamo | Edit Page',
+ 'title' => $page['title'],
'page' => $page,
'mode' => $mode,
'token' => Session::get('form_token'),
@@ -150,22 +155,21 @@ class DashControl
$config = new Settings();
$settings = $config->getSettings();
$loader = new \Twig\Loader\FilesystemLoader(
- '../content/themes'
+ '../content/themes/' . $settings['global']['theme'] .
+ '/'
);
$display = new \Twig\Environment($loader, []);
$book = new Book();
$page = $book->findPageById($uuid);
$pageOptions = Sorting::page($page);
- $preview = $settings['global']['theme'] .
- '/' .
- $page['layout'] .
+ $preview = $page['layout'] .
'.twig';
$html = $display->render($preview, $pageOptions);
$response->getBody()->write($html);
return $response;
- break;
+ break;
default:
$pageOptions = [
'title' => 'Fipamo | Create Page',
@@ -184,7 +188,7 @@ class DashControl
Session::kill();
header('Location: /dashboard');
exit();
- break;
+ break;
case 'reset-password':
$template = 'dash/reset-password.twig';
$pageOptions = [
@@ -195,7 +199,7 @@ class DashControl
$template = 'dash/start.twig';
if (Session::active()) {
$pageOptions = [
- 'title' => 'Welcome Back',
+ 'title' => 'Start',
'status' => Session::active(),
'data' => (new Book())->getPages(1, 4),
];
diff --git a/brain/controller/RouteControl.php b/brain/controller/RouteControl.php
index 2fbc068..f3eb19e 100644
--- a/brain/controller/RouteControl.php
+++ b/brain/controller/RouteControl.php
@@ -7,6 +7,7 @@ use Psr\Http\Message\ServerRequestInterface;
class RouteControl
{
+ //TODO: Add additional HTTP Methods to better organize API control paths
public function get(
ServerRequestInterface $request,
ResponseInterface $response,
@@ -32,14 +33,15 @@ class RouteControl
): ResponseInterface {
switch (isset($args['first']) ? $args['first'] : 'index') {
case 'api':
- //$result = APIControl::post($request, $response, $args);
- //var_dump($result);
return APIControl::post($request, $response, $args);
break;
default:
- //echo "YES";
- //return IndexControl::start($request, $response, $args);
- break;
+ $result = [
+ 'message' => "Nothing matches this route. That's unfortunate",
+ 'type' => 'TASK_NONE',
+ ];
+ $response->getBody()->write(json_encode($result));
+ return $response->withHeader('Content-Type', 'application/json');
}
}
}
diff --git a/brain/data/Book.php b/brain/data/Book.php
index 71d8a26..efb0575 100644
--- a/brain/data/Book.php
+++ b/brain/data/Book.php
@@ -5,7 +5,6 @@ namespace brain\data;
use Carbon\Carbon;
use brain\utility\DocTools;
use brain\utility\StringTools;
-use brain\utility\FileUploader;
use function _\find;
use function _\filter;
@@ -39,13 +38,8 @@ 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"]]);
- $body = $request->getParsedBody();
- } else {
- $body = $request->getParsedBody();
- }
+ $body = json_decode(file_get_contents("php://input"), true);
+ //$body = find($content, ["uuid" => $parsed["id"]]);
$page = find($content, ['uuid' => $body['uuid']]);
$files = $request->getUploadedFiles();
@@ -63,65 +57,6 @@ class Book
$page_feature = '';
$page_files = '';
- if (isset($files['page_files'])) {
- $imageList = '';
- $fileList = '';
- //var_dump($files['page_files']);
- foreach ($files['page_files'] as $file) {
- $type = $file->getClientMediaType();
- //var_dump($type);
- switch ($type) {
- case 'image/jpeg':
- case 'image/png':
- case 'image/gif':
- case 'image/svg':
- $imagesPath = '/assets/images/blog/' . $path . '/';
- $imageList = $imageList . $imagesPath . urlencode($file->getClientFileName()) . ', ';
-
- FileUploader::uploadFile(
- '../public/assets/images/blog/' . $path . '/',
- $file
- );
- break;
- case 'video/mp4':
- $videosPath = '/assets/video/blog/' . $path . '/';
- $imageList = $imageList . $videosPath . urlencode($file->getClientFileName()) . ', ';
-
- FileUploader::uploadFile(
- '../public/assets/video/blog/' . $path . '/',
- $file
- );
- break;
- case 'audio/mpeg':
- $soundPath = '/assets/sound/blog/' . $path . '/';
- $fileList = $fileList . $soundPath . urlencode($file->getClientFileName()) . ', ';
-
- FileUploader::uploadFile(
- '../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()) . ', ';
-
- FileUploader::uploadFile(
- '../public/assets/docs/blog/' . $path . '/',
- $file
- );
- break;
- }
- }
- $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 ($task == 'delete') {
$deleted = 'true';
$body['menu'] = 'false';
@@ -139,10 +74,10 @@ class Book
$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['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");
diff --git a/brain/data/Member.php b/brain/data/Member.php
index 66ebc64..31e4cd8 100644
--- a/brain/data/Member.php
+++ b/brain/data/Member.php
@@ -2,6 +2,7 @@
namespace brain\data;
+use Carbon\Carbon;
use brain\utility\DocTools;
use function _\find;
@@ -38,7 +39,7 @@ class Member
}
$found[$key] = $data;
//record time updated
- $updated = new \Moment\Moment();
+ $updated = Carbon::now();
$found['updated'] = $updated->format("Y-m-d\TH:i:sP");
$newFolks = [];
array_push($newFolks, $found);
diff --git a/brain/data/Render.php b/brain/data/Render.php
index d0be3a6..9ed923b 100644
--- a/brain/data/Render.php
+++ b/brain/data/Render.php
@@ -107,7 +107,7 @@ class Render
}
$template = $layout . '.twig';
- if (str_contains($page['layout'], 'index')) {
+ if (str_contains($layout, 'index')) {
$location = '../public/index.html';
$dir = null;
} else {
diff --git a/brain/data/Settings.php b/brain/data/Settings.php
index 7f050de..4b81b99 100644
--- a/brain/data/Settings.php
+++ b/brain/data/Settings.php
@@ -4,6 +4,7 @@ namespace brain\data;
use brain\utility\DocTools;
use brain\utility\Sorting;
+use Carbon\Carbon;
use function _\find;
use function _\pull;
@@ -67,8 +68,8 @@ class Settings
$page['deleted']
? ($page['deleted'] = 'true')
: ($page['deleted'] = 'false');
- $updated = new \Moment\Moment();
- $created = new \Moment\Moment($page['rawCreated']);
+ $updated = Carbon::now();
+ $created = new Carbon($page['rawCreated']);
$page['created'] = $created->format("Y-m-d\TH:i:sP");
$page['updated'] = $updated->format("Y-m-d\TH:i:sP");
diff --git a/brain/utility/DocTools.php b/brain/utility/DocTools.php
index 4c71f45..1dd9dfd 100644
--- a/brain/utility/DocTools.php
+++ b/brain/utility/DocTools.php
@@ -99,10 +99,10 @@ class DocTools
"'" .
"\n" .
'feature: ' .
- $object['feature'] .
+ $object['imageList'] .
"\n" .
'files: ' .
- $object['files'] .
+ $object['fileList'] .
"\n" .
'path: ' .
$object['path'] .
diff --git a/brain/utility/Maintenance.php b/brain/utility/Maintenance.php
index eece1a2..764a274 100644
--- a/brain/utility/Maintenance.php
+++ b/brain/utility/Maintenance.php
@@ -3,6 +3,7 @@
namespace brain\utility;
use brain\data\Settings;
+use Carbon\Carbon;
class Maintenance
{
@@ -90,7 +91,7 @@ class Maintenance
$zip->close();
//update settings file with latest back up date
- $updated = new \Moment\Moment();
+ $updated = Carbon::now();
Settings::updateGlobalData(
'last_backup',
$updated->format("Y-m-d\TH:i:sP")
diff --git a/brain/utility/Setup.php b/brain/utility/Setup.php
index 80cd566..5d8c544 100644
--- a/brain/utility/Setup.php
+++ b/brain/utility/Setup.php
@@ -2,6 +2,8 @@
namespace brain\utility;
+use Carbon\Carbon;
+
use function _\find;
class SetUp
@@ -33,7 +35,7 @@ class SetUp
$pass = $body['new_member_pass'];
$title = $body['new_member_title'];
- $now = new \Moment\Moment();
+ $now = Carbon::now();
//setup folks config
$hash = password_hash($pass, PASSWORD_DEFAULT);
$newFolks[0]['id'] = 0;
diff --git a/brain/utility/Sorting.php b/brain/utility/Sorting.php
index 8ca60a4..aa38c14 100644
--- a/brain/utility/Sorting.php
+++ b/brain/utility/Sorting.php
@@ -2,12 +2,13 @@
namespace brain\utility;
-use function _\filter;
-use function _\find;
use brain\data\Book;
use brain\data\Settings;
use Mni\FrontYAML\Parser;
+use function _\filter;
+use function _\find;
+
class Sorting
{
private static $p_tags = [];
@@ -16,6 +17,7 @@ class Sorting
public function __construct()
{
}
+
public static function tags()
{
$pages = (new Book('../content/pages'))->getContents();
@@ -36,6 +38,7 @@ class Sorting
return self::$p_tags;
}
+
private static function tagPages($tag, $pages)
{
$tagged = [];
@@ -52,6 +55,7 @@ class Sorting
return $tagged;
}
+
public static function archive()
{
$pages = (new Book('../content/pages'))->getContents();
@@ -64,10 +68,13 @@ class Sorting
if (!find($years, ['year' => trim($date[0])])) {
$findPages = filter($pages, ['createdYear' => trim($date[0])]);
// var_dump($findPages);
- array_push($years, [
- 'year' => trim($date[0]),
- 'count' => count($findPages),
- ]);
+ array_push(
+ $years,
+ [
+ 'year' => trim($date[0]),
+ 'count' => count($findPages),
+ ]
+ );
}
}
foreach ($years as $year) {
@@ -77,12 +84,15 @@ class Sorting
foreach ($filtered as $obj) {
$month = date('m', date($obj['rawCreated']));
if (!find($sorted, ['month' => $month])) {
- $perMonth = filter($pages, [
- 'path' => $year['year'] . '/' . $month,
- 'deleted' => false,
- 'published' => true,
- 'layout' => 'page',
- ]);
+ $perMonth = filter(
+ $pages,
+ [
+ 'path' => $year['year'] . '/' . $month,
+ 'deleted' => false,
+ 'published' => true,
+ 'layout' => 'page',
+ ]
+ );
array_push($sorted, [
'month' => $month,
'full_month' => date('F', date($obj['rawCreated'])),
@@ -99,6 +109,7 @@ class Sorting
return self::$p_archive;
}
+
public static function page($page)
{
$config = new Settings();
diff --git a/brain/views/dash/_frame.twig b/brain/views/dash/_frame.twig
index 4f96798..7903787 100644
--- a/brain/views/dash/_frame.twig
+++ b/brain/views/dash/_frame.twig
@@ -11,56 +11,38 @@
{% block stylesheets %}{% endblock %}