Compare commits
137 Commits
Author | SHA1 | Date |
---|---|---|
Ro | 62e2dea287 | 2 years ago |
Ro | f824b53f2a | 2 years ago |
Ro | 8461d88dd6 | 2 years ago |
Ro | a9c88f1430 | 2 years ago |
Ro | fa4b252d9c | 2 years ago |
Ro | 181225329a | 2 years ago |
Ro | 4876c1336e | 2 years ago |
Ro | 8ce253418d | 2 years ago |
Ro | f1850ce7f7 | 2 years ago |
Ro | 8622ba5941 | 2 years ago |
Ro | e7cd52bd12 | 2 years ago |
Ro | f9190c2a41 | 2 years ago |
Ro | 302362a478 | 2 years ago |
Ro | 8885ae4c63 | 2 years ago |
Ro | 405be1a6ed | 2 years ago |
Ro | 3f9506ac6b | 2 years ago |
Ro | e7fd91c152 | 2 years ago |
Ro | 5adf196783 | 2 years ago |
Ro | 2ce86fad2e | 2 years ago |
Ro | bfb0873f5f | 2 years ago |
Ro | 97278e3a90 | 2 years ago |
Ro | 78bfe4596b | 2 years ago |
Ro | 1b89d1d072 | 2 years ago |
Ro | fcca7357bc | 2 years ago |
Ro | 07b422a9c3 | 2 years ago |
Ro | ec1dc49ba1 | 2 years ago |
Ro | 61ae73a9e5 | 2 years ago |
Ro | 859b75e9f3 | 2 years ago |
Ro | a14d4a0a08 | 2 years ago |
Ro | 7890715ea6 | 2 years ago |
Ro | 77eb8dd1a8 | 2 years ago |
Ro | e431f1afa4 | 2 years ago |
Ro | 254a7f1c38 | 2 years ago |
Ro | c2b3b234fa | 2 years ago |
Ro | b092645733 | 2 years ago |
Ro | fce378d437 | 2 years ago |
Ro | 73e4243231 | 2 years ago |
Ro | 3260e3b76b | 2 years ago |
Are0h | 69fc689d38 | 3 years ago |
Are0h | a1c0d86580 | 3 years ago |
Are0h | 197fb005de | 3 years ago |
Are0h | 00d41a3664 | 3 years ago |
Are0h | 3fa3a9e0e6 | 3 years ago |
Are0h | 8734baf85e | 3 years ago |
Are0h | a31dff94cb | 3 years ago |
Are0h | 63eaba08e2 | 3 years ago |
Are0h | d9c9f7744e | 3 years ago |
Are0h | b2c7dae322 | 3 years ago |
Are0h | 2501a19685 | 3 years ago |
Are0h | b8b763637f | 3 years ago |
Are0h | 61b9acb280 | 3 years ago |
Are0h | c546aa7b63 | 3 years ago |
Are0h | aa3301fb66 | 3 years ago |
Are0h | 9baaed6d50 | 3 years ago |
Are0h | 6f2a8cfb4b | 3 years ago |
Are0h | 2e30d6eb26 | 3 years ago |
Are0h | 7393e4572c | 3 years ago |
are0h | 614c9859b1 | 3 years ago |
are0h | 0ee4083949 | 3 years ago |
are0h | d92944b2ec | 3 years ago |
are0h | a841063ddb | 3 years ago |
are0h | c004452c55 | 3 years ago |
are0h | 692926c816 | 3 years ago |
are0h | 7cefc12692 | 3 years ago |
are0h | b230f3f15d | 3 years ago |
are0h | d7c5fb7a70 | 3 years ago |
are0h | d98bccdd1f | 3 years ago |
are0h | 382c314af0 | 3 years ago |
Ro | 6279ad4730 | 3 years ago |
Ro | 2b7db3cc88 | 3 years ago |
Ro | a70c98afa0 | 3 years ago |
Ro | 8ad3fa38c5 | 3 years ago |
Ro | 1351b98ee4 | 3 years ago |
Ro | 2210e39aee | 3 years ago |
Ro | 523b611ac5 | 3 years ago |
Ro | fe74fd6e07 | 3 years ago |
Ro | 2ed2cd3803 | 3 years ago |
Ro | f24a6b5099 | 3 years ago |
Ro | 3c52bca8ba | 3 years ago |
Ro | 2d5de69f1c | 3 years ago |
Ro | 8f9021bb7d | 3 years ago |
Ro | 53864becc1 | 3 years ago |
Ro | 601fd6b1ab | 3 years ago |
Ro | b69559541a | 3 years ago |
Ro | f6aac33ae4 | 3 years ago |
Ro | 8684c8b1ac | 3 years ago |
Ro | c98a75f931 | 3 years ago |
Ro | c15b6cdc5b | 3 years ago |
Ro | 257d2a0623 | 3 years ago |
Ro | 59e0f37b3e | 3 years ago |
Ro | 7cabb1d1f0 | 3 years ago |
Ro | f1a8ef67bc | 3 years ago |
Ro | 10081c4323 | 3 years ago |
Ro | 32a4f32202 | 3 years ago |
Ro | b70308d990 | 3 years ago |
Ro | 0e52528de0 | 3 years ago |
Ro | fdf2319783 | 3 years ago |
Ro | 6c053868a2 | 3 years ago |
Ro | 71dc41e950 | 3 years ago |
Ro | dc08f60098 | 3 years ago |
Ro | db385d938c | 3 years ago |
Ro | 8502c4f0e0 | 3 years ago |
Ro | 2fdd7f40f0 | 3 years ago |
Ro | de2aec58c9 | 3 years ago |
Ro | d2f02eea50 | 3 years ago |
Ro | 55b16a0acd | 3 years ago |
Ro | 39c6ff7f11 | 3 years ago |
Ro | dad43f4a19 | 3 years ago |
Ro | 7775c1d409 | 3 years ago |
Ro | 0742e06c45 | 3 years ago |
Ro | 682406515d | 3 years ago |
Ro | 1b66f5daf9 | 3 years ago |
Ro | c0c3b60fd5 | 3 years ago |
Ro | 4f4fee807c | 3 years ago |
Ro | 1c2ba579df | 3 years ago |
Ro | 03c629462b | 3 years ago |
Ro | f119bdc773 | 3 years ago |
Ro | e5873b92cf | 3 years ago |
Ro | 39775e624d | 3 years ago |
Ro | 4151891129 | 3 years ago |
Ro | 7e38b4edb8 | 3 years ago |
Ro | 3994e97829 | 3 years ago |
Ro | c867b6c508 | 3 years ago |
Ro | 49e53a9638 | 3 years ago |
Ro | a8355b2da4 | 3 years ago |
Ro | bbfe37597a | 3 years ago |
Ro | 4f4ee5dfc7 | 3 years ago |
Ro | cecead05a1 | 3 years ago |
Ro | e6cda301cf | 3 years ago |
Ro | 4796431076 | 3 years ago |
Ro | 35c780bba6 | 3 years ago |
Ro | e5cffd39d7 | 3 years ago |
Ro | 815ebf58f7 | 3 years ago |
Ro | d6f6f771ac | 3 years ago |
Ro | a475b64aca | 3 years ago |
Ro | 9fe8ce1e4c | 3 years ago |
Ro | 1bb13ce771 | 3 years ago |
@ -1 +1,13 @@
|
||||
{ "presets": ["env"] }
|
||||
{
|
||||
"presets": [],
|
||||
"plugins": [
|
||||
[
|
||||
"prismjs",
|
||||
{
|
||||
"languages": ["html", "markdown", "markup"],
|
||||
"theme": "okaidia",
|
||||
"css": false
|
||||
}
|
||||
]
|
||||
]
|
||||
}
|
||||
|
@ -1,70 +1,70 @@
|
||||
{
|
||||
"parserOptions": {
|
||||
"ecmaVersion": 7,
|
||||
"sourceType": "module",
|
||||
"ecmaFeatures": {}
|
||||
},
|
||||
"rules": {
|
||||
"constructor-super": 2,
|
||||
"for-direction": 2,
|
||||
"getter-return": 2,
|
||||
"no-case-declarations": 2,
|
||||
"no-class-assign": 2,
|
||||
"no-compare-neg-zero": 2,
|
||||
"no-cond-assign": 2,
|
||||
"no-console": 1,
|
||||
"no-const-assign": 2,
|
||||
"no-constant-condition": 2,
|
||||
"no-control-regex": 1,
|
||||
"no-debugger": 2,
|
||||
"no-delete-var": 2,
|
||||
"no-dupe-args": 2,
|
||||
"no-dupe-class-members": 2,
|
||||
"no-dupe-keys": 2,
|
||||
"no-duplicate-case": 2,
|
||||
"no-empty": 2,
|
||||
"no-empty-character-class": 2,
|
||||
"no-empty-pattern": 2,
|
||||
"no-ex-assign": 2,
|
||||
"no-extra-boolean-cast": 2,
|
||||
"no-extra-semi": 2,
|
||||
"no-fallthrough": 2,
|
||||
"no-func-assign": 2,
|
||||
"no-global-assign": 2,
|
||||
"no-inner-declarations": 2,
|
||||
"no-invalid-regexp": 2,
|
||||
"no-irregular-whitespace": 2,
|
||||
"no-mixed-spaces-and-tabs": 2,
|
||||
"no-new-symbol": 2,
|
||||
"no-obj-calls": 2,
|
||||
"no-octal": 2,
|
||||
"no-redeclare": 2,
|
||||
"no-regex-spaces": 2,
|
||||
"no-self-assign": 2,
|
||||
"no-sparse-arrays": 2,
|
||||
"no-this-before-super": 2,
|
||||
"no-undef": 2,
|
||||
"no-unexpected-multiline": 2,
|
||||
"no-unreachable": 2,
|
||||
"no-unsafe-finally": 2,
|
||||
"no-unsafe-negation": 2,
|
||||
"no-unused-labels": 2,
|
||||
"no-unused-vars": 2,
|
||||
"no-useless-escape": 1,
|
||||
"require-yield": 2,
|
||||
"use-isnan": 2,
|
||||
"valid-typeof": 2,
|
||||
"no-duplicate-imports": 2
|
||||
},
|
||||
"env": {
|
||||
"node": true,
|
||||
"browser": true,
|
||||
"es6": true
|
||||
},
|
||||
"globals": {
|
||||
"_": false,
|
||||
"hljs": false,
|
||||
"Sortable": false,
|
||||
"Prism": false
|
||||
}
|
||||
}
|
||||
"parserOptions": {
|
||||
"ecmaVersion": 7,
|
||||
"sourceType": "module",
|
||||
"ecmaFeatures": {}
|
||||
},
|
||||
"rules": {
|
||||
"constructor-super": 2,
|
||||
"for-direction": 2,
|
||||
"getter-return": 2,
|
||||
"no-case-declarations": 2,
|
||||
"no-class-assign": 2,
|
||||
"no-compare-neg-zero": 2,
|
||||
"no-cond-assign": 2,
|
||||
"no-console": 1,
|
||||
"no-const-assign": 2,
|
||||
"no-constant-condition": 2,
|
||||
"no-control-regex": 1,
|
||||
"no-debugger": 2,
|
||||
"no-delete-var": 2,
|
||||
"no-dupe-args": 2,
|
||||
"no-dupe-class-members": 2,
|
||||
"no-dupe-keys": 2,
|
||||
"no-duplicate-case": 2,
|
||||
"no-empty": 2,
|
||||
"no-empty-character-class": 2,
|
||||
"no-empty-pattern": 2,
|
||||
"no-ex-assign": 2,
|
||||
"no-extra-boolean-cast": 2,
|
||||
"no-extra-semi": 2,
|
||||
"no-fallthrough": 2,
|
||||
"no-func-assign": 2,
|
||||
"no-global-assign": 2,
|
||||
"no-inner-declarations": 2,
|
||||
"no-invalid-regexp": 2,
|
||||
"no-irregular-whitespace": 2,
|
||||
"no-mixed-spaces-and-tabs": 2,
|
||||
"no-new-symbol": 2,
|
||||
"no-obj-calls": 2,
|
||||
"no-octal": 2,
|
||||
"no-redeclare": 2,
|
||||
"no-regex-spaces": 2,
|
||||
"no-self-assign": 2,
|
||||
"no-sparse-arrays": 2,
|
||||
"no-this-before-super": 2,
|
||||
"no-undef": 2,
|
||||
"no-unexpected-multiline": 2,
|
||||
"no-unreachable": 2,
|
||||
"no-unsafe-finally": 2,
|
||||
"no-unsafe-negation": 2,
|
||||
"no-unused-labels": 2,
|
||||
"no-unused-vars": 1,
|
||||
"no-useless-escape": 1,
|
||||
"require-yield": 2,
|
||||
"use-isnan": 2,
|
||||
"valid-typeof": 2,
|
||||
"no-duplicate-imports": 2
|
||||
},
|
||||
"env": {
|
||||
"node": true,
|
||||
"browser": true,
|
||||
"es6": true
|
||||
},
|
||||
"globals": {
|
||||
"_": false,
|
||||
"hljs": false,
|
||||
"Sortable": false,
|
||||
"Prism": false
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,74 @@
|
||||
<?php
|
||||
|
||||
$config = new PhpCsFixer\Config();
|
||||
return $config
|
||||
->setRiskyAllowed(true)
|
||||
->setRules([
|
||||
'@PSR12' => true,
|
||||
'array_indentation' => true,
|
||||
'array_syntax' => [
|
||||
'syntax' => 'short',
|
||||
],
|
||||
'combine_consecutive_unsets' => true,
|
||||
'method_chaining_indentation' => true,
|
||||
'class_attributes_separation' => [
|
||||
'elements' => [
|
||||
'const' => 'none',
|
||||
'method' => 'one',
|
||||
'property' => 'none',
|
||||
'trait_import' => 'none',
|
||||
],
|
||||
],
|
||||
'multiline_whitespace_before_semicolons' => [
|
||||
'strategy' => 'no_multi_line',
|
||||
],
|
||||
'single_quote' => false,
|
||||
|
||||
'binary_operator_spaces' => [
|
||||
'default' => 'single_space',
|
||||
'operators' => [
|
||||
'=' => 'align_single_space_minimal',
|
||||
'=>' => 'align_single_space_minimal',
|
||||
],
|
||||
],
|
||||
'braces' => [
|
||||
'allow_single_line_closure' => true,
|
||||
],
|
||||
'concat_space' => [
|
||||
'spacing' => 'one',
|
||||
],
|
||||
'declare_equal_normalize' => true,
|
||||
'function_typehint_space' => true,
|
||||
'single_line_comment_style' => [
|
||||
'comment_types' => [
|
||||
'hash',
|
||||
],
|
||||
],
|
||||
'include' => true,
|
||||
'lowercase_cast' => true,
|
||||
'no_extra_blank_lines' => [
|
||||
'tokens' => [
|
||||
'curly_brace_block',
|
||||
'extra',
|
||||
'parenthesis_brace_block',
|
||||
'throw',
|
||||
]
|
||||
],
|
||||
'no_multiline_whitespace_around_double_arrow' => true,
|
||||
'no_spaces_around_offset' => true,
|
||||
'no_unused_imports' => true,
|
||||
'no_whitespace_before_comma_in_array' => true,
|
||||
'no_whitespace_in_blank_line' => true,
|
||||
'object_operator_without_whitespace' => true,
|
||||
'single_blank_line_before_namespace' => true,
|
||||
'ternary_operator_spaces' => true,
|
||||
'trim_array_spaces' => true,
|
||||
'unary_operator_spaces' => true,
|
||||
'whitespace_after_comma_in_array' => true,
|
||||
'single_line_after_imports' => true,
|
||||
'ordered_imports' => [
|
||||
'sort_algorithm' => 'none',
|
||||
],
|
||||
//Other rules here...
|
||||
])
|
||||
->setLineEnding("\n");
|
@ -0,0 +1,7 @@
|
||||
.babelrc
|
||||
README.md
|
||||
*.twig
|
||||
*.sass
|
||||
*.json
|
||||
*.php
|
||||
*.md
|
@ -0,0 +1,36 @@
|
||||
{
|
||||
"overrides": [
|
||||
{
|
||||
"files": ".prettierrc",
|
||||
"options": { "parser": "json" }
|
||||
},
|
||||
{
|
||||
"files": "*.scss",
|
||||
"options": {
|
||||
"tabWidth": 4,
|
||||
"semi": false,
|
||||
"singleQuote": true,
|
||||
"printWidth": 90
|
||||
}
|
||||
},
|
||||
{
|
||||
"files": "*.js",
|
||||
"options": {
|
||||
"arrowParens": "avoid",
|
||||
"bracketSpacing": true,
|
||||
"htmlWhitespaceSensitivity": "css",
|
||||
"insertPragma": false,
|
||||
"bracketSameLine": false,
|
||||
"jsxSingleQuote": true,
|
||||
"proseWrap": "preserve",
|
||||
"requirePragma": false,
|
||||
"semi": true,
|
||||
"singleQuote": true,
|
||||
"trailingComma": "none",
|
||||
"useTabs": true,
|
||||
"tabWidth": 4,
|
||||
"printWidth": 90
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
@ -0,0 +1,3 @@
|
||||
{
|
||||
"extends": ["stylelint-config-standard"]
|
||||
}
|
@ -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 write and publish.
|
||||
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. <br>
|
||||
## Check the (WIP) Docs to get you started. <br>
|
||||
|
||||
[Getting Started](https://code.playvicio.us/Are0h/Fipamo/wiki/00---Start) <br>
|
||||
[Install](https://code.playvicio.us/Are0h/Fipamo/wiki/01---Install) <br>
|
||||
[Using Fipamo](https://code.playvicio.us/Are0h/Fipamo/wiki/02-Usage) <br>
|
||||
[Getting Started](https://koodu.ubiqueros.com/are0h/Fipamo/wiki/00---Start) <br>
|
||||
|
@ -1,46 +0,0 @@
|
||||
<?php
|
||||
|
||||
use Psr\Http\Message\ResponseInterface as Response;
|
||||
use Psr\Http\Message\ServerRequestInterface as Request;
|
||||
use Slim\Factory\AppFactory;
|
||||
use Slim\Views\Twig;
|
||||
use Slim\Views\TwigMiddleware;
|
||||
|
||||
include "../brain/controller/RouteControl.inc.php";
|
||||
include "../brain/data/Settings.inc.php";
|
||||
include "../brain/data/Session.inc.php";
|
||||
include "../brain/data/Member.inc.php";
|
||||
include "../brain/data/Auth.inc.php";
|
||||
include "../brain/data/Render.inc.php";
|
||||
include "../brain/utility/StringTools.inc.php";
|
||||
include "../brain/utility/FileUploader.inc.php";
|
||||
include "../brain/utility/DocTools.inc.php";
|
||||
include "../brain/utility/Sorting.inc.php";
|
||||
include "../brain/utility/Setup.inc.php";
|
||||
include "../brain/utility/Maintenance.inc.php";
|
||||
include "../brain/utility/Mailer.inc.php";
|
||||
include "../brain/utility/HandleCors.inc.php";
|
||||
|
||||
class App
|
||||
{
|
||||
public function __construct()
|
||||
{
|
||||
// set up cors
|
||||
new HandleCors();
|
||||
$app = AppFactory::create();
|
||||
$twig = Twig::create("../brain/views/");
|
||||
$app->add(TwigMiddleware::create($app, $twig));
|
||||
//set up routing
|
||||
$app->get(
|
||||
"/[{first}[/{second}[/{third}[/{fourth}[/{fifth}]]]]]",
|
||||
"\RouteControl:get"
|
||||
);
|
||||
$app->post(
|
||||
"/[{first}[/{second}[/{third}[/{fourth}]]]]",
|
||||
"\RouteControl:post"
|
||||
);
|
||||
//start the app
|
||||
|
||||
$app->run();
|
||||
}
|
||||
}
|
@ -0,0 +1,10 @@
|
||||
<?php
|
||||
|
||||
spl_autoload_register(function ($className) {
|
||||
$file = dirname(__DIR__) . '\\' . $className . '.php';
|
||||
$file = str_replace('\\', DIRECTORY_SEPARATOR, $file);
|
||||
//echo $file;
|
||||
if (file_exists($file)) {
|
||||
include $file;
|
||||
}
|
||||
});
|
@ -1,74 +0,0 @@
|
||||
<?php
|
||||
|
||||
class AuthAPI
|
||||
{
|
||||
public function __construct()
|
||||
{
|
||||
}
|
||||
|
||||
public static function status()
|
||||
{
|
||||
$result = [];
|
||||
//internal check for admin action
|
||||
if (Auth::status()) {
|
||||
$result = [
|
||||
"message" => "Authorized",
|
||||
"type" => "apiUseAuthorized",
|
||||
"token" => Session::get("token"),
|
||||
];
|
||||
} else {
|
||||
$result = [
|
||||
"message" => "Not Authorized",
|
||||
"type" => "apiUseNotAuthorized",
|
||||
];
|
||||
}
|
||||
return $result;
|
||||
}
|
||||
|
||||
public static function login($body)
|
||||
{
|
||||
$result = [];
|
||||
switch (Auth::login($body)) {
|
||||
case "no_name":
|
||||
$result = [
|
||||
"message" => "Need to see some id, champ",
|
||||
"type" => "requestLame",
|
||||
];
|
||||
break;
|
||||
case "bad_pass":
|
||||
$result = [
|
||||
"message" => "Check your password, sport",
|
||||
"type" => "requestLame",
|
||||
];
|
||||
break;
|
||||
default:
|
||||
$result = [
|
||||
"message" => "Welcome back",
|
||||
"type" => "requestGood",
|
||||
];
|
||||
break;
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
public static function logout($body)
|
||||
{
|
||||
Auth::logout($body);
|
||||
$result = [
|
||||
"message" => "Till next time, g.",
|
||||
"type" => "TASK_LOGOUT",
|
||||
];
|
||||
return $result;
|
||||
}
|
||||
public static function requestSecret($body)
|
||||
{
|
||||
$result = Auth::findSecret($body);
|
||||
return $result;
|
||||
}
|
||||
public static function resetPassword($body)
|
||||
{
|
||||
$result = Auth::makeNewPassword($body);
|
||||
return $result;
|
||||
}
|
||||
}
|
@ -0,0 +1,81 @@
|
||||
<?php
|
||||
|
||||
namespace brain\api\v1;
|
||||
|
||||
use brain\data\Auth;
|
||||
use brain\data\Session;
|
||||
|
||||
class AuthAPI
|
||||
{
|
||||
public function __construct()
|
||||
{
|
||||
}
|
||||
|
||||
public static function status()
|
||||
{
|
||||
$result = [];
|
||||
//internal check for admin action
|
||||
if (Auth::status()) {
|
||||
$result = [
|
||||
'message' => 'Authorized',
|
||||
'type' => 'apiUseAuthorized',
|
||||
'token' => Session::get('token'),
|
||||
];
|
||||
} else {
|
||||
$result = [
|
||||
'message' => 'Not Authorized',
|
||||
'type' => 'apiUseNotAuthorized',
|
||||
];
|
||||
}
|
||||
return $result;
|
||||
}
|
||||
|
||||
public static function login($body)
|
||||
{
|
||||
$result = [];
|
||||
switch (Auth::login($body)) {
|
||||
case 'no_name':
|
||||
$result = [
|
||||
'message' => 'Need to see some id, champ',
|
||||
'type' => 'requestLame',
|
||||
];
|
||||
break;
|
||||
case 'bad_pass':
|
||||
$result = [
|
||||
'message' => 'Check your password, sport',
|
||||
'type' => 'requestLame',
|
||||
];
|
||||
break;
|
||||
default:
|
||||
$result = [
|
||||
'message' => 'Welcome back',
|
||||
'type' => 'requestGood',
|
||||
];
|
||||
break;
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
public static function logout($body)
|
||||
{
|
||||
Auth::logout($body);
|
||||
$result = [
|
||||
'message' => 'Till next time, g.',
|
||||
'type' => 'TASK_LOGOUT',
|
||||
];
|
||||
return $result;
|
||||
}
|
||||
|
||||
public static function requestSecret($body)
|
||||
{
|
||||
$result = Auth::findSecret($body);
|
||||
return $result;
|
||||
}
|
||||
|
||||
public static function resetPassword($body)
|
||||
{
|
||||
$result = Auth::makeNewPassword($body);
|
||||
return $result;
|
||||
}
|
||||
}
|
@ -0,0 +1,73 @@
|
||||
<?php
|
||||
|
||||
namespace brain\api\v1;
|
||||
|
||||
use brain\utility\FileUploader;
|
||||
use brain\data\Settings;
|
||||
use brain\data\Member;
|
||||
|
||||
class FilesAPI
|
||||
{
|
||||
public function __construct()
|
||||
{
|
||||
}
|
||||
|
||||
public static function uploadFiles($request, $type = null)
|
||||
{
|
||||
$upload = $request->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;
|
||||
}
|
||||
}
|
@ -1,76 +0,0 @@
|
||||
<?php
|
||||
|
||||
class ImagesAPI
|
||||
{
|
||||
public function __construct()
|
||||
{
|
||||
}
|
||||
|
||||
public static function uploadImage($request, $type = null)
|
||||
{
|
||||
$file = $request->getUploadedFiles();
|
||||
$uploadPath = "";
|
||||
$path = date("Y") . "/" . date("m");
|
||||
$response = [];
|
||||
switch ($type) {
|
||||
case "avatar":
|
||||
$image = $file["avatar_upload"];
|
||||
$uploadPath = "../public/assets/images/user/" . $path;
|
||||
break;
|
||||
case "background":
|
||||
$image = $file["background_upload"];
|
||||
$uploadPath = "../public/assets/images/user/" . $path;
|
||||
break;
|
||||
default:
|
||||
$image = $file["post_image"];
|
||||
$path = date("Y") . "/" . date("m");
|
||||
$uploadPath = "../public/assets/images/blog/" . $path;
|
||||
break;
|
||||
}
|
||||
|
||||
$result = FileUploader::uploadFile($uploadPath, $image);
|
||||
|
||||
switch ($type) {
|
||||
case "avatar":
|
||||
$response = [
|
||||
"message" => "Avatar Added. You look great!",
|
||||
"type" => "avatarUploaded",
|
||||
"url" =>
|
||||
"/assets/images/user/" . $path . "/" . $image->getClientFileName(),
|
||||
];
|
||||
|
||||
//update member data
|
||||
Member::updateData(
|
||||
"avi",
|
||||
"/assets/images/user/" . $path . "/" . $image->getClientFileName()
|
||||
);
|
||||
|
||||
break;
|
||||
case "background":
|
||||
$response = [
|
||||
"message" => "Background plugged in. That's nice!",
|
||||
"type" => "siteBackgroundUploaded",
|
||||
"url" =>
|
||||
"/assets/images/user/" . $path . "/" . $image->getClientFileName(),
|
||||
];
|
||||
|
||||
//update settings file
|
||||
Settings::updateGlobalData(
|
||||
"background",
|
||||
"/assets/images/user/" . $path . "/" . $image->getClientFileName()
|
||||
);
|
||||
|
||||
break;
|
||||
default:
|
||||
$response = [
|
||||
"message" => "Image Added. Very slick",
|
||||
"type" => "postImageAdded",
|
||||
"url" =>
|
||||
"/assets/images/blog/" . $path . "/" . $image->getClientFileName(),
|
||||
];
|
||||
break;
|
||||
}
|
||||
|
||||
return $response;
|
||||
}
|
||||
}
|
@ -0,0 +1,79 @@
|
||||
<?php
|
||||
|
||||
namespace brain\api\v1;
|
||||
|
||||
use brain\data\Member;
|
||||
use brain\data\Settings;
|
||||
use brain\utility\FileUploader;
|
||||
|
||||
class ImagesAPI
|
||||
{
|
||||
public function __construct()
|
||||
{
|
||||
}
|
||||
|
||||
public static function uploadImage($request, $type = null)
|
||||
{
|
||||
$file = $request->getUploadedFiles();
|
||||
$uploadPath = '';
|
||||
$path = date('Y') . '/' . date('m');
|
||||
$response = [];
|
||||
switch ($type) {
|
||||
case 'avatar':
|
||||
$image = $file['avatar_upload'];
|
||||
$uploadPath = '../public/assets/images/user/' . $path;
|
||||
break;
|
||||
case 'background':
|
||||
$image = $file['background_upload'];
|
||||
$uploadPath = '../public/assets/images/user/' . $path;
|
||||
break;
|
||||
default:
|
||||
$image = $file['post_image'];
|
||||
$path = date('Y') . '/' . date('m');
|
||||
$uploadPath = '../public/assets/images/blog/' . $path;
|
||||
break;
|
||||
}
|
||||
|
||||
$result = FileUploader::uploadFile($uploadPath, $image);
|
||||
|
||||
switch ($type) {
|
||||
case 'avatar':
|
||||
$response = [
|
||||
'message' => 'Avatar Added. You look great!',
|
||||
'type' => 'avatarUploaded',
|
||||
'url' => '/assets/images/user/' . $path . '/' . $image->getClientFileName(),
|
||||
];
|
||||
|
||||
//update member data
|
||||
Member::updateData(
|
||||
'avi',
|
||||
'/assets/images/user/' . $path . '/' . $image->getClientFileName()
|
||||
);
|
||||
|
||||
break;
|
||||
case 'background':
|
||||
$response = [
|
||||
'message' => "Background plugged in. That's nice!",
|
||||
'type' => 'siteBackgroundUploaded',
|
||||
'url' => '/assets/images/user/' . $path . '/' . $image->getClientFileName(),
|
||||
];
|
||||
|
||||
//update settings file
|
||||
Settings::updateGlobalData(
|
||||
'background',
|
||||
'/assets/images/user/' . $path . '/' . $image->getClientFileName()
|
||||
);
|
||||
|
||||
break;
|
||||
default:
|
||||
$response = [
|
||||
'message' => 'Image Added. Very slick',
|
||||
'type' => 'postImageAdded',
|
||||
'url' => '/assets/images/blog/' . $path . '/' . $image->getClientFileName(),
|
||||
];
|
||||
break;
|
||||
}
|
||||
|
||||
return $response;
|
||||
}
|
||||
}
|
@ -1,30 +0,0 @@
|
||||
<?php
|
||||
|
||||
class InitAPI
|
||||
{
|
||||
public function __construct()
|
||||
{
|
||||
}
|
||||
|
||||
public static function handleInitTasks($task, $request)
|
||||
{
|
||||
//check if a site config already exists. if it does, deny set up request
|
||||
//restore to previous version of site while a config exists is only accessible
|
||||
//through settings.
|
||||
|
||||
if (Setup::status()) {
|
||||
$result = ["type" => "blogInitFail", "message" => "Site already set up"];
|
||||
} else {
|
||||
switch ($task) {
|
||||
case "init":
|
||||
$result = Setup::init($request);
|
||||
break;
|
||||
case "restore":
|
||||
$result = Setup::restore($request);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
}
|
@ -0,0 +1,34 @@
|
||||
<?php
|
||||
|
||||
namespace brain\api\v1;
|
||||
|
||||
use brain\utility\Setup;
|
||||
|
||||
class InitAPI
|
||||
{
|
||||
public function __construct()
|
||||
{
|
||||
}
|
||||
|
||||
public static function handleInitTasks($task, $request)
|
||||
{
|
||||
//check if a site config already exists. if it does, deny set up request
|
||||
//restore to previous version of site while a config exists is only accessible
|
||||
//through settings.
|
||||
|
||||
if (Setup::status()) {
|
||||
$result = ['type' => 'blogInitFail', 'message' => 'Site already set up'];
|
||||
} else {
|
||||
switch ($task) {
|
||||
case 'init':
|
||||
$result = Setup::init($request);
|
||||
break;
|
||||
case 'restore':
|
||||
$result = Setup::restore($request);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
}
|
@ -1,26 +0,0 @@
|
||||
<?php
|
||||
|
||||
class MailerAPI
|
||||
{
|
||||
public function __construct()
|
||||
{
|
||||
}
|
||||
|
||||
public static function handleMail($request, $body, $response)
|
||||
{
|
||||
//if testing, verify session is active
|
||||
if ($body["mail_task"] == "TESTING") {
|
||||
if (Session::active()) {
|
||||
$result = Mailer::sendmail($body);
|
||||
} else {
|
||||
$result = [
|
||||
"message" => "You need to be logged in for this, champ.",
|
||||
"type" => "MAILER_ERROR",
|
||||
];
|
||||
}
|
||||
} else {
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
}
|
@ -0,0 +1,32 @@
|
||||
<?php
|
||||
|
||||
namespace brain\api\v1;
|
||||
|
||||
use brain\data\Session;
|
||||
use brain\utility\Mailer;
|
||||
|
||||
class MailerAPI
|
||||
{
|
||||
public function __construct()
|
||||
{
|
||||
}
|
||||
|
||||
public static function handleMail($request, $body, $response)
|
||||
{
|
||||
// if testing, verify session is active
|
||||
// add clean method for sending programmtic emails
|
||||
if ($body['mail_task'] == 'TESTING') {
|
||||
if (Session::active()) {
|
||||
$result = Mailer::sendmail($body);
|
||||
} else {
|
||||
$result = [
|
||||
'message' => 'You need to be logged in for this, champ.',
|
||||
'type' => 'MAILER_ERROR',
|
||||
];
|
||||
}
|
||||
} else {
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
}
|
@ -1,173 +0,0 @@
|
||||
<?php
|
||||
use function _\filter;
|
||||
use Mni\FrontYAML\Parser;
|
||||
|
||||
class PagesAPI
|
||||
{
|
||||
public function __construct()
|
||||
{
|
||||
}
|
||||
|
||||
public static function getPageContent($request, $args)
|
||||
{
|
||||
$task = $args["fourth"];
|
||||
$pages = (new Book("../content/pages"))->getContents();
|
||||
$content = [];
|
||||
foreach ($pages as $page) {
|
||||
$entry = [
|
||||
"id" => $page["id"],
|
||||
"uuid" => $page["uuid"],
|
||||
"title" => $page["title"],
|
||||
"feature" => $page["feature"],
|
||||
"path" => $page["path"],
|
||||
"layout" => $page["layout"],
|
||||
"tags" => $page["tags"],
|
||||
"author" => $page["author"],
|
||||
"created" => $page["created"],
|
||||
"updated" => $page["updated"],
|
||||
"deleted" => $page["deleted"],
|
||||
"menu" => $page["menu"],
|
||||
"featured" => $page["featured"],
|
||||
"published" => $page["published"],
|
||||
"slug" => $page["slug"],
|
||||
"content" => StringTools::sanitizeContent($page["content"]),
|
||||
];
|
||||
|
||||
array_push($content, $entry);
|
||||
}
|
||||
switch ($task) {
|
||||
case "published":
|
||||
$published = filter($content, function ($item) {
|
||||
return $item["published"] == true && $item["deleted"] == false;
|
||||
});
|
||||
|
||||
$result = ["pages" => $published, "totalItems" => count($published)];
|
||||
break;
|
||||
case "featured":
|
||||
$featured = filter($content, function ($item) {
|
||||
return $item["featured"] == true && $item["deleted"] == false;
|
||||
});
|
||||
|
||||
$result = [
|
||||
"pages" => $featured,
|
||||
"totalItems" => count($featured),
|
||||
];
|
||||
break;
|
||||
case "menu":
|
||||
$menu = filter($content, function ($item) {
|
||||
return $item["menu"] == true && $item["deleted"] == false;
|
||||
});
|
||||
|
||||
$result = ["pages" => $menu, "totalItems" => count($menu)];
|
||||
break;
|
||||
case "single":
|
||||
$uuid = $args["fifth"];
|
||||
$page = (new Book("../content/pages"))->findPageById($uuid);
|
||||
|
||||
$entry = [
|
||||
"id" => $page["id"],
|
||||
"uuid" => $page["uuid"],
|
||||
"title" => $page["title"],
|
||||
"feature" => $page["feature"],
|
||||
"path" => $page["path"],
|
||||
"layout" => $page["layout"],
|
||||
"tags" => $page["tags"],
|
||||
"author" => $page["author"],
|
||||
"created" => $page["created"],
|
||||
"updated" => $page["updated"],
|
||||
"deleted" => $page["deleted"],
|
||||
"menu" => $page["menu"],
|
||||
"featured" => $page["featured"],
|
||||
"published" => $page["published"],
|
||||
"slug" => $page["slug"],
|
||||
"content" => StringTools::sanitizeContent($page["content"]),
|
||||
];
|
||||
$result = $entry;
|
||||
break;
|
||||
case "tags":
|
||||
$result = Settings::getTags();
|
||||
break;
|
||||
default:
|
||||
$result = [
|
||||
"message" => "Hm, no task. That's unfortunate",
|
||||
"type" => "TASK_NONE",
|
||||
];
|
||||
break;
|
||||
}
|
||||
return $result;
|
||||
}
|
||||
|
||||
public static function handlePageTask($request, $args)
|
||||
{
|
||||
$task = $args["fourth"];
|
||||
switch ($task) {
|
||||
case "delete":
|
||||
case "create":
|
||||
case "write":
|
||||
$body = $request->getParsedBody();
|
||||
$passed = true;
|
||||
if (!isset($body["form_token"])) {
|
||||
$result = [
|
||||
"message" => "No form token. Not good, sport.",
|
||||
"type" => "TASK_FORM_AUTH",
|
||||
];
|
||||
} else {
|
||||
if ($body["form_token"] == Session::get("form_token")) {
|
||||
//TODO: Verify form fields
|
||||
$keys = [
|
||||
"id",
|
||||
"uuid",
|
||||
"layout",
|
||||
"current_title",
|
||||
"content",
|
||||
"title",
|
||||
"created",
|
||||
"slug",
|
||||
"tags",
|
||||
"menu",
|
||||
"featured",
|
||||
"published",
|
||||
"form_token",
|
||||
"feature_image",
|
||||
];
|
||||
|
||||
foreach ($body as $key => $item) {
|
||||
if (!in_array($key, $keys)) {
|
||||
//found unnecessary key, so reject submission
|
||||
$passed = false;
|
||||
}
|
||||
}
|
||||
if ($passed) {
|
||||
$result = (new Book("../content/pages"))->editPage(
|
||||
$task,
|
||||
$request
|
||||
);
|
||||
} else {
|
||||
$result = [
|
||||
"message" => "Form token, auth failed. Uh oh.",
|
||||
"type" => "TASK_FORM_AUTH",
|
||||
];
|
||||
}
|
||||
} else {
|
||||
$result = [
|
||||
"message" => "Form token, auth failed. Uh oh.",
|
||||
"type" => "TASK_FORM_AUTH",
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
break;
|
||||
case "add-entry-image":
|
||||
$result = ImagesAPI::uploadImage($request);
|
||||
break;
|
||||
default:
|
||||
$result = [
|
||||
"message" => "Hm, no task. That's unfortunate",
|
||||
"type" => "TASK_NONE",
|
||||
];
|
||||
break;
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
}
|
@ -0,0 +1,179 @@
|
||||
<?php
|
||||
|
||||
namespace brain\api\v1;
|
||||
|
||||
use brain\data\Book;
|
||||
use brain\data\Settings;
|
||||
use brain\data\Session;
|
||||
use brain\utility\StringTools;
|
||||
|
||||
use function _\filter;
|
||||
|
||||
class PagesAPI
|
||||
{
|
||||
public function __construct()
|
||||
{
|
||||
}
|
||||
|
||||
public static function getPageContent($request, $args)
|
||||
{
|
||||
$task = $args['fourth'];
|
||||
$pages = (new Book('../content/pages'))->getContents();
|
||||
$content = [];
|
||||
foreach ($pages as $page) {
|
||||
$entry = [
|
||||
'id' => $page['id'],
|
||||
'uuid' => $page['uuid'],
|
||||
'title' => $page['title'],
|
||||
'feature' => $page['feature'],
|
||||
'path' => $page['path'],
|
||||
'layout' => $page['layout'],
|
||||
'tags' => $page['tags'],
|
||||
'author' => $page['author'],
|
||||
'created' => $page['created'],
|
||||
'updated' => $page['updated'],
|
||||
'deleted' => $page['deleted'],
|
||||
'menu' => $page['menu'],
|
||||
'featured' => $page['featured'],
|
||||
'published' => $page['published'],
|
||||
'slug' => $page['slug'],
|
||||
'content' => StringTools::sanitizeContent($page['content']),
|
||||
];
|
||||
|
||||
array_push($content, $entry);
|
||||
}
|
||||
switch ($task) {
|
||||
case 'published':
|
||||
$published = filter($content, function ($item) {
|
||||
return $item['published'] == true && $item['deleted'] == false;
|
||||
});
|
||||
|
||||
$result = ['pages' => $published, 'totalItems' => count($published)];
|
||||
break;
|
||||
case 'featured':
|
||||
$featured = filter($content, function ($item) {
|
||||
return $item['featured'] == true && $item['deleted'] == false;
|
||||
});
|
||||
|
||||
$result = [
|
||||
'pages' => $featured,
|
||||
'totalItems' => count($featured),
|
||||
];
|
||||
break;
|
||||
case 'menu':
|
||||
$menu = filter($content, function ($item) {
|
||||
return $item['menu'] == true && $item['deleted'] == false;
|
||||
});
|
||||
|
||||
$result = ['pages' => $menu, 'totalItems' => count($menu)];
|
||||
break;
|
||||
case 'single':
|
||||
$uuid = $args['fifth'];
|
||||
$page = (new Book('../content/pages'))->findPageById($uuid);
|
||||
|
||||
$entry = [
|
||||
'id' => $page['id'],
|
||||
'uuid' => $page['uuid'],
|
||||
'title' => $page['title'],
|
||||
'feature' => $page['feature'],
|
||||
'path' => $page['path'],
|
||||
'layout' => $page['layout'],
|
||||
'tags' => $page['tags'],
|
||||
'author' => $page['author'],
|
||||
'created' => $page['created'],
|
||||
'updated' => $page['updated'],
|
||||
'deleted' => $page['deleted'],
|
||||
'menu' => $page['menu'],
|
||||
'featured' => $page['featured'],
|
||||
'published' => $page['published'],
|
||||
'slug' => $page['slug'],
|
||||
'content' => StringTools::sanitizeContent($page['content']),
|
||||
];
|
||||
$result = $entry;
|
||||
break;
|
||||
case 'tags':
|
||||
$result = Settings::getTags();
|
||||
break;
|
||||
default:
|
||||
$result = [
|
||||
'message' => "Hm, no task. That's unfortunate",
|
||||
'type' => 'TASK_NONE',
|
||||
];
|
||||
break;
|
||||
}
|
||||
return $result;
|
||||
}
|
||||
|
||||
public static function handlePageTask($request, $args)
|
||||
{
|
||||
$task = $args['fourth'];
|
||||
switch ($task) {
|
||||
case 'delete':
|
||||
case 'create':
|
||||
case 'write':
|
||||
$body = json_decode(file_get_contents("php://input"), true);
|
||||
$passed = true;
|
||||
if (!isset($body['form_token'])) {
|
||||
$result = [
|
||||
'message' => 'No form token. Not good, sport.',
|
||||
'type' => 'TASK_FORM_AUTH',
|
||||