Compare commits
204 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 | 2 years ago |
Are0h | a1c0d86580 | 2 years ago |
Are0h | 197fb005de | 2 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 |
Ro | ccf65e1899 | 3 years ago |
Ro | 934d29f4cf | 3 years ago |
Ro | ccbf55bb54 | 3 years ago |
Ro | fdc6cb2cf2 | 3 years ago |
Ro | f2450b2be5 | 3 years ago |
Ro | 6e9368c2aa | 3 years ago |
Ro | d7c2827115 | 3 years ago |
Ro | 854cf12067 | 3 years ago |
Ro | 8df5e68024 | 3 years ago |
Ro | 85a7eab8be | 3 years ago |
Ro | 734c6d36f1 | 3 years ago |
Ro | bf383785a0 | 3 years ago |
Ro | 183a620b1e | 3 years ago |
Ro | b1c884689e | 3 years ago |
Ro | b3c47d6721 | 3 years ago |
Ro | ce30f3efb7 | 3 years ago |
Ro | cad32ace74 | 3 years ago |
Ro | fe8a5e4e96 | 3 years ago |
Ro | 7d3f2d13a4 | 3 years ago |
Ro | da49388caa | 3 years ago |
Ro | a1932e1a24 | 3 years ago |
Ro | 3c3f2a0881 | 3 years ago |
Ro | b24f0a6adb | 3 years ago |
Ro | 3968e32e78 | 3 years ago |
Ro | 0ec49de8ab | 3 years ago |
Ro | 83b4aff716 | 3 years ago |
Ro | 7d80e42642 | 3 years ago |
Ro | 13c9d05019 | 3 years ago |
Ro | 7f3be4c0c5 | 3 years ago |
Ro | 8355137952 | 3 years ago |
Ro | 1f1c611afe | 3 years ago |
Ro | 02563a4c87 | 3 years ago |
Ro | ab40219d9b | 3 years ago |
Ro | 2785ef6982 | 3 years ago |
Ro | b9056b64df | 3 years ago |
Ro | ebdda2c089 | 3 years ago |
Ro | e40e566302 | 3 years ago |
Ro | f7e3b3b55e | 3 years ago |
Ro | 8101b16cf9 | 3 years ago |
Ro | 45fd8be25f | 3 years ago |
Ro | 46691b454d | 3 years ago |
Ro | 321903643a | 3 years ago |
Ro | 2d84ec9e33 | 3 years ago |
Ro | 8f5df10b89 | 3 years ago |
Ro | 24242d4bf0 | 3 years ago |
Ro | 3d8c421f76 | 3 years ago |
Ro | 8417e692d7 | 3 years ago |
Ro | 65def75433 | 3 years ago |
Ro | 3df2720009 | 4 years ago |
Ro | 2f1f6678b7 | 4 years ago |
Ro | a542b2d884 | 4 years ago |
Ro | 6b2ee8e401 | 4 years ago |
Ro | 6cd28c06c0 | 4 years ago |
Ro | b7aafed112 | 4 years ago |
Ro | 3706a81c5f | 4 years ago |
Ro | c21704b8bd | 4 years ago |
Ro | 18e67691f5 | 4 years ago |
Ro | 20fc9c64a1 | 4 years ago |
Ro | 0765ea4555 | 4 years ago |
Ro | 033fe5e48b | 4 years ago |
Ro | 8e3d359486 | 4 years ago |
Ro | 005de8027e | 4 years ago |
Ro | b51d63633f | 4 years ago |
Ro | 913dd3a57f | 4 years ago |
Ro | 8f1e3a55e7 | 4 years ago |
Ro | 9462b91246 | 4 years ago |
Ro | bedb6fdfe5 | 4 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,42 +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";
|
||||
|
||||
class App
|
||||
{
|
||||
public function __construct()
|
||||
{
|
||||
$app = AppFactory::create();
|
||||
$twig = Twig::create("../brain/views/");
|
||||
$app->add(TwigMiddleware::create($app, $twig));
|
||||
//set up routing
|
||||
$app->get(
|
||||
"/[{first}[/{second}[/{third}[/{fourth}]]]]",
|
||||
"\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,63 +0,0 @@
|
||||
<?php
|
||||
|
||||
class AuthAPI
|
||||
{
|
||||
public function __construct()
|
||||
{
|
||||
}
|
||||
|
||||
public static function status()
|
||||
{
|
||||
$result = [];
|
||||
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;
|
||||
}
|
||||
}
|
@ -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,22 +0,0 @@
|
||||
<?php
|
||||
|
||||
class InitAPI
|
||||
{
|
||||
public function __construct()
|
||||
{
|
||||
}
|
||||
|
||||
public static function handleInitTasks($task, $request)
|
||||
{
|
||||
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;
|
||||
}
|
||||
}
|
@ -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,31 +0,0 @@
|
||||
<?php
|
||||
|
||||
class PagesAPI
|
||||
{
|
||||
public function __construct()
|
||||
{
|
||||
}
|
||||
|
||||
public static function handlePageTask($request, $args)
|
||||
{
|
||||
$task = $args["fourth"];
|
||||
switch ($task) {
|
||||
case "delete":
|
||||
case "create":
|
||||
case "write":
|
||||
$result = (new Book("../content/pages"))->editPage($task, $request);
|
||||
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',
|
||||
];
|
||||
} else {
|
||||
if ($body['form_token'] == Session::get('form_token')) {
|
||||
$keys = [
|
||||
'id',
|
||||
'uuid',
|
||||
'layout',
|
||||
'current_title',
|
||||
'content',
|
||||
'title',
|
||||
'created',
|
||||
'slug',
|
||||
'tags',
|
||||
'menu',
|
||||
'featured',
|
||||
'published',
|
||||
'form_token',
|
||||
'imageList',
|
||||
"fileList",
|
||||
"remote"
|
||||
];
|
||||
|
||||
foreach ($body as $key => $item) {
|
||||
if (!in_array($key, $keys)) {
|
||||
//found unnecessary key, so reject submission
|
||||
var_dump($key);
|
||||
$passed = false;
|
||||
}
|
||||
}
|
||||
if ($passed) {
|
||||
$result = (new Book())->editPage($task, $request);
|
||||
} else {
|
||||
$result = [
|
||||
'message' => 'Unneccessary key found. Post not authorized, slick.',
|
||||
'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;
|
||||
}
|
||||
}
|
@ -1,63 +0,0 @@
|
||||
<?php
|
||||
|
||||
use Slim\Views\Twig;
|
||||
|
||||
class SettingsAPI
|
||||
{
|
||||
public function __construct()
|
||||
{
|
||||
}
|
||||
|
||||
public static function handleSettingsTask($request, $args, $body = null)
|
||||
{
|
||||
$task = $args["fourth"];
|
||||
switch ($task) {
|
||||
case "publish":
|
||||
$render = new Render();
|
||||
$render->renderTags();
|
||||
$render->renderArchive();
|
||||
$render->renderPages();
|
||||
|
||||
$result = [
|
||||
"message" => "Site Rendered. GOOD EFFORT",
|
||||
"type" => "TASK_NONE",
|
||||
];
|
||||
|
||||
break;
|
||||
case "add-avatar":
|
||||
$result = ImagesAPI::uploadImage($request, "avatar");
|
||||
break;
|
||||
case "add-feature-background":
|
||||
$result = ImagesAPI::uploadImage($request, "background");
|
||||
break;
|
||||
case "sync":
|
||||
Settings::sync($body);
|
||||
$result = [
|
||||
"message" => "Settings Synced. You're doing great!",
|
||||
"type" => "settingsUpdated",
|
||||
];
|
||||
break;
|
||||
case "nav-sync":
|
||||
Settings::navSync($body);
|
||||
$result = [
|
||||
"message" => "Navigation updated. Very slick!",
|
||||
"type" => "menuUpdated",
|
||||
];
|
||||
break;
|
||||
default:
|
||||
$result = [
|
||||
"message" => "Hm, no task. That's unfortunate",
|
||||
"type" => "TASK_NONE",
|
||||
];
|
||||
break;
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
public static function createBackup()
|
||||
{
|
||||
$result = Maintenance::makeBackup();
|
||||
return $result;
|
||||
}
|
||||
}
|
@ -0,0 +1,153 @@
|
||||
<?php
|
||||
|
||||
namespace brain\api\v1;
|
||||
|
||||
use brain\data\Render;
|
||||
use brain\data\Settings;
|
||||
use brain\data\Session;
|
||||
use brain\utility\Maintenance;
|
||||
|
||||
class SettingsAPI
|
||||
{
|
||||
public function __construct()
|
||||
{
|
||||
}
|
||||
|
||||
public static function handleSettingsTask($request, $args, $body = null)
|
||||
{
|
||||
$task = $args['fourth'];
|
||||
switch ($task) {
|
||||
case 'publish':
|
||||
//check settings to see if site is a one pager
|
||||
$config = new Settings();
|
||||
$settings = $config->getSettings();
|
||||
$theme = $settings['global']['theme'];
|
||||
$themeConfig = json_decode(
|
||||
file_get_contents('../content/themes/' . $theme . '/theme.json'),
|
||||
true
|
||||
);
|
||||
//check to see if dynamic rendering is active
|
||||
if (
|
||||
isset($settings['global']['dynamicRender']) &&
|
||||
$settings['global']['dynamicRender'] === 'true'
|
||||
) {
|
||||
$result = [
|
||||
'message' => "Dynamic Render Active! You're good!",
|
||||
'type' => 'RENDER_SUCCESS',
|
||||
];
|
||||
} else {
|
||||
$render = new Render();
|
||||
if (isset($themeConfig['render'])) {
|
||||
//rendering for one page sites
|
||||
if (!$themeConfig['render'] || $themeConfig['render'] === 'false') {
|
||||
$render->renderIndex();
|
||||
$result = [
|
||||
'message' => 'Index Rendered. HAND CLAPS',
|
||||
'type' => 'RENDER_SUCCESS',
|
||||
];
|
||||
} else {
|
||||
$render->renderTags();
|
||||
$render->renderArchive();
|
||||
$render->renderPages();
|
||||
$result = [
|
||||
'message' => 'Site Rendered. GOOD EFFORT',
|
||||
'type' => 'RENDER_SUCCESS',
|
||||
];
|
||||
}
|
||||
} else {
|
||||
// just incase the render flag is missing
|
||||
$render->renderTags();
|
||||
$render->renderArchive();
|
||||
$render->renderPages();
|
||||
$result = [
|
||||
'message' => 'Site Rendered. GOOD EFFORT',
|
||||
'type' => 'RENDER_SUCCESS',
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
//if render flag is set and false, just render index page for one page sites
|
||||
//otherwise, render all pages according to theme template files
|
||||
|
||||
break;
|
||||
case 'add-avatar':
|
||||
$result = ImagesAPI::uploadImage($request, 'avatar');
|
||||
break;
|
||||
case 'add-feature-background':
|
||||
$result = ImagesAPI::uploadImage($request, 'background');
|
||||
break;
|
||||
case 'sync':
|
||||
Settings::sync($body);
|
||||
$result = [
|
||||
'message' => "Settings Synced. You're doing great!",
|
||||
'type' => 'settingsUpdated',
|
||||
];
|
||||
break;
|
||||
case 'nav-sync':
|
||||
Settings::navSync($body);
|
||||
$result = [
|
||||
'message' => 'Navigation updated. Very slick!',
|
||||
'type' => 'menuUpdated',
|
||||
];
|
||||
break;
|
||||
default:
|
||||
$result = [
|
||||
'message' => "Hm, no task. That's unfortunate",
|
||||
'type' => 'TASK_NONE',
|
||||
];
|
||||
break;
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
public static function getInfo($request, $args)
|
||||
{
|
||||
$task = $args['fourth'];
|
||||
switch ($task) {
|
||||
case 'site':
|
||||
$config = new Settings();
|
||||
$settings = $config->getSettings();
|
||||
$data = [
|
||||
'title' => $settings['global']['title'],
|
||||
'base_url' => $settings['global']['base_url'],
|
||||
'description' => $settings['global']['descriptions'],
|
||||
];
|
||||
$result = [
|
||||
'message' => 'Settings Found',
|
||||
'type' => 'GET_SETTINGS',
|
||||
'data' => $data,
|
||||
];
|
||||
break;
|
||||
case 'member':
|
||||
if (Session::active()) {
|
||||
$member = $member = Session::get('member');
|
||||
$data = ['handle' => $member['handle'], 'email' => $member['email']];
|
||||
$result = [
|
||||
'message' => 'Member Info Found',
|
||||
'type' => 'GET_MEMBER_INFO',
|
||||
'data' => $data,
|
||||
];
|
||||
} else {
|
||||
$result = [
|
||||
'message' => "Not logged in. C'mon, bruh",
|
||||
'type' => 'TASK_NONE',
|
||||
];
|
||||
}
|
||||
break;
|
||||
default:
|
||||
$result = [
|
||||
'message' => 'No Settings found. Frowny Face',
|
||||
'type' => 'TASK_NONE',
|
||||
];
|
||||
break;
|
||||
}
|
||||
return $result;
|
||||
}
|
||||
|
||||
public static function createBackup()
|
||||
{
|
||||
$result = Maintenance::makeBackup();
|
||||
return $result;
|
||||
}
|
||||
}
|
@ -1,151 +0,0 @@
|
||||
<?php
|
||||
use Psr\Http\Message\ResponseInterface;
|
||||
use Psr\Http\Message\ServerRequestInterface;
|
||||
|
||||
include "../brain/api/v1/AuthAPI.inc.php";
|
||||
include "../brain/api/v1/ImagesAPI.inc.php";
|
||||
include "../brain/api/v1/PagesAPI.inc.php";
|
||||
include "../brain/api/v1/SettingsAPI.inc.php";
|
||||
include "../brain/api/v1/InitAPI.inc.php";
|
||||
|
||||
class APIControl
|
||||
{
|
||||
public static function get(
|
||||
ServerRequestInterface $request,
|
||||
ResponseInterface $response,
|
||||
array $args
|
||||
): ResponseInterface {
|
||||
$filename = "";
|
||||
switch (isset($args["third"]) ? $args["third"] : "none") {
|
||||
case "status":
|
||||
$result = AuthAPI::status();
|
||||
break;
|
||||
case "files":
|
||||
if (Session::active()) {
|
||||
if ($args["third"] == "backup") {
|
||||
$filename = "../config/backups/latest_backup.zip";
|
||||
if (file_exists($filename)) {
|
||||
header("Content-Type: application/zip");
|
||||
header(
|
||||
'Content-Disposition: attachment; filename="' .
|
||||
basename($filename) .
|
||||
'"'
|
||||
);
|
||||
header("Content-Length: " . filesize($filename));
|
||||
|
||||
flush();
|
||||
// return readfile($filename);
|
||||
//readfile($filename);
|
||||
// delete file
|
||||
//unlink($filename);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
$result = [
|
||||
"message" => "API access denied, homie",
|
||||
"type" => "API_ERROR",
|
||||
];
|
||||
}
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
$freshResponse = $response;
|
||||
|
||||
if ($args["third"] == "files") {
|
||||
$freshResponse
|
||||
->getBody()
|
||||
->write(file_get_contents("../config/backups/latest_back.zip"));
|
||||
|
||||
$freshResponse->withHeader("Content-Type", "application/zip");
|
||||
return $freshResponse->withAddedHeader(
|
||||
"Content-Disposition",
|
||||
"attachment; filename=latest_backup.zip"
|
||||
);
|
||||
} else {
|
||||
$response->getBody()->write(json_encode($result));
|
||||
return $response->withHeader("Content-Type", "application/json");
|
||||
}
|
||||
}
|
||||
public static function post(
|
||||
ServerRequestInterface $request,
|
||||
ResponseInterface $response,
|
||||
array $args
|
||||
): ResponseInterface {
|
||||
$contentType = $request->getHeader("Content-Type");
|
||||
switch ($contentType[0]) {
|
||||
case "application/json":
|
||||
$body = json_decode(file_get_contents("php://input"), true);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
switch (isset($args["third"]) ? $args["third"] : "none") {
|
||||
case "restore":
|
||||
case "init":
|
||||
$task = $args["third"];
|
||||
$result = InitApi::handleInitTasks(
|
||||
$task,
|
||||
$task == "init" ? $body : $request
|
||||
);
|
||||
break;
|
||||
case "backup":
|
||||
$token = $request->getHeader("fipamo-access-token");
|
||||
//Verify token for admin tasks
|
||||
if (Session::verifyToken($token[0])) {
|
||||
$result = SettingsAPI::createBackup();
|
||||
} else {
|
||||
$result = [
|
||||
"message" => "API access denied, homie",
|
||||
"type" => "API_ERROR",
|
||||
];
|
||||
}
|
||||
break;
|
||||
case "login":
|
||||
$result = AuthAPI::login($body);
|
||||
break;
|
||||
case "logout":
|
||||
$result = AuthAPI::logout($body);
|
||||
break;
|
||||
case "page":
|
||||
$token = $request->getHeader("fipamo-access-token");
|
||||
//Verify token for admin tasks
|
||||
if (Session::verifyToken($token[0])) {
|
||||
$result = PagesAPI::handlePageTask($request, $args);
|
||||
} else {
|
||||
$result = [
|
||||
"message" => "API access denied, homie",
|
||||
"type" => "API_ERROR",
|
||||
];
|
||||
}
|
||||
break;
|
||||
case "settings":
|
||||
$token = $request->getHeader("fipamo-access-token");
|
||||
if (Session::verifyToken($token[0])) {
|
||||
if (isset($body)) {
|
||||
$postBody = $body;
|
||||
} else {
|
||||
$postBody = null;
|
||||
}
|
||||
|
||||
$result = SettingsAPI::handleSettingsTask($request, $args, $postBody);
|
||||
} else {
|
||||
$result = [
|
||||
"message" => "API access denied, homie",
|
||||
"type" => "API_ERROR",
|
||||
];
|
||||
}
|
||||
break;
|
||||
default:
|
||||
$result = [
|
||||
"message" => "Oh, nothing to do. That's unfortunate",
|
||||
"type" => "TASK_NONE",
|
||||
];
|
||||
break;
|
||||
}
|
||||
|
||||
$response->getBody()->write(json_encode($result));
|
||||
return $response->withHeader("Content-Type", "application/json");
|
||||
}
|
||||
}
|
@ -0,0 +1,250 @@
|
||||
<?php
|
||||
|
||||
namespace brain\controller;
|
||||
|
||||
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;
|
||||
use brain\data\Member;
|
||||
use brain\data\Session;
|
||||
|
||||
class APIControl
|
||||
{
|
||||
public static function get(
|
||||
ServerRequestInterface $request,
|
||||
ResponseInterface $response,
|
||||
array $args
|
||||
): ResponseInterface {
|
||||
$filename = '';
|
||||
switch (isset($args['third']) ? $args['third'] : 'none') {
|
||||
case 'status':
|
||||
$result = AuthAPI::status();
|
||||
|
||||
break;
|
||||
case 'page':
|
||||
//echo
|
||||
if (Member::verifyKey($_GET['key'])) {
|
||||
$result = PagesAPI::getPageContent($request, $args);
|
||||
} else {
|
||||
$result = [
|
||||
'message' => 'API access denied, homie',
|
||||
'type' => 'API_ERROR',
|
||||
];
|
||||
}
|
||||
break;
|
||||
case 'settings':
|
||||
$token = $request->getHeader('fipamo-access-token');
|
||||
//Verify token to get site info
|
||||
if (isset($token[0])) {
|
||||
if (Session::verifyToken($token[0])) {
|
||||
$result = SettingsAPI::getInfo($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 'files':
|
||||
if (Session::active()) {
|
||||
if ($args['third'] == 'backup') {
|
||||
$filename = '../config/backups/latest_backup.zip';
|
||||
if (file_exists($filename)) {
|
||||
header('Content-Type: application/zip');
|
||||
header(
|
||||
'Content-Disposition: attachment; filename="' .
|
||||
basename($filename) .
|
||||
'"'
|
||||
);
|
||||
header('Content-Length: ' . filesize($filename));
|
||||
|
||||
flush();
|
||||
// return readfile($filename);
|
||||
//readfile($filename);
|
||||
// delete file
|
||||
//unlink($filename);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
$result = [
|
||||
'message' => 'API access denied, homie',
|
||||
'type' => 'API_ERROR',
|
||||
];
|
||||
}
|
||||
// no break
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
$freshResponse = $response;
|
||||
|
||||
if ($args['third'] == 'files') {
|
||||
$freshResponse
|
||||
->getBody()
|
||||
->write(file_get_contents('../config/backups/latest_back.zip'));
|
||||
|
||||
$freshResponse->withHeader('Content-Type', 'application/zip');
|
||||
return $freshResponse->withAddedHeader(
|
||||
'Content-Disposition',
|
||||
'attachment; filename=latest_backup.zip'
|
||||
);
|
||||
} else {
|
||||
$response->getBody()->write(json_encode($result));
|
||||
return $response->withHeader('Content-Type', 'application/json');
|
||||
}
|
||||
}
|
||||
|
||||
public static function post(
|
||||
ServerRequestInterface $request,
|
||||
ResponseInterface $response,
|
||||
array $args
|
||||
): ResponseInterface {
|
||||
$contentType = $request->getHeader('Content-Type');
|
||||
switch ($contentType[0]) {
|
||||
case 'application/json':
|
||||
$body = json_decode(file_get_contents('php://input'), true);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
switch (isset($args['third']) ? $args['third'] : 'none') {
|
||||
case 'restore': //move to 'api/auth'
|
||||
case 'init': //move to 'api/auth'
|
||||
$task = $args['third'];
|
||||
$result = InitApi::handleInitTasks(
|
||||
$task,
|
||||
$task == 'init' ? $body : $request
|
||||
);
|
||||
break;
|
||||
case 'backup': //move to 'api/auth'
|
||||
$token = $request->getHeader('fipamo-access-token');
|
||||
//Verify token for admin tasks
|
||||
$result = SettingsAPI::createBackup();
|
||||
/*
|
||||
|
||||
if (Session::verifyToken($token[0])) {
|
||||
$result = SettingsAPI::createBackup();
|
||||
} else {
|
||||
$result = [
|
||||
"message" => "API access denied, homie",
|
||||
"type" => "API_ERROR",
|
||||
];
|
||||
}
|
||||
*/
|
||||
break;
|
||||
case 'login': //move to 'api/auth'
|
||||
//check if request is remote and if so, verify token
|
||||
if ($body['remote'] || $body['remote'] == 'true') {
|
||||
if (Member::verifyKey($body['key'])) {
|
||||
$result = AuthAPI::login($body);
|
||||
} else {
|
||||
$result = [
|
||||
'message' => 'API access denied, homie',
|
||||
'type' => 'API_ERROR',
|
||||
];
|
||||
}
|
||||
} else {
|
||||
//request is local, so it's cool
|
||||
$result = AuthAPI::login($body);
|
||||
}
|
||||
|
||||
break;
|
||||
case 'logout': //move to 'api/auth'
|
||||
$result = AuthAPI::logout($body);
|
||||
break;
|
||||
case 'get-secret': //move to 'api/auth'
|
||||
$result = AuthAPI::requestSecret($body);
|
||||
break;
|
||||
case 'reset-password': //move to 'api/auth'
|
||||
$result = AuthAPI::resetPassword($body);
|
||||
break;
|
||||
case 'page':
|
||||
$token = $request->getHeader('fipamo-access-token');
|
||||
//Verify token for admin tasks
|
||||
if (isset($token[0])) {
|
||||
if (Session::verifyToken($token[0])) {
|
||||
$result = PagesAPI::handlePageTask($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 "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)) {
|
||||
$postBody = $body;
|
||||
} else {
|
||||
$postBody = null;
|
||||
}
|
||||
$task = $args['fourth'];
|
||||
if ($task == 'add-feature-background' || $task == 'add-avatar') {
|
||||
$result = SettingsAPI::handleSettingsTask($request, $args, $postBody);
|
||||
} else {
|
||||
$token = $request->getHeader('fipamo-access-token');
|
||||
if (Session::verifyToken($token[0])) {
|
||||
$result = SettingsAPI::handleSettingsTask(
|
||||
$request,
|
||||
$args,
|
||||
$postBody
|
||||
);
|
||||
} else {
|
||||
$result = [
|
||||
'message' => 'API access denied, homie',
|
||||
'type' => 'API_ERROR',
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
break;
|
||||
case 'mailer':
|
||||
$result = MailerAPI::handleMail($request, $body, $response);
|
||||
break;
|
||||
default:
|
||||
$result = [
|
||||
'message' => "Oh, nothing to do. That's unfortunate",
|
||||
'type' => 'TASK_NONE',
|
||||
];
|
||||
break;
|
||||
}
|
||||
$response->getBody()->write(json_encode($result));
|
||||
return $response->withHeader('Content-Type', 'application/json');
|
||||
}
|
||||
}
|
@ -1,144 +0,0 @@
|
||||
<?php
|
||||
use Psr\Http\Message\ResponseInterface;
|
||||
use Psr\Http\Message\ServerRequestInterface;
|
||||
use Slim\Views\Twig;
|
||||
|
||||
include "../brain/data/Book.inc.php";
|
||||
|
||||
class DashControl
|
||||
{
|
||||
public static function start(
|
||||
ServerRequestInterface $request,
|
||||
ResponseInterface $response,
|
||||
array $args
|
||||
): ResponseInterface {
|
||||
$view = Twig::fromRequest($request);
|
||||
$pageOptions = [];
|
||||
$template = "";
|
||||
if (Setup::status()) {
|
||||
switch (isset($args["second"]) ? $args["second"] : "index") {
|
||||
case "settings":
|
||||
if (Session::active()) {
|
||||
$config = new Settings();
|
||||
$settings = $config->getSettings();
|
||||
$themes = $config->getThemes();
|
||||
$template = "dash/settings.twig";
|
||||
$member = Session::get("member");
|
||||
$updated = new \Moment\Moment($settings["global"]["last_backup"]);
|
||||
$pageOptions = [
|
||||
"title" => "Dash Settings",
|
||||
"private" => $settings["global"]["private"],
|
||||
"render" => $settings["global"]["renderOnSave"],
|
||||
"background" => $settings["global"]["background"],
|
||||
"member" => $member,
|
||||
"siteTitle" => $settings["global"]["title"],
|
||||
"baseUrl" => $settings["global"]["base_url"],
|
||||
"desc" => $settings["global"]["descriptions"],
|
||||
"lastBackup" => $updated->format("Y M D d"),
|
||||
"currentTheme" => $settings["global"]["theme"],
|
||||
"themes" => $themes,
|
||||
"mailOption" => $settings["email"]["active"],
|
||||
"status" => Session::active(),
|
||||
];
|
||||
} else {
|
||||
header("Location: /dashboard");
|
||||
die();
|
||||
}
|
||||
|
||||
break;
|
||||
case "navigation":
|
||||
if (Session::active()) {
|
||||
$config = new Settings();
|
||||
$settings = $config->getSettings();
|
||||
$template = "dash/navigation.twig";
|
||||
$pageOptions = [
|
||||
"title" => "Edit Dash Navigation",
|
||||
"status" => Session::active(),
|
||||
"menu" => $settings["menu"],
|
||||
];
|
||||
} else {
|
||||
header("Location: /dashboard");
|
||||
die();
|
||||
}
|
||||
break;
|
||||
case "pages":
|
||||
if (Session::active()) {
|
||||
$currentPage = isset($args["fourth"]) ? $args["fourth"] : 1;
|
||||
$filter = isset($args["third"]) ? $args["third"] : "all";
|
||||
$data = (new Book("../content/pages"))->getPages(
|
||||
$currentPage,
|
||||
4,
|
||||
$filter
|
||||
);
|
||||
$template = "dash/book.twig";
|
||||
$pageOptions = [
|
||||
"entryCount" => $data["entryCount"],
|
||||
"numOfPages" => $data["numOfPages"],
|
||||
"currentPage" => $currentPage,
|
||||
"filter" => $data["paginate"]["sort"],
|
||||
"stats" => $data["stats"],
|
||||
"pages" => $data["pages"],
|
||||
"paginate" => $data["paginate"],
|
||||
"status" => Session::active(),
|
||||
];
|
||||
} else {
|
||||
header("Location: /dashboard");
|
||||
die();
|
||||
}
|
||||
break;
|
||||
case "page":
|
||||
if (Session::active()) {
|
||||
$template = "dash/page-edit.twig";
|
||||
$mode = $args["third"];
|
||||
if ($mode == "edit") {
|
||||
$uuid = $args["fourth"];
|
||||
|
||||
$pageOptions = [
|
||||
"title" => "Fipamo | Edit Page",
|
||||
"page" => (new Book("../content/pages"))->findPageById($uuid),
|
||||
"mode" => $mode,
|
||||
"status" => Session::active(),
|
||||
];
|
||||
} else {
|
||||
$pageOptions = [
|
||||
"title" => "Fipamo | Create Page",
|
||||
"mode" => $mode,
|
||||
"status" => Session::active(),
|
||||
];
|
||||
}
|
||||
} else {
|
||||
header("Location: /dashboard");
|
||||
die();
|
||||
}
|
||||
break;
|
||||
case "logout":
|
||||
Session::kill();
|
||||
header("Location: /dashboard");
|
||||
die();
|
||||
break;
|
||||
|
||||
default:
|
||||
//$secret = ;
|
||||
$template = "dash/start.twig";
|
||||
if (Session::active()) {
|
||||
$pageOptions = [
|
||||
"title" => "Welcome Back",
|
||||
"status" => Session::active(),
|
||||
"data" => (new Book("../content/pages"))->getPages(1, 4),
|
||||
];
|
||||
} else {
|
||||
$pageOptions = [
|
||||
"title" => "Welcome to Fipamo",
|
||||
"status" => Session::active(),
|
||||
];
|
||||
}
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
$template = "dash/init.twig";
|
||||
$pageOptions = ["title" => "Fipamo Setup"];
|
||||
}
|
||||
|
||||
return $view->render($response, $template, $pageOptions);
|
||||
}
|
||||
}
|
@ -0,0 +1,226 @@
|
||||
<?php
|
||||
|
||||
namespace brain\controller;
|
||||
|
||||
use brain\data\Book;
|
||||
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;
|
||||
|
||||
class DashControl
|
||||
{
|
||||
public static function start(
|
||||
ServerRequestInterface $request,
|
||||
ResponseInterface $response,
|
||||
array $args
|
||||
): ResponseInterface {
|
||||
$view = Twig::fromRequest($request);
|
||||
$pageOptions = [];
|
||||
$template = '';
|
||||
if (Setup::status()) {
|
||||
switch (isset($args['second']) ? $args['second'] : 'index') {
|
||||
case 'settings':
|
||||
if (Session::active()) {
|
||||
$config = new Settings();
|
||||
$settings = $config->getSettings();
|
||||
$themes = (new Themes())->getThemes(); // $config->getThemes();
|
||||
$template = 'dash/settings.twig';
|
||||
$member = Session::get('member');
|
||||
$form_token = Session::get('form_token');
|
||||
$updated = new Carbon($settings['global']['last_backup']);
|
||||
$pageOptions = [
|
||||
'title' => 'Settings',
|
||||
'private' => $settings['global']['private'],
|
||||
'renderOnSave' => $settings['global']['renderOnSave'],
|
||||
'background' => $settings['global']['background'],
|
||||
'member' => $member,
|
||||
'ftoken' => $form_token,
|
||||
'siteTitle' => $settings['global']['title'],
|
||||
'baseUrl' => $settings['global']['base_url'],
|
||||
'desc' => $settings['global']['descriptions'],
|
||||
'lastBackup' => $updated->format('Y M D d'),
|
||||
'currentTheme' => $settings['global']['theme'],
|
||||
'themes' => $themes,
|
||||
'apiStatus' => isset($settings['global']['externalAPI'])
|
||||
? $settings['global']['externalAPI']
|
||||
: 'false',
|
||||
'dynamicRenderStatus' => isset(
|
||||
$settings['global']['dynamicRender']
|
||||
)
|
||||
? $settings['global']['dynamicRender']
|
||||
: 'false',
|
||||
'mailOption' => $settings['email']['active'],
|
||||
'mailConfig' => $settings['email'],
|
||||
'status' => Session::active(),
|
||||
];
|
||||
} else {
|
||||
header('Location: /dashboard');
|
||||
exit();
|
||||
}
|
||||
|
||||
break;
|
||||
case 'navigation':
|
||||
if (Session::active()) {
|
||||
$config = new Settings();
|
||||
$settings = $config->getSettings();
|
||||
$template = 'dash/navigation.twig';
|
||||
$pageOptions = [
|
||||
'title' => 'Edit Menu',
|
||||
'status' => Session::active(),
|
||||
'menu' => $settings['menu'],
|
||||
];
|
||||
} else {
|
||||
header('Location: /dashboard');
|
||||
exit();
|
||||
}
|
||||
break;
|
||||
case 'pages':
|
||||
if (Session::active()) {
|
||||
$currentPage = isset($args['fourth']) ? $args['fourth'] : 1;
|
||||
$filter = isset($args['third']) ? $args['third'] : 'all';
|
||||
$data = (new Book())->getPages($currentPage, 4, $filter);
|
||||
$template = 'dash/book.twig';
|
||||
$pageOptions = [
|
||||
'title' => 'Contents',
|
||||
'entryCount' => $data['entryCount'],
|
||||
'numOfPages' => $data['numOfPages'],
|
||||
'currentPage' => $currentPage,
|
||||
'filter' => $data['paginate']['sort'],
|
||||
'stats' => $data['stats'],
|
||||
'pages' => $data['pages'],
|
||||
'paginate' => $data['paginate'],
|
||||
'status' => Session::active(),
|
||||
];
|
||||
} else {
|
||||
header('Location: /dashboard');
|
||||
exit();
|
||||
}
|
||||
break;
|
||||
case 'page':
|
||||
if (Session::active()) {
|
||||
$template = 'dash/page-edit.twig';
|
||||
$mode = $args['third'];
|
||||
$uuid = $args['fourth'];
|
||||
|
||||
switch ($mode) {
|
||||
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 {
|
||||
$views = (new Themes())->getCustomViews();
|
||||
}
|
||||
$imageList = [];
|
||||
$fileList = [];
|
||||
if (isset($page['feature'])) {
|
||||
$imageList = explode(',', $page['feature']);
|
||||
}
|
||||
if (isset($page['files'])) {
|
||||
$fileList = explode(',', $page['files']);
|
||||
}
|
||||
|
||||
$images = [];
|
||||
$files = [];
|
||||
foreach ($imageList as $item) {
|
||||
$image = trim($item);
|
||||
if (!empty($image)) {
|
||||
array_push($images, $image);
|
||||
}
|
||||
}
|
||||
|
||||
foreach ($fileList as $item) {
|
||||
$file = trim($item);
|
||||
if (!empty($file)) {
|
||||
array_push($files, $file);
|
||||
}
|
||||
}
|
||||
|
||||
$pageOptions = [
|
||||
'title' => $page['title'],
|
||||
'page' => $page,
|
||||
'mode' => $mode,
|
||||
'token' => Session::get('form_token'),
|
||||
'status' => Session::active(),
|
||||
'images' => $images,
|
||||
'files' => $files,
|
||||
'views' => $views,
|
||||
];
|
||||
break;
|
||||
case 'preview':
|
||||
$config = new Settings();
|
||||
$settings = $config->getSettings();
|
||||
$loader = new \Twig\Loader\FilesystemLoader(
|
||||
'../content/themes/' . $settings['global']['theme'] .
|
||||
'/'
|
||||
);
|
||||
$display = new \Twig\Environment($loader, []);
|
||||
|
||||
$book = new Book();
|
||||
$page = $book->findPageById($uuid);
|
||||
$pageOptions = Sorting::page($page);
|
||||
$preview = $page['layout'] .
|
||||
'.twig';
|
||||
$html = $display->render($preview, $pageOptions);
|
||||
$response->getBody()->write($html);
|
||||
|
||||
return $response;
|
||||
break;
|
||||
default:
|
||||
$pageOptions = [
|
||||
'title' => 'Fipamo | Create Page',
|
||||
'token' => Session::get('form_token'),
|
||||
'mode' => $mode,
|
||||
'status' => Session::active(),
|
||||
];
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
header('Location: /dashboard');
|
||||
exit();
|
||||
}
|
||||
break;
|
||||
case 'logout':
|
||||
Session::kill();
|
||||
header('Location: /dashboard');
|
||||
exit();
|
||||
break;
|
||||
case 'reset-password':
|
||||
$template = 'dash/reset-password.twig';
|
||||
$pageOptions = [
|
||||
'title' => 'Reset Password',
|
||||
];
|
||||
break;
|
||||
default:
|
||||
$template = 'dash/start.twig';
|
||||
if (Session::active()) {
|
||||
$pageOptions = [
|
||||
'title' => 'Start',
|
||||
'status' => Session::active(),
|
||||
'data' => (new Book())->getPages(1, 4),
|
||||
];
|
||||
} else {
|
||||
$pageOptions = [
|
||||
'title' => 'Welcome to Fipamo',
|
||||
'status' => Session::active(),
|
||||
];
|
||||
}
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
$template = 'dash/init.twig';
|
||||
$pageOptions = ['title' => 'Fipamo Setup'];
|
||||
}
|
||||
|
||||
return $view->render($response, $template, $pageOptions);
|
||||
}
|
||||
}
|
@ -1,19 +0,0 @@
|
||||
<?php
|
||||
use Psr\Http\Message\ResponseInterface;
|
||||
use Psr\Http\Message\ServerRequestInterface;
|
||||
use Slim\Views\Twig;
|
||||
|
||||
class IndexControl
|
||||
{
|
||||
public static function start(
|
||||
ServerRequestInterface $request,
|
||||
ResponseInterface $response,
|
||||
array $args
|
||||
): ResponseInterface {
|
||||
//unset($_SESSION);
|
||||
$view = Twig::fromRequest($request);
|
||||
$html = file_get_contents("../public/index.html");
|
||||
$response->getBody()->write($html);
|
||||
return $response;
|
||||
}
|
||||
}
|
@ -0,0 +1,110 @@
|
||||
<?php
|
||||
|
||||
namespace brain\controller;
|
||||
|
||||
use Psr\Http\Message\ResponseInterface;
|
||||
use Psr\Http\Message\ServerRequestInterface;
|
||||
use Slim\Views\Twig;
|
||||
use brain\data\Settings;
|
||||
use brain\utility\Sorting;
|
||||
|
||||
use function _\find;
|
||||
|
||||
class IndexControl
|
||||
{
|
||||
public static function start(
|
||||
ServerRequestInterface $request,
|
||||
ResponseInterface $response,
|
||||
array $args
|
||||
): ResponseInterface {
|
||||
//unset($_SESSION);
|
||||
$config = new Settings();
|
||||
$settings = $config->getSettings();
|
||||
$view = Twig::fromRequest($request);
|
||||
//checks dynamic render flag for site render status
|
||||
if ($settings['global']['dynamicRender']) {
|
||||
if ($settings['global']['dynamicRender'] == 'true') {
|
||||
$loader = new \Twig\Loader\FilesystemLoader('../content/themes');
|
||||
$display = new \Twig\Environment($loader, []);
|
||||
$template = '';
|
||||
$pageOptions = [];
|
||||
|
||||
$pageInfo = [
|
||||
'keywords' => isset($settings['global']['keywords'])
|
||||
? $settings['global']['keywords']
|
||||
: 'fipamo, blog, jamstack, php, markdown, js',
|
||||
'description' => $settings['global']['descriptions'],
|
||||
'image' => $settings['global']['base_url'] . $settings['global']['background'],
|
||||
'baseURL' => $settings['global']['base_url'],
|
||||
];
|
||||
|
||||
if (isset($args['first'])) {
|
||||
switch ($args['first']) {
|
||||
case 'tags':
|
||||
$template = $settings['global']['theme'] . '/tags.twig';
|
||||
$tag = trim($args['second']);
|
||||
$taglist = Sorting::tags();
|
||||
$item = find($taglist, ['tag_name' => $tag]);
|
||||
$pageOptions = [
|
||||
'title' => 'Pages Tagged as ' . $item['tag_name'],
|
||||
'background' => $pageInfo['image'],
|
||||
'tag_list' => $item['pages'],
|
||||
'info' => $pageInfo,
|
||||
'menu' => $settings['menu'],
|
||||
'dynamicRender' => $settings['global']['dynamicRender'],
|
||||
];
|
||||
break;
|
||||
case 'archives':
|
||||
$archive = Sorting::archive();
|
||||
$template = $settings['global']['theme'] . '/archive.twig';
|
||||
$pageOptions = [
|
||||
'title' => 'Archive',
|
||||
'background' => $pageInfo['image'],
|
||||
'archives' => $archive,
|
||||
'info' => $pageInfo,
|
||||
'menu' => $settings['menu'],
|
||||
'dynamicRender' => $settings['global']['dynamicRender'],
|
||||
];
|
||||
|
||||
break;
|
||||
default:
|
||||
//check if page is a menu item, if not render along path as usual
|
||||
$page = [];
|
||||
$book = new Book();
|
||||
if (is_numeric($args['first'])) {
|
||||
$page = $book->findPageBySlug($args['third']);
|
||||
} else {
|
||||
$page = $book->findPageBySlug($args['first']);
|
||||
}
|
||||
$template = $settings['global']['theme'] . '/' . $page['layout'] . '.twig';
|
||||
$pageOptions = Sorting::page($page);
|
||||
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
//index
|
||||
$template = $settings['global']['theme'] . '/' . $page['layout'] . '.twig';
|
||||
$book = new Book('');
|
||||
$page = $book->findPageBySlug();
|
||||
$pageOptions = Sorting::page($page);
|
||||
}
|
||||
|
||||
$html = $display->render($template, $pageOptions);
|
||||
$response->getBody()->write($html);
|
||||
return $response;
|
||||
} else {
|
||||
//if dynamic flag is false, load up html
|
||||
$view = Twig::fromRequest($request);
|
||||
$html = file_get_contents('../public/index.html');
|
||||
$response->getBody()->write($html);
|
||||
return $response;
|
||||
}
|
||||
} else {
|
||||
//if flag is not present, default to static html
|
||||
$view = Twig::fromRequest($request);
|
||||
$html = file_get_contents('../public/index.html');
|
||||
$response->getBody()->write($html);
|
||||
return $response;
|
||||
}
|
||||
}
|
||||
}
|
@ -1,44 +0,0 @@
|
||||
<?php
|
||||
use Psr\Http\Message\ResponseInterface;
|
||||
use Psr\Http\Message\ServerRequestInterface;
|
||||
|
||||
include "../brain/controller/IndexControl.inc.php";
|
||||
include "../brain/controller/DashControl.inc.php";
|
||||
include "../brain/controller/APIControl.inc.php";
|
||||
|
||||
class RouteControl
|
||||
{
|
||||
public function get(
|
||||
ServerRequestInterface $request,
|
||||
ResponseInterface $response,
|
||||
array $args
|
||||
): ResponseInterface {
|
||||
switch (isset($args["first"]) ? $args["first"] : "index") {
|
||||
case "dashboard":
|
||||
return DashControl::start($request, $response, $args);
|
||||
break;
|
||||
case "api":
|
||||
return APIControl::get($request, $response, $args);
|
||||
break;
|
||||
default:
|
||||
return IndexControl::start($request, $response, $args);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
public function post(
|
||||
ServerRequestInterface $request,
|
||||
ResponseInterface $response,
|
||||
array $args
|
||||
): ResponseInterface {
|
||||
switch (isset($args["first"]) ? $args["first"] : "index") {
|
||||
case "api":
|
||||
return APIControl::post($request, $response, $args);
|
||||
break;
|
||||
default:
|
||||
//echo "YES";
|
||||
//return IndexControl::start($request, $response, $args);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,47 @@
|
||||
<?php
|
||||
|
||||
namespace brain\controller;
|
||||
|
||||
use Psr\Http\Message\ResponseInterface;
|
||||
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,
|
||||
array $args
|
||||
): ResponseInterface {
|
||||
switch (isset($args['first']) ? $args['first'] : 'index') {
|
||||
case 'dashboard':
|
||||
return DashControl::start($request, $response, $args);
|
||||
break;
|
||||
case 'api':
|
||||
return APIControl::get($request, $response, $args);
|
||||
break;
|
||||
default:
|
||||
return IndexControl::start($request, $response, $args);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
public function post(
|
||||
ServerRequestInterface $request,
|
||||
ResponseInterface $response,
|
||||
array $args
|
||||
): ResponseInterface {
|
||||
switch (isset($args['first']) ? $args['first'] : 'index') {
|
||||
case 'api':
|
||||
return APIControl::post($request, $response, $args);
|
||||
break;
|
||||
default:
|
||||
$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');
|
||||
}
|
||||
}
|
||||
}
|
@ -1,74 +0,0 @@
|
||||
<?php
|
||||
|
||||
use function _\find;
|
||||
use ReallySimpleJWT\Token;
|
||||
|
||||
class Auth
|
||||
{
|
||||
public function __construct()
|
||||
{
|
||||
}
|
||||
|
||||
public static function sessionStatus()
|
||||
{
|
||||
if (isset($_SESSION["member"])) {
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
//return $this->secret;
|
||||
}
|
||||
|
||||
public static function status()
|
||||
{
|
||||
$result = "";
|
||||
if (Session::active()) {
|
||||
$result = true;
|
||||
} else {
|
||||
$result = false;
|
||||
}
|
||||
return $result;
|
||||
}
|
||||
|
||||
public static function login($who)
|
||||
{
|
||||
//grab member list
|
||||
$folks = (new Settings())->getFolks();
|
||||
$found = find($folks, ["handle" => $who["handle"]]);
|
||||
|
||||
if ($found) {
|
||||
//name is found, verify password
|
||||
if (password_verify($who["password"], $found["password"])) {
|
||||
$member = [
|
||||
"handle" => $found["handle"],
|
||||
"email" => $found["email"],
|
||||
"role" => $found["role"],
|
||||
"avatar" => $found["avi"],
|
||||
];
|
||||
|
||||
$token = Token::create(
|
||||
$found["id"],
|
||||
$found["secret"],
|
||||
time() + 3600,
|
||||
"localhost"
|
||||
); //expires in an hour
|
||||
Session::start();
|
||||
Session::set("member", $member);
|
||||
Session::set("token", $token);
|
||||
|
||||
$result = "good_login";
|
||||
} else {
|
||||
$result = "bad_pass";
|
||||
}
|
||||
} else {
|
||||
//if name is not found
|
||||
$result = "no_name";
|
||||
}
|
||||
return $result;
|
||||
}
|
||||
|
||||
public static function logout()
|
||||
{
|
||||
Session::kill();
|
||||
}
|
||||
}
|
@ -0,0 +1,154 @@
|
||||
<?php
|
||||
|
||||
namespace brain\data;
|
||||
|
||||
use ReallySimpleJWT\Token;
|
||||
|
||||
use function _\find;
|
||||
|
||||
class Auth
|
||||
{
|
||||
public function __construct()
|
||||
{
|
||||
}
|
||||
|
||||
public static function sessionStatus()
|
||||
{
|
||||
if (isset($_SESSION['member'])) {
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
//return $this->secret;
|
||||
}
|
||||
|
||||
public static function status()
|
||||
{
|
||||
$result = '';
|
||||
if (Session::active()) {
|
||||
$result = true;
|
||||
} else {
|
||||
$result = false;
|
||||
}
|
||||
return $result;
|
||||
}
|
||||
|
||||
public static function login($who)
|
||||
{
|
||||
//grab member list
|
||||
$folks = (new Settings())->getFolks();
|
||||
$found = find($folks, ['handle' => $who['handle']]);
|
||||
|
||||
if ($found) {
|
||||
//name is found, verify password
|
||||
if (password_verify($who['password'], $found['password'])) {
|
||||
$member = [
|
||||
'handle' => $found['handle'],
|
||||
'email' => $found['email'],
|
||||
'role' => $found['role'],
|
||||
'avatar' => $found['avi'],
|
||||
'key' => $found['key'],
|
||||
];
|
||||
|
||||
$token = Token::create(
|
||||
$found['key'],
|
||||
$found['secret'],
|
||||
time() + 3600,
|
||||
'localhost'
|
||||
); //expires in an hour
|
||||
|
||||
$form_token = md5(uniqid(microtime(), true));
|
||||
Session::start();
|
||||
Session::set('member', $member);
|
||||
Session::set('token', $token);
|
||||
Session::set('form_token', $form_token);
|
||||
|
||||
$result = 'good_login';
|
||||
} else {
|
||||
$result = 'bad_pass';
|
||||
}
|
||||
} else {
|
||||
//if name is not found
|
||||
$result = 'no_name';
|
||||
}
|
||||
return $result;
|
||||
}
|
||||
|
||||
public static function findSecret($data)
|
||||
{
|
||||
$result = [];
|
||||
$folks = (new Settings())->getFolks();
|
||||
|
||||
if (!empty($data['email']) && filter_var($data['email'], FILTER_VALIDATE_EMAIL)) {
|
||||
$found = find($folks, ['email' => $data['email']]);
|
||||
if ($found) {
|
||||
//if email is cool, check mail relay status
|
||||
//if set up, send secret there, if not just return it
|
||||
$config = new Settings();
|
||||
$settings = $config->getSettings();
|
||||
$email = $settings['email']['active'];
|
||||
if ($email != 'option-none') {
|
||||
$data['mail_task'] = 'SEND_SECRET';
|
||||
$data['secret'] = $found['secret'];
|
||||
$result = Mailer::sendmail($data);
|
||||
} else {
|
||||
$result = [
|
||||
'message' => 'Valid email, but no email set up!',
|
||||
'type' => 'secretFound',
|
||||
'secret' => $found['secret'],
|
||||
];
|
||||
}
|
||||
} else {
|
||||
$result = [
|
||||
'message' => 'No valid email, no goodies, pleighboi',
|
||||
'type' => 'secretNotFound',
|
||||
];
|
||||
}
|
||||
} else {
|
||||
$result = [
|
||||
'message' => 'Aye, this address is not right, slick.',
|
||||
'type' => 'secretNotFound',
|
||||
];
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
public static function makeNewPassword($data)
|
||||
{
|
||||
//check if passwordsmatch
|
||||
if ($data['newPass'] == $data['newPassConfirm']) {
|
||||
//verify secret
|
||||
$folks = (new Settings())->getFolks();
|
||||
$found = find($folks, ['secret' => $data['secret']]);
|
||||
if ($found) {
|
||||
//create new pass and secret key, then update file
|
||||
$hash = password_hash($data['newPass'], PASSWORD_DEFAULT);
|
||||
$freshSecret = StringTools::randomString(12);
|
||||
Member::updateData('password', $hash, $data['secret']);
|
||||
Member::updateData('secret', $freshSecret, $data['secret']);
|
||||
$result = [
|
||||
'message' => 'Password Updated. Very nice!',
|
||||
'type' => 'passCreated',
|
||||
];
|
||||
} else {
|
||||
$result = [
|
||||
'message' => 'Secret key is invalid. Try to retrieve it again',
|
||||
'type' => 'passNotCreated',
|
||||
];
|
||||
}
|
||||
} else {
|
||||
$result = [
|
||||
'message' => "Passwords don't match. Try it again.",
|
||||
'type' => 'passNotCreated',
|
||||
];
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
public static function logout()
|
||||
{
|
||||
Session::kill();
|
||||
}
|
||||
}
|
@ -1,290 +0,0 @@
|
||||
<?php
|
||||
|
||||
use Mni\FrontYAML\Parser;
|
||||
use function _\orderBy;
|
||||
use function _\filter;
|
||||
use function _\find;
|
||||
|
||||
class Book
|
||||
{
|
||||
public $files = [];
|
||||
|
||||
public function __construct($folder)
|
||||
{
|
||||
$this->read($folder);
|
||||
}
|
||||
public function read($folder)
|
||||
{
|
||||
$folders = glob("$folder/*", GLOB_ONLYDIR);
|
||||
foreach ($folders as $folder) {
|
||||
//$this->files[] = $folder . "/";
|
||||
$this->read($folder);
|
||||
}
|
||||
$files = array_filter(glob("$folder/*md"), "is_file");
|
||||
foreach ($files as $file) {
|
||||
$this->files[] = $file;
|
||||
}
|
||||
}
|
||||
|
||||
public function findPageById(string $uuid)
|
||||
{
|
||||
$content = $this->getContents();
|
||||
$page = find($content, ["uuid" => $uuid]);
|
||||
return $page;
|
||||
}
|
||||
|
||||
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"]]);
|
||||
} else {
|
||||
$body = $request->getParsedBody();
|
||||
}
|
||||
|
||||
$page = find($content, ["uuid" => $body["uuid"]]);
|
||||
$image = $request->getUploadedFiles();
|
||||
$member = Session::get("member");
|
||||
|
||||
if ($task != "create") {
|
||||
$path =
|
||||
date("Y", date($page["rawCreated"])) .
|
||||
"/" .
|
||||
date("m", date($page["rawCreated"]));
|
||||
} else {
|
||||
$path = date("Y") . "/" . date("m");
|
||||
}
|
||||
|
||||
if (isset($image["feature_image"])) {
|
||||
if ($task != "create") {
|
||||
$feature =
|
||||
"/assets/images/blog/" .
|
||||
$path .
|
||||
"/" .
|
||||
$image["feature_image"]->getClientFileName();
|
||||
} else {
|
||||
$feature =
|
||||
"/assets/images/blog/" .
|
||||
$path .
|
||||
"/" .
|
||||
$image["feature_image"]->getClientFileName();
|
||||
}
|
||||
|
||||
FileUploader::uploadFile(
|
||||
"../public/assets/images/blog/" . $path . "/",
|
||||
$image["feature_image"]
|
||||
);
|
||||
} else {
|
||||
if (isset($body["feature_image"])) {
|
||||
$url = explode("/", $body["feature_image"]);
|
||||
$feature =
|
||||
"/" .
|
||||
$url[3] .
|
||||
"/" .
|
||||
$url[4] .
|
||||
"/" .
|
||||
$url[5] .
|
||||
"/" .
|
||||
$url[6] .
|
||||
"/" .
|
||||
$url[7] .
|
||||
"/" .
|
||||
$url[8];
|
||||
} else {
|
||||
$feature = $body["feature"];
|
||||
}
|
||||
}
|
||||
|
||||
if ($task == "delete") {
|
||||
$deleted = "true";
|
||||
$body["menu"] ? ($body["menu"] = "true") : ($body["menu"] = "false");
|
||||
$body["published"]
|
||||
? ($body["published"] = "true")
|
||||
: ($body["published"] = "false");
|
||||
$body["featured"]
|
||||
? ($body["featured"] = "true")
|
||||
: ($body["featured"] = "false");
|
||||
} else {
|
||||
$deleted = isset($page["deleted"]) ? $page["deleted"] : "false";
|
||||
}
|
||||
|
||||
$created =
|
||||
$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();
|
||||
// now that variables are done, set to body object and then convert to markdown to save
|
||||
|
||||
$body["id"] = $id;
|
||||
$body["uuid"] = $uuid;
|
||||
$body["feature"] = $feature;
|
||||
$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";
|
||||
} else {
|
||||
$writePath = "../content/pages/" . $path . "/" . $body["slug"] . ".md";
|
||||
}
|
||||
|
||||
$status = DocTools::writePages($task, $path, $writePath, $write);
|
||||
|
||||
if ($status) {
|
||||
$response = [
|
||||
"message" => "File edited. Nice work",
|
||||
"type" => $task == "write" ? "postUpdated" : "postAdded",
|
||||
"id" => $uuid,
|
||||
];
|
||||
|
||||
//**just testing to see why indexing isn't working **
|
||||
|
||||
//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") {
|
||||
Settings::updateIndex();
|
||||
}
|
||||
} else {
|
||||
$response = [
|
||||
"message" => "Uh oh. File save problem. Don't panic",
|
||||
"type" => "postError",
|
||||
"id" => $uuid,
|
||||
];
|
||||
}
|
||||
|
||||
return $response;
|
||||
}
|
||||
|
||||
public function getPages(int $page, int $limit, string $sort = null)
|
||||
{
|
||||
$content = $this->getContents();
|
||||
|
||||
$published = filter($content, function ($item) {
|
||||
return $item["published"] == true && $item["deleted"] == false;
|
||||
});
|
||||
$deleted = filter($content, function ($item) {
|
||||
return $item["deleted"] == true;
|
||||
});
|
||||
|
||||
$all = $content;
|
||||
$filter = isset($sort) ? $sort : "all";
|
||||
switch ($filter) {
|
||||
case "published":
|
||||
$filtered = $published;
|
||||
break;
|
||||
case "deleted":
|
||||
$filtered = $deleted;
|
||||
break;
|
||||
default:
|
||||
$filtered = $content;
|
||||
break;
|
||||
}
|
||||
$numOfPages = ceil(count($filtered) / ($limit + 1));
|
||||
$folder = [];
|
||||
|
||||
if (count($filtered) != 0) {
|
||||
if (count($filtered) < $limit) {
|
||||
$limit = count($filtered) - 1;
|
||||
}
|
||||
$range = $page * $limit - $limit;
|
||||
|
||||
if ($range != 0) {
|
||||
$range = $range + 1;
|
||||
}
|
||||
for ($i = 0; $i <= $limit; $i++) {
|
||||
if (isset($filtered[$i + $range])) {
|
||||
array_push($folder, $filtered[$i + $range]);
|
||||
} else {
|
||||
//chill out
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$prev = $page - 1;
|
||||
if ($prev <= 0) {
|
||||
$prev = $numOfPages;
|
||||
}
|
||||
|
||||
$next = $page + 1;
|
||||
if ($next > $numOfPages) {
|
||||
$next = 1;
|
||||
}
|
||||
|
||||
return [
|
||||
"pages" => $folder,
|
||||
"numOfPages" => $numOfPages,
|
||||
"entryCount" => count($filtered),
|
||||
"paginate" => [
|
||||
"sort" => $sort,
|
||||
"nextPage" => $next,
|
||||
"prevPage" => $prev,
|
||||
],
|
||||
"stats" => [
|
||||
"all" => count($all),
|
||||
"published" => count($published),
|
||||
"deleted" => count($deleted),
|
||||
],
|
||||
];
|
||||
}
|
||||
public function getContents()
|
||||
{
|
||||
//move page collection to utiltiy class
|
||||
$parser = new Parser();
|
||||
$contents = [];
|
||||
foreach ($this->files as $file) {
|
||||
$doc = $parser->parse(file_get_contents($file), false);
|
||||
$meta = $doc->getYAML();
|
||||
$page = [
|
||||
"id" => $meta["id"],
|
||||
"uuid" => $meta["uuid"],
|
||||
"title" => $meta["title"],
|
||||
"feature" => $meta["feature"],
|
||||
"path" => $meta["path"],
|
||||
"layout" => $meta["layout"],
|
||||
"tags" => $meta["tags"],
|
||||
"author" => $meta["author"],
|
||||
"created" => date("Y M D d", $meta["created"]),
|
||||
"updated" => date("Y M D d", $meta["updated"]),
|
||||
"rawCreated" => $meta["created"],
|
||||
"rawUpdated" => $meta["updated"],
|
||||
"createdYear" => date("Y", $meta["created"]),
|
||||
"createdMonth" => date("m", $meta["created"]),
|
||||
"deleted" => $meta["deleted"],
|
||||
"menu" => $meta["menu"],
|
||||
"featured" => $meta["featured"],
|
||||
"published" => $meta["published"],
|
||||
"slug" => $meta["slug"],
|
||||
"filePath" => $file,
|
||||
"content" => $doc->getContent(),
|
||||
];
|
||||
//checks for duplicates
|
||||
$uuid = $meta["uuid"];
|
||||
$found = current(
|
||||
array_filter($contents, function ($item) use ($uuid) {
|
||||
return isset($item["uuid"]) && $uuid == $item["uuid"];
|
||||
})
|
||||
);
|
||||
|
||||
// if uuid is not present, add it
|
||||
if (!$found) {
|
||||
array_push($contents, $page);
|
||||
}
|
||||
}
|
||||
$contents = orderBy($contents, ["id"], ["desc"]);
|
||||
return $contents;
|
||||
}
|
||||
}
|
@ -0,0 +1,230 @@
|
||||
<?php
|
||||
|
||||
namespace brain\data;
|
||||
|
||||
use Carbon\Carbon;
|
||||
use brain\utility\DocTools;
|
||||
use brain\utility\StringTools;
|
||||
|
||||
use function _\find;
|
||||
use function _\filter;
|
||||
|
||||
class Book
|
||||
{
|
||||
public function __construct()
|
||||
{
|
||||
}
|
||||
|
||||
public function findPageById(string $uuid)
|
||||
{
|
||||
$content = $this->getContents();
|
||||
$page = find($content, ['uuid' => $uuid]);
|
||||
|
||||
return $page;
|
||||
}
|
||||
|
||||
public function findPageBySlug(string $slug = null)
|
||||
{
|
||||
$content = $this->getContents();
|
||||
if (isset($slug)) {
|
||||
$page = find($content, ['slug' => $slug]);
|
||||
} else {
|
||||
$page = find($content, ['layout' => 'index']);
|
||||
}
|
||||
|
||||
return $page;
|
||||
}
|
||||
|
||||
public function editPage($task, $request)
|
||||
{
|
||||
$content = $this->getContents();
|
||||
$body = json_decode(file_get_contents("php://input"), true);
|
||||
//$body = find($content, ["uuid" => $parsed["id"]]);
|
||||
|
||||
$page = find($content, ['uuid' => $body['uuid']]);
|
||||
$files = $request->getUploadedFiles();
|
||||
|
||||
$member = Session::get('member');
|
||||
|
||||
if ($task != 'create') {
|
||||
$path = date('Y', date($page['rawCreated'])) .
|
||||
'/' .
|
||||
date('m', date($page['rawCreated']));
|
||||
} else {
|
||||
$path = date('Y') . '/' . date('m');
|
||||
}
|
||||
|
||||
$page_feature = '';
|
||||
$page_files = '';
|
||||
|
||||
if ($task == 'delete') {
|
||||
$deleted = 'true';
|
||||
$body['menu'] = 'false';
|
||||
$body['published'] = 'false';
|
||||
$body['featured'] = 'false';
|
||||
} else {
|
||||
$deleted = isset($page['deleted']) ? $page['deleted'] : 'false';
|
||||
}
|
||||
|
||||
$created = $task != 'create' ? new Carbon($page['rawCreated']) : Carbon::now();
|
||||
$updated = Carbon::now();
|
||||
|
||||
// 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;
|
||||
|
||||
$write = DocTools::objectToMD($body);
|
||||
|
||||
// if layout is index, change path to file
|
||||
|
||||
if ($body['layout'] == 'index') {
|
||||
$writePath = '../content/pages/start/index.md';
|
||||
} else {
|
||||
$writePath = '../content/pages/' . $path . '/' . $body['slug'] . '.md';
|
||||
}
|
||||
|
||||
$status = DocTools::writePages($task, $path, $writePath, $write);
|
||||
|
||||
if ($status) {
|
||||
$config = new Settings();
|
||||
$settings = $config->getSettings();
|
||||
$message = '';
|
||||
|
||||
if (
|
||||
$settings['global']['renderOnSave'] == 'true' &&
|
||||
$settings['global']['dynamicRender'] == 'false'
|
||||
) {
|
||||
$render = new Render();
|
||||
$render->renderTags();
|
||||
$render->renderArchive();
|
||||
$render->renderPages();
|
||||
$message = 'Filed edited and rendered. NOICE.';
|
||||
} else {
|
||||
$message = 'File edited. Nice work';
|
||||
}
|
||||
|
||||
$response = [
|
||||
'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);
|
||||
|
||||
// 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') {
|
||||
Settings::updateIndex();
|
||||
}
|
||||
} else {
|
||||
$response = [
|
||||
'message' => "Uh oh. File save problem. Don't panic",
|
||||
'type' => 'postError',
|
||||
'id' => $uuid,
|
||||
];
|
||||
}
|
||||
|
||||
return $response;
|
||||
}
|
||||
|
||||
public function getPages(int $page, int $limit, string $sort = null)
|
||||
{
|
||||
$content = $this->getContents();
|
||||
|
||||
$published = filter($content, function ($item) {
|
||||
return $item['published'] == true && $item['deleted'] == false;
|
||||
});
|
||||
$deleted = filter($content, function ($item) {
|
||||
return $item['deleted'] == true;
|
||||
});
|
||||
|
||||
// $all = $content;
|
||||
$all = filter($content, function ($item) {
|
||||
return $item['deleted'] == false;
|
||||
});
|
||||
$filter = isset($sort) ? $sort : 'all';
|
||||
switch ($filter) {
|
||||
case 'published':
|
||||
$filtered = $published;
|
||||
break;
|
||||
case 'deleted':
|
||||
$filtered = $deleted;
|
||||
break;
|
||||
default:
|
||||
$filtered = $all;
|
||||
break;
|
||||
}
|
||||
$numOfPages = ceil(count($filtered) / ($limit + 1));
|
||||
$folder = [];
|
||||
|
||||
if (count($filtered) != 0) {
|
||||
if (count($filtered) < $limit) {
|
||||
$limit = count($filtered) - 1;
|
||||
}
|
||||
$range = $page * $limit - $limit;
|
||||
|
||||
if ($range != 0) {
|
||||
$range = $range + 1;
|
||||
}
|
||||
for ($i = 0; $i <= $limit; ++$i) {
|
||||
if (isset($filtered[$i + $range])) {
|
||||
array_push($folder, $filtered[$i + $range]);
|
||||
} else {
|
||||
// chill out
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$prev = $page - 1;
|
||||
if ($prev <= 0) {
|
||||
$prev = $numOfPages;
|
||||
}
|
||||
|
||||
$next = $page + 1;
|
||||
if ($next > $numOfPages) {
|
||||
$next = 1;
|
||||
}
|
||||
|
||||
return [
|
||||
'pages' => $folder,
|
||||
'numOfPages' => $numOfPages,
|
||||
'entryCount' => count($filtered),
|
||||
'paginate' => [
|
||||
'sort' => $sort,
|
||||
'nextPage' => $next,
|
||||
'prevPage' => $prev,
|
||||
],
|
||||
'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();
|
||||
|
||||
return $contents;
|
||||
}
|
||||
}
|
@ -0,0 +1,193 @@
|
||||
<?php
|
||||
|
||||
namespace brain\data;
|
||||
|
||||
use HtmlSanitizer\SanitizerBuilder;
|
||||
use League\CommonMark\MarkdownConverter;
|
||||
use League\CommonMark\Environment\Environment;
|
||||
use HtmlSanitizer\Extension\Basic\BasicExtension;
|
||||
use HtmlSanitizer\Extension\Listing\ListExtension;
|
||||
use HtmlSanitizer\Extension\Iframe\IframeExtension;
|
||||
use League\CommonMark\Extension\Table\TableExtension;
|
||||
use League\CommonMark\Extension\Attributes\AttributesExtension;
|
||||
use League\CommonMark\Extension\FrontMatter\FrontMatterExtension;
|
||||
use League\CommonMark\Extension\CommonMark\CommonMarkCoreExtension;
|
||||
use League\CommonMark\Extension\Strikethrough\StrikethroughExtension;
|
||||
use League\CommonMark\Extension\FrontMatter\Output\RenderedContentWithFrontMatter;
|
||||
|
||||
use function _\orderBy;
|
||||
|
||||
class Contents
|
||||
{
|
||||
public $files = [];
|
||||
public $config = [];
|
||||
|
||||
public function __construct($folder)
|
||||
{
|
||||
$this->read($folder);
|
||||
}
|
||||
|
||||
public function read($folder)
|
||||
{
|
||||
$folders = glob("$folder/*", GLOB_ONLYDIR);
|
||||
foreach ($folders as $folder) {
|
||||
//$this->files[] = $folder . "/";
|
||||
$this->read($folder);
|
||||
}
|
||||
$files = array_filter(glob("$folder/*md"), 'is_file');
|
||||
foreach ($files as $file) {
|
||||
$this->files[] = $file;
|
||||
}
|
||||
}
|
||||
|
||||
public function getAll()
|
||||
{
|
||||
$environment = new Environment($this->config);
|
||||
$environment->addExtension(new CommonMarkCoreExtension());
|
||||
|
||||
// Add the extension
|
||||
$environment->addExtension(new FrontMatterExtension());
|
||||
|
||||
//Add Strikethrough rendering
|
||||
$environment->addExtension(new StrikethroughExtension());
|
||||
|
||||
//add attributes to elements in markdown
|
||||
$environment->addExtension(new AttributesExtension());
|
||||
|
||||
//add table rendering
|
||||
$environment->addExtension(new TableExtension());
|
||||
|
||||
// Instantiate the converter engine and start converting some Markdown!
|
||||
$converter = new MarkdownConverter($environment);
|
||||
|
||||
$contents = [];
|
||||
foreach ($this->files as $file) {
|
||||
//get meta and html from file
|
||||
$result = $converter->convertToHtml(file_get_contents($file));
|
||||
$meta = [];
|
||||
if ($result instanceof RenderedContentWithFrontMatter) {
|
||||
$meta = $result->getFrontMatter();
|
||||
}
|
||||
|
||||
//get raw markdown from file
|
||||
$frontMatterExtension = new FrontMatterExtension();
|
||||
$parsed = $frontMatterExtension
|
||||
->getFrontMatterParser()
|
||||
->parse(file_get_contents($file));
|
||||
|
||||
//never trust the front end. clean it up
|
||||
//add what sanitizer extensions we need manually
|
||||
$builder = new SanitizerBuilder();
|
||||
$builder->registerExtension(new BasicExtension());
|
||||
$builder->registerExtension(new IframeExtension());
|
||||
$builder->registerExtension(new ListExtension());
|
||||
//just add it straight because classname is already in use
|
||||
$builder->registerExtension(new \HtmlSanitizer\Extension\Table\TableExtension());
|
||||
|
||||
//relative-a and relative-image
|
||||
$builder->registerExtension(
|
||||
new \HtmlSanitizer\Extension\Relative\A\AExtension()
|
||||
);
|
||||
$builder->registerExtension(
|
||||
new \HtmlSanitizer\Extension\Relative\Image\ImageExtension()
|
||||
);
|
||||
|
||||
$detergent = [
|
||||
'extensions' => ['basic', 'list', 'relative-a', 'relative-image', 'iframe', 'table'],
|
||||
'tags' => [
|
||||
'div' => [
|
||||
'allowed_attributes' => ['class', 'title', 'id', 'style'],
|
||||
],
|
||||
'img' => [
|
||||
'allowed_attributes' => ['src', 'alt', 'title', 'class'],
|
||||
],
|
||||
'iframe' => [
|
||||
'allowed_attributes' => ['height', 'width', 'title', 'src'],
|
||||
],
|
||||
],
|
||||
];
|
||||
|
||||
$sanitizer = $builder->build($detergent);
|
||||
$scrubbed = $sanitizer->sanitize($result->getContent());
|
||||
if (isset($meta['feature'])) {
|
||||
$featureList = explode(',', $meta['feature']);
|
||||
} else {
|
||||
$featureList = "";
|
||||
}
|
||||
|
||||
$docs = '';
|
||||
if (isset($meta['files'])) {
|
||||
$fileList = explode(',', $meta['files']);
|
||||
$docs = $meta['files'];
|
||||
} else {
|
||||
$fileList = [];
|
||||
$docs = '';
|
||||
}
|
||||
|
||||
$media = [];
|
||||
$files = [];
|
||||
if ($featureList != '') {
|
||||
foreach ($featureList as $file) {
|
||||
$item = trim($file);
|
||||
$ext = pathinfo($item, PATHINFO_EXTENSION);
|
||||
if ($item != null || $item != '') {
|
||||
array_push($media, ['file' => $item, 'type' => trim($ext)]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ($fileList != "") {
|
||||
foreach ($fileList as $file) {
|
||||
$item = trim($file);
|
||||
$ext = pathinfo($item, PATHINFO_EXTENSION);
|
||||
if ($item != null || $item != '') {
|
||||
array_push($files, ['file' => $item, 'type' => trim($ext)]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//sort attributes into page object
|
||||
$page = [
|
||||
'id' => $meta['id'],
|
||||
'uuid' => $meta['uuid'],
|
||||
'title' => $meta['title'],
|
||||
'feature' => $meta['feature'],
|
||||
'files' => $docs,
|
||||
'path' => $meta['path'],
|
||||
'layout' => $meta['layout'],
|
||||
'tags' => $meta['tags'],
|
||||
'author' => $meta['author'],
|
||||
'created' => date('Y M D d', $meta['created']),
|
||||
'updated' => date('Y M D d', $meta['updated']),
|
||||
'rawCreated' => $meta['created'],
|
||||
'rawUpdated' => $meta['updated'],
|
||||
'createdYear' => date('Y', $meta['created']),
|
||||
'createdMonth' => date('m', $meta['created']),
|
||||
'deleted' => $meta['deleted'],
|
||||
'menu' => $meta['menu'],
|
||||
'featured' => $meta['featured'],
|
||||
'published' => $meta['published'],
|
||||
'slug' => $meta['slug'],
|
||||
'filePath' => $file,
|
||||
'content' => $parsed->getContent(),
|
||||
'html' => $scrubbed,
|
||||
'media' => $media,
|
||||
'docs' => $files
|
||||
];
|
||||
//checks for duplicates
|
||||
$uuid = $meta['uuid'];
|
||||
$found = current(
|
||||
array_filter($contents, function ($item) use ($uuid) {
|
||||
return isset($item['uuid']) && $uuid == $item['uuid'];
|
||||
})
|
||||
);
|
||||
|
||||
// if uuid is not present, add it
|
||||
if (!$found) {
|
||||
array_push($contents, $page);
|
||||
}
|
||||
}
|
||||
$contents = orderBy($contents, ['id'], ['desc']);
|
||||
return $contents;
|
||||
}
|
||||
}
|
@ -1,33 +0,0 @@
|
||||
<?php
|
||||
use function _\find;
|
||||
|
||||
class Member
|
||||
{
|
||||
public function __construct()
|
||||
{
|
||||
}
|
||||
|
||||
public static function updateData(string $key, string $data)
|
||||
{
|
||||
$folks = (new Settings())->getFolks();
|
||||
$member = Session::get("member");
|
||||
$found = find($folks, ["handle" => $member["handle"]]);
|
||||
$found[$key] = $data;
|
||||
//record time updated
|
||||
$updated = new \Moment\Moment();
|
||||
$found["updated"] = $updated->format("Y-m-d\TH:i:sP");
|
||||
$newFolks = [];
|
||||
array_push($newFolks, $found);
|
||||
//save updated file
|
||||
DocTools::writeSettings("../config/folks.json", $newFolks);
|
||||
//update member data in session
|
||||
|
||||
$member = [
|
||||
"handle" => $found["handle"],
|
||||
"email" => $found["email"],
|
||||
"role" => $found["role"],
|
||||
"avatar" => $found["avi"],
|
||||
];
|
||||
Session::set("member", $member);
|
||||
}
|
||||
}
|
@ -0,0 +1,61 @@
|
||||
<?php
|
||||
|
||||
namespace brain\data;
|
||||
|
||||
use Carbon\Carbon;
|
||||
use brain\utility\DocTools;
|
||||
|
||||
use function _\find;
|
||||
|
||||
class Member
|
||||
{
|
||||
public function __construct()
|
||||
{
|
||||
}
|
||||
|
||||
public static function verifyKey(string $key)
|
||||
{
|
||||
if (isset($key)) {
|
||||
$folks = (new Settings())->getFolks();
|
||||
$found = find($folks, ['key' => $key]);
|
||||
if ($found) {
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public static function updateData(string $key, string $data, $secret = null)
|
||||
{
|
||||
$folks = (new Settings())->getFolks();
|
||||
if (isset($secret)) {
|
||||
$found = find($folks, ['secret' => $secret]);
|
||||
} else {
|
||||
$member = Session::get('member');
|
||||
$found = find($folks, ['handle' => $member['handle']]);
|
||||
}
|
||||
$found[$key] = $data;
|
||||
//record time updated
|
||||
$updated = Carbon::now();
|
||||
$found['updated'] = $updated->format("Y-m-d\TH:i:sP");
|
||||
$newFolks = [];
|
||||
array_push($newFolks, $found);
|
||||
//save updated file
|
||||
DocTools::writeSettings('../config/folks.json', $newFolks);
|
||||
//update member data in session
|
||||
|
||||
if (!isset($secret)) {
|
||||
$member = [
|
||||
'handle' => $found['handle'],
|
||||
'email' => $found['email'],
|
||||
'role' => $found['role'],
|
||||
'avatar' => $found['avi'],
|
||||
'key' => $found['key'],
|
||||
];
|
||||
Session::set('member', $member);
|
||||
}
|
||||
}
|
||||
}
|
@ -1,215 +0,0 @@
|
||||
<?php
|
||||
use Mni\FrontYAML\Parser;
|
||||
|
||||
class Render
|
||||
{
|
||||
public $loader;
|
||||
public $twig;
|
||||
public $pageInfo;
|
||||
public $menu;
|
||||
public $background;
|
||||
public function __construct()
|
||||
{
|
||||
$config = new Settings();
|
||||
$this->loader = new \Twig\Loader\FilesystemLoader("../content/themes");
|
||||
$this->twig = new \Twig\Environment($this->loader, []);
|
||||
$settings = $config->getSettings();
|
||||
$this->menu = $settings["menu"];
|
||||
$this->theme = $settings["global"]["theme"];
|
||||
$this->pageInfo = [
|
||||
"keywords" => isset($settings["global"]["keywords"])
|
||||
? $settings["global"]["keywords"]
|
||||
: "fipamo, blog, jamstack, php, markdown, js",
|
||||
"description" => $settings["global"]["descriptions"],
|
||||
"image" =>
|
||||
$settings["global"]["base_url"] . $settings["global"]["background"],
|
||||
"baseURL" => $settings["global"]["base_url"],
|
||||
];
|
||||
//copy current theme assets to public
|
||||
if (is_file("../public/assets/css/base.css")) {
|
||||
unlink("../public/assets/css/base.css");
|
||||
}
|
||||
copy(
|
||||
"../content/themes/" . $this->theme . "/assets/css/base.css",
|
||||
"../public/assets/css/base.css"
|
||||
);
|
||||
if (is_file("../public/assets/scripts/start.min.js")) {
|
||||
unlink("../public/assets/scripts/start.min.js");
|
||||
}
|
||||
copy(
|
||||
"../content/themes/" . $this->theme . "/assets/scripts/start.min.js",
|
||||
"../public/assets/scripts/start.min.js"
|
||||
);
|
||||
}
|
||||
|
||||
public function renderPages()
|
||||
{
|
||||
$pages = (new Book("../content/pages"))->getContents();
|
||||
$recent = [];
|
||||
$featured = [];
|
||||
$limit = 4;
|
||||
foreach ($pages as $page) {
|
||||
if (!$page["deleted"] && $page["published"]) {
|
||||
if (count($recent) < $limit) {
|
||||
array_push($recent, [
|
||||
"path" => $page["path"],
|
||||
"slug" => $page["slug"],
|
||||
"title" => $page["title"],
|
||||
]);
|
||||
}
|
||||
|
||||
if ($page["featured"] == true) {
|
||||
if (count($featured) < $limit) {
|
||||
array_push($featured, [
|
||||
"path" => $page["path"],
|
||||
"slug" => $page["slug"],
|
||||
"title" => $page["title"],
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
$taglist = explode(",", $page["tags"]);
|
||||
$tags = [];
|
||||
foreach ($taglist as $tag) {
|
||||
$label = trim($tag);
|
||||
array_push($tags, [
|
||||
"label" => $label . " ",
|
||||
"slug" => StringTools::safeString($label),
|
||||
]);
|
||||
}
|
||||
|
||||
$meta = [
|
||||
"who" => $page["author"],
|
||||
"when" => $page["created"],
|
||||
"tags" => $tags,
|
||||
];
|
||||
|
||||
//render markdown content and clean it
|
||||
$parser = new Parser();
|
||||
$rendered = $parser->parse($page["content"]);
|
||||
$sanitizer = HtmlSanitizer\Sanitizer::create([
|
||||
"extensions" => ["basic", "image", "list", "code"],
|
||||
"tags" => [
|
||||
"img" => [
|
||||
"allowed_attributes" => ["src", "alt", "title", "class"],
|
||||
"allowed_hosts" => null,
|
||||
],
|
||||
],
|
||||
]);
|
||||
|
||||
$preclean = $sanitizer->sanitize($rendered->getContent());
|
||||
|
||||
//just clean renderd string for now, Sanitize doesn't like relative img urls
|
||||
//so another option is needed
|
||||
$cleaned = strip_tags($rendered->getContent(), [
|
||||
"a",
|
||||
"br",
|
||||
"p",
|
||||
"strong",
|
||||
"br",
|
||||
"img",
|
||||
"iframe",
|
||||
"ul",
|
||||
"li",
|
||||
"i",
|
||||
"h1",
|
||||
"h2",
|
||||
"h3",
|
||||
"pre",
|
||||
"code",
|
||||
]);
|
||||
//$cleaned = preg_replace('/(?:\r\n|[\r\n]){2,}/', "\n\n", $cleaned);
|
||||
//$cleaned = html_entity_decode($cleaned, ENT_QUOTES, "UTF-8");
|
||||
|
||||
//if page feature isn't empty, replace page info meta image
|
||||
if ($page["feature"] != "" || $page["feature"] != null) {
|
||||
$this->pageInfo["image"] =
|
||||
$this->pageInfo["baseURL"] . $page["feature"];
|
||||
}
|
||||
|
||||
if ($page["layout"] == "index") {
|
||||
$template = $this->theme . "/index.twig";
|
||||
$location = "../public/index.html";
|
||||
$dir = null;
|
||||
|
||||
$pageOptions = [
|
||||
"title" => $page["title"],
|
||||
"background" => $page["feature"],
|
||||
"content" => $cleaned,
|
||||
"meta" => $meta,
|
||||
"recent" => $recent,
|
||||
"featured" => $featured,
|
||||
"info" => $this->pageInfo,
|
||||
"menu" => $this->menu,
|
||||
];
|
||||
} else {
|
||||
$template = $this->theme . "/page.twig";
|
||||
$location =
|
||||
"../public/" . $page["path"] . "/" . $page["slug"] . ".html";
|
||||
$dir = "../public/" . $page["path"];
|
||||
$pageOptions = [
|
||||
"title" => $page["title"],
|
||||
"background" => $page["feature"],
|
||||
"content" => $cleaned,
|
||||
"meta" => $meta,
|
||||
"info" => $this->pageInfo,
|
||||
"menu" => $this->menu,
|
||||
];
|
||||
}
|
||||
|
||||
$html = $this->twig->render($template, $pageOptions);
|
||||
DocTools::writeHTML($location, $html, $dir);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function renderArchive()
|
||||
{
|
||||
$archive = Sorting::archive();
|
||||
$template = $this->theme . "/archive.twig";
|
||||
$pageOptions = [
|
||||
"title" => "Archive",
|
||||
"background" => $this->pageInfo["image"],
|
||||
"archives" => $archive,
|
||||
"info" => $this->pageInfo,
|
||||
"menu" => $this->menu,
|
||||
];
|
||||
|
||||
$html = $this->twig->render($template, $pageOptions);
|
||||
$location = "../public/archives.html";
|
||||
DocTools::writeHTML($location, $html);
|
||||
}
|
||||
|
||||
public function renderTags()
|
||||
{
|
||||
$list = Sorting::tags();
|
||||
foreach ($list as $item) {
|
||||
$template = $this->theme . "/tags.twig";
|
||||
$pageOptions = [
|
||||
"title" => "Pages Tagged as " . $item["tag_name"],
|
||||
"background" => $this->pageInfo["image"],
|
||||
"tag_list" => $item["pages"],
|
||||
"info" => $this->pageInfo,
|
||||
"menu" => $this->menu,
|
||||
];
|
||||
|
||||
$html = $this->twig->render($template, $pageOptions);
|
||||
|
||||
$location = "../public/tags/" . $item["slug"] . ".html";
|
||||
|
||||
//if tags folder doesn't exist, make it
|
||||
if (!is_dir("../public/tags")) {
|
||||
mkdir("../public/tags", 0755, true);
|
||||
} else {
|
||||
}
|
||||
|
||||
if (!is_file($location)) {
|
||||
file_put_contents($location, $html);
|
||||
} else {
|
||||
($new = fopen($location, "w")) or die("Unable to open file!");
|
||||
fwrite($new, $html);
|
||||
fclose($new);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,204 @@
|
||||
<?php
|
||||
|
||||
namespace brain\data;
|
||||
|
||||
use brain\utility\Sorting;
|
||||
use brain\utility\DocTools;
|
||||
|
||||
use function _\find;
|
||||
|
||||
class Render
|
||||
{
|
||||
public $loader;
|
||||
public $twig;
|
||||
public $pageInfo;
|
||||
public $menu;
|
||||
public $background;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$config = new Settings();
|
||||
//TODO: Add theme folder to loader
|
||||
$settings = $config->getSettings();
|
||||
$this->menu = $settings['menu'];
|
||||
$this->theme = $settings['global']['theme'];
|
||||
$this->loader = new \Twig\Loader\FilesystemLoader('../content/themes/' . $this->theme);
|
||||
$this->twig = new \Twig\Environment($this->loader, []);
|
||||
$this->pageInfo = [
|
||||
'keywords' => isset($settings['global']['keywords'])
|
||||
? $settings['global']['keywords']
|
||||
: 'fipamo, blog, jamstack, php, markdown, js',
|
||||
'description' => $settings['global']['descriptions'],
|
||||
'image' => $settings['global']['base_url'] . $settings['global']['background'],
|
||||
'baseURL' => $settings['global']['base_url'],
|
||||
];
|
||||
//move global theme image assets to public folder
|
||||
foreach (
|
||||
new \DirectoryIterator('../content/themes/' . $this->theme . '/assets/images/global/') as $file
|
||||
) {
|
||||
if ($file->isDot()) {
|
||||
continue;
|
||||
}
|
||||
if (!is_file('../public/assets/images/global/' . $file->getFileName())) {
|
||||
copy(
|
||||
'../content/themes/' .
|
||||
$this->theme .
|
||||
'/assets/images/global/' .
|
||||
$file->getFileName(),
|
||||
'../public/assets/images/global/' . $file->getFileName()
|
||||
);
|
||||
} else {
|
||||
//image is already there, so chill
|
||||
}
|
||||
//print $file->getFilename() . "\n";
|
||||
}
|
||||
|
||||
//copy current theme assets to public
|
||||
|
||||
//clear files in css and scripts folder
|
||||
$styles = glob('../public/assets/css/*'); // get all file names
|
||||
foreach ($styles as $file) { // iterate files
|
||||
if (is_file($file)) {
|
||||
//don't erase dashboard css
|
||||
if (!$file == '../public/assets/css/dash.css') {
|
||||
unlink($file); // delete file
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$scripts = glob('../public/assets/scripts/*'); // get all file names
|
||||
foreach ($scripts as $file) { // iterate files
|
||||
if (is_file($file)) {
|
||||
if (!$file == '../public/assets/scripts/Start.js') {
|
||||
unlink($file); // delete file
|
||||
}
|
||||
}
|
||||
}
|
||||
//copy theme assets to public
|
||||
$newcss = glob('../content/themes/' . $this->theme . '/assets/css/*');
|
||||
foreach ($newcss as $file) { // iterate files
|
||||
if (is_file($file)) {
|
||||
$path = explode('/', $file);
|
||||
copy($file, '../public/assets/css/' . $path[6]);
|
||||
}
|
||||
}
|
||||
$newjs = glob('../content/themes/' . $this->theme . '/assets/scripts/*');
|
||||
foreach ($newjs as $file) { // iterate files
|
||||
if (is_file($file)) {
|
||||
$path = explode('/', $file);
|
||||
copy($file, '../public/assets/scripts/' . $path[6]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function renderPages()
|
||||
{
|
||||
$pages = (new Book())->getContents();
|
||||
$recent = [];
|
||||
$featured = [];
|
||||
$limit = 4;
|
||||
foreach ($pages as $page) {
|
||||
$pageOptions = Sorting::page($page);
|
||||
|
||||
$layout = $page['layout'];
|
||||
//new pages have no layout, so defautl for now
|
||||
if ($layout == '' || $layout == null) {
|
||||
$layout = 'page';
|
||||
}
|
||||
|
||||
$template = $layout . '.twig';
|
||||
if (str_contains($layout, 'index')) {
|
||||
$location = '../public/index.html';
|
||||
$dir = null;
|
||||
} else {
|
||||
// if page is a menu item, render the page on public root
|
||||
if ($page['menu'] == 'true') {
|
||||
$location = '../public/' . $page['slug'] . '.html';
|
||||
$dir = '../public/';
|
||||
} else {
|
||||
$location = '../public/' . $page['path'] . '/' . $page['slug'] . '.html';
|
||||
$dir = '../public/' . $page['path'];
|
||||
}
|
||||
}
|
||||
|
||||
$html = $this->twig->render($template, $pageOptions);
|
||||
DocTools::writeHTML($location, $html, $dir);
|
||||
}
|
||||
}
|
||||
|
||||
public function renderArchive()
|
||||
{
|
||||
$archive = Sorting::archive();
|
||||
$template = 'archive.twig';
|
||||
$pageOptions = [
|
||||
'title' => 'Archive',
|
||||
'background' => $this->pageInfo['image'],
|
||||
'archives' => $archive,
|
||||
'info' => $this->pageInfo,
|
||||
'menu' => $this->menu,
|
||||
'media' => [['file' => $this->pageInfo['image'], 'type' => trim(pathinfo($this->pageInfo['image'], PATHINFO_EXTENSION))]],
|
||||
];
|
||||
|
||||
$html = $this->twig->render($template, $pageOptions);
|
||||
$location = '../public/archives.html';
|
||||
DocTools::writeHTML($location, $html);
|
||||
}
|
||||
|
||||
public function renderTags()
|
||||
{
|
||||
$list = Sorting::tags();
|
||||
foreach ($list as $item) {
|
||||
$template = 'tags.twig';
|
||||
$pageOptions = [
|
||||
'title' => 'Pages Tagged as ' . $item['tag_name'],
|
||||
'background' => $this->pageInfo['image'],
|
||||
'tag_list' => $item['pages'],
|
||||
'info' => $this->pageInfo,
|
||||
'menu' => $this->menu,
|
||||
'media' => [['file' => $this->pageInfo['image'], 'type' => trim(pathinfo($this->pageInfo['image'], PATHINFO_EXTENSION))]],
|
||||
];
|
||||
|
||||
$html = $this->twig->render($template, $pageOptions);
|
||||
|
||||
$location = '../public/tags/' . $item['slug'] . '.html';
|
||||
|
||||
//if tags folder doesn't exist, make it
|
||||
if (!is_dir('../public/tags')) {
|
||||
mkdir('../public/tags', 0755, true);
|
||||
} else {
|
||||
}
|
||||
|
||||
if (!is_file($location)) {
|
||||
file_put_contents($location, $html);
|
||||
} else {
|
||||
($new = fopen($location, 'w')) or die('Unable to open file!');
|
||||
fwrite($new, $html);
|
||||
fclose($new);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function renderIndex()
|
||||
{
|
||||
//TODO: Need to fix this to account for new index templating system
|
||||
$pages = (new Book())->getContents();
|
||||
$index = find($pages, ['layout' => 'index']);
|
||||
$template = 'index.twig';
|
||||
$location = '../public/index.html';
|
||||
$dir = null;
|
||||
|
||||
$meta = [
|
||||
'who' => $index['author'],
|
||||
'when' => $index['created'],
|
||||
];
|
||||
|
||||
$pageOptions = [
|
||||
'title' => $index['title'],
|
||||
'background' => $index['feature'],
|
||||
'meta' => $meta,
|
||||
];
|
||||
|
||||
$html = $this->twig->render($template, $pageOptions);
|
||||
DocTools::writeHTML($location, $html, $dir);
|
||||
}
|
||||
}
|
@ -1,89 +0,0 @@
|
||||
<?php
|
||||
use function _\find;
|
||||
use ReallySimpleJWT\Token;
|
||||
|
||||
class Session
|
||||
{
|
||||
private static $file = "../content/.session";
|
||||
private static $data = [
|
||||
"member" => "",
|
||||
"token" => "",
|
||||
];
|
||||
public static function start()
|
||||
{
|
||||
if (!is_file(self::$file)) {
|
||||
file_put_contents(self::$file, json_encode(self::$data));
|
||||
} else {
|
||||
($new = fopen(self::$file, "w")) or die("Unable to open file!");
|
||||
fwrite($new, json_encode(self::$data));
|
||||
fclose($new);
|
||||
}
|
||||
}
|
||||
|
||||
public static function active()
|
||||
{
|
||||
if (!is_file(self::$file)) {
|
||||
return false;
|
||||
} else {
|
||||
$data = json_decode(file_get_contents(self::$file), true);
|
||||
if ($data["member"] != null) {
|
||||
$secret = (new Settings())->getFolks("secret");
|
||||
if ($secret == null) {
|
||||
return false;
|
||||
} else {
|
||||
if (
|
||||
Token::validate($data["token"], $secret) &&
|
||||
Token::validateExpiration($data["token"], $secret)
|
||||
) {
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static function verifyToken($token)
|
||||
{
|
||||
$data = json_decode(file_get_contents(self::$file), true);
|
||||
if ($data["member"] != null) {
|
||||
$secret = (new Settings())->getFolks("secret");
|
||||
if (
|
||||
Token::validate($token, $secret) &&
|
||||
Token::validateExpiration($token, $secret)
|
||||
) {
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public static function set($key, $value)
|
||||
{
|
||||
$data = json_decode(file_get_contents(self::$file), true);
|
||||
$data[$key] = $value;
|
||||
($fresh = fopen(self::$file, "w")) or die("Unable to open file!");
|
||||
fwrite($fresh, json_encode($data));
|
||||
fclose($fresh);
|
||||
}
|
||||
|
||||
public static function get($key)
|
||||
{
|
||||
$data = json_decode(file_get_contents(self::$file), true);
|
||||
|
||||
return $data[$key];
|
||||
}
|
||||
|
||||
public static function kill()
|
||||
{
|
||||
($fresh = fopen(self::$file, "w")) or die("Unable to open file!");
|
||||
fwrite($fresh, json_encode(self::$data));
|
||||
fclose($fresh);
|
||||
}
|
||||
}
|
@ -0,0 +1,93 @@
|
||||
<?php
|
||||
|
||||
namespace brain\data;
|
||||
|
||||
use ReallySimpleJWT\Token;
|
||||
|
||||
class Session
|
||||
{
|
||||
private static $file = '../content/.session';
|
||||
private static $data = [
|
||||
'member' => '',
|
||||
'token' => '',
|
||||
'form_token' => '',
|
||||
];
|
||||
|
||||
public static function start()
|
||||
{
|
||||
if (!is_file(self::$file)) {
|
||||
file_put_contents(self::$file, json_encode(self::$data));
|
||||
} else {
|
||||
($new = fopen(self::$file, 'w')) or die('Unable to open file!');
|
||||
fwrite($new, json_encode(self::$data));
|
||||
fclose($new);
|
||||
}
|
||||
}
|
||||
|
||||
public static function active()
|
||||
{
|
||||
if (!is_file(self::$file)) {
|
||||
return false;
|
||||
} else {
|
||||
$data = json_decode(file_get_contents(self::$file), true);
|
||||
if ($data['member'] != null) {
|
||||
$secret = (new Settings())->getFolks('secret');
|
||||
if ($secret == null) {
|
||||
return false;
|
||||
} else {
|
||||
if (
|
||||
Token::validate($data['token'], $secret) &&
|
||||
Token::validateExpiration($data['token'], $secret)
|
||||
) {
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static function verifyToken($token)
|
||||
{
|
||||
$data = json_decode(file_get_contents(self::$file), true);
|
||||
if ($data['member'] != null) {
|
||||
$secret = (new Settings())->getFolks('secret');
|
||||
if (
|
||||
Token::validate($token, $secret) &&
|
||||
Token::validateExpiration($token, $secret)
|
||||
) {
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public static function set($key, $value)
|
||||
{
|
||||
$data = json_decode(file_get_contents(self::$file), true);
|
||||
$data[$key] = $value;
|
||||
($fresh = fopen(self::$file, 'w')) or die('Unable to open file!');
|
||||
fwrite($fresh, json_encode($data));
|
||||
fclose($fresh);
|
||||
}
|
||||
|
||||
public static function get($key)
|
||||
{
|
||||
$data = json_decode(file_get_contents(self::$file), true);
|
||||
|
||||
return $data[$key];
|
||||
}
|
||||
|
||||
public static function kill()
|
||||
{
|
||||
($fresh = fopen(self::$file, 'w')) or die('Unable to open file!');
|
||||
fwrite($fresh, json_encode(self::$data));
|
||||
fclose($fresh);
|
||||
}
|
||||
}
|
@ -1,176 +0,0 @@
|
||||
<?php
|
||||
use function _\find;
|
||||
use function _\pull;
|
||||
use function _\remove;
|
||||
class Settings
|
||||
{
|
||||
private $folks;
|
||||
private $tags;
|
||||
private $themes = [];
|
||||
private static $settings;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
//gets all settings files and converts to php objects
|
||||
$this->folks = json_decode(file_get_contents("../config/folks.json"), true);
|
||||
$this->tags = json_decode(file_get_contents("../config/tags.json"), true);
|
||||
self::$settings = json_decode(
|
||||
file_get_contents("../config/settings.json"),
|
||||
true
|
||||
);
|
||||
|
||||
$_themes = glob("../content/themes/*", GLOB_ONLYDIR);
|
||||
foreach ($_themes as $theme) {
|
||||
array_push(
|
||||
$this->themes,
|
||||
json_decode(file_get_contents($theme . "/theme.json"), true)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
public static function sync($data)
|
||||
{
|
||||
$settings = self::$settings;
|
||||
$settings["global"]["base_url"] = $data["global"]["base_url"];
|
||||
$settings["global"]["title"] = $data["global"]["title"];
|
||||
$settings["global"]["descriptions"] = $data["global"]["descriptions"];
|
||||
$settings["global"]["base_url"] = $data["global"]["base_url"];
|
||||
$settings["global"]["private"] = $data["global"]["private"];
|
||||
$settings["global"]["renderOnSave"] = $data["global"]["renderOnSave"];
|
||||
$settings["global"]["theme"] = $data["global"]["theme"];
|
||||
|
||||
Member::updateData("handle", $data["member"]["handle"]);
|
||||
Member::updateData("email", $data["member"]["email"]);
|
||||
|
||||
$settings["email"]["active"] = $data["email"]["active"];
|
||||
$settings["email"]["smtp"] = $data["email"]["smtp"];
|
||||
$settings["email"]["mailgun"] = $data["email"]["mailgun"];
|
||||
|
||||
DocTools::writeSettings("../config/settings.json", $settings);
|
||||
}
|
||||
|
||||
public static function navSync($data)
|
||||
{
|
||||
$settings = self::$settings;
|
||||
|
||||
$remove = $data["remove"];
|
||||
//if remove contains id, find nav item page and set menu to false
|
||||
if ($remove != null || $remove != "") {
|
||||
$page = (new Book("../content/pages"))->findPageById($remove);
|
||||
$page["menu"] = "false";
|
||||
$page["published"]
|
||||
? ($page["published"] = "true")
|
||||
: ($page["published"] = "false");
|
||||
$page["featured"]
|
||||
? ($page["featured"] = "true")
|
||||
: ($page["featured"] = "false");
|
||||
$page["deleted"]
|
||||
? ($page["deleted"] = "true")
|
||||
: ($page["deleted"] = "false");
|
||||
$updated = new \Moment\Moment();
|
||||
$created = new \Moment\Moment($page["rawCreated"]);
|
||||
$page["created"] = $created->format("Y-m-d\TH:i:sP");
|
||||
$page["updated"] = $updated->format("Y-m-d\TH:i:sP");
|
||||
|
||||
$md = DocTools::objectToMD($page);
|
||||
|
||||
if ($page["layout"] == "index") {
|
||||
$writePath = "../content/pages/start/index.md";
|
||||
} else {
|
||||
$writePath =
|
||||
"../content/pages/" . $page["path"] . "/" . $page["slug"] . ".md";
|
||||
}
|
||||
|
||||
DocTools::writePages("write", $page["path"], $writePath, $md);
|
||||
}
|
||||
|
||||
$settings["menu"] = [];
|
||||
$items = $data["menu"];
|
||||
foreach ($items as $item) {
|
||||
array_push($settings["menu"], [
|
||||
"title" => $item["title"],
|
||||
"id" => $item["id"],
|
||||
"uuid" => $item["uuid"],
|
||||
"slug" => $item["slug"],
|
||||
"path" => $item["path"],
|
||||
]);
|
||||
}
|
||||
|
||||
DocTools::writeSettings("../config/settings.json", $settings);
|
||||
}
|
||||
|
||||
public function getThemes()
|
||||
{
|
||||
return $this->themes;
|
||||
}
|
||||
|
||||
public function getFolks($key = null)
|
||||
{
|
||||
if (isset($key)) {
|
||||
$member = Session::get("member");
|
||||
$found = find($this->folks, ["handle" => $member["handle"]]);
|
||||
if ($found) {
|
||||
return $found[$key];
|
||||
}
|
||||
} else {
|
||||
return $this->folks;
|
||||
}
|
||||
}
|
||||
|
||||
public function getSettings($key = null)
|
||||
{
|
||||
return self::$settings;
|
||||
}
|
||||
|
||||
public static function updateGlobalData($key, $data)
|
||||
{
|
||||
$settings = self::$settings;
|
||||
$settings["global"][$key] = $data;
|
||||
DocTools::writeSettings("../config/settings.json", $settings);
|
||||
}
|
||||
|
||||
public static function getCurrentIndex()
|
||||
{
|
||||
$settings = self::$settings;
|
||||
return $settings["library_stats"]["current_index"];
|
||||
}
|
||||
|
||||
public static function updateIndex()
|
||||
{
|
||||
$settings = self::$settings;
|
||||
|
||||
$settings["library_stats"]["current_index"] =
|
||||
$settings["library_stats"]["current_index"] + 1;
|
||||
|
||||
DocTools::writeSettings("../config/settings.json", $settings);
|
||||
}
|
||||
|
||||
public static function updateMenu($body)
|
||||
{
|
||||
$settings = self::$settings;
|
||||
//$menu = $settings["menu"];
|
||||
$item = [
|
||||
"title" => $body["title"],
|
||||
"id" => $body["id"],
|
||||
"uuid" => $body["uuid"],
|
||||
"slug" => $body["slug"],
|
||||
"path" => $body["path"],
|
||||
];
|
||||
if ($body["menu"] == "true") {
|
||||
if (!find($settings["menu"], ["uuid" => $item["uuid"]])) {
|
||||
array_push($settings["menu"], $item);
|
||||
}
|
||||
} else {
|
||||
if (find($settings["menu"], ["uuid" => $item["uuid"]])) {
|
||||
pull($settings["menu"], $item);
|
||||
}
|
||||
}
|
||||
DocTools::writeSettings("../config/settings.json", $settings);
|
||||
}
|
||||
|
||||
public static function updateTags()
|
||||
{
|
||||
$tags = Sorting::tags();
|
||||
DocTools::writeSettings("../config/tags.json", $tags);
|
||||
}
|
||||
}
|
@ -0,0 +1,175 @@
|
||||
<?php
|
||||
|
||||
namespace brain\data;
|
||||
|
||||
use brain\utility\DocTools;
|
||||
use brain\utility\Sorting;
|
||||
use Carbon\Carbon;
|
||||
|
||||
use function _\find;
|
||||
use function _\pull;
|
||||
use function _\remove;
|
||||
|
||||
class Settings
|
||||
{
|
||||
private $folks;
|
||||
private static $tags;
|
||||
private static $settings;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
//gets all settings files and converts to php objects
|
||||
$this->folks = json_decode(file_get_contents('../config/folks.json'), true);
|
||||
self::$tags = json_decode(file_get_contents('../config/tags.json'), true);
|
||||
self::$settings = json_decode(
|
||||
file_get_contents('../config/settings.json'),
|
||||
true
|
||||
);
|
||||
}
|
||||
|
||||
public static function sync($data)
|
||||
{
|
||||
$settings = self::$settings;
|
||||
$settings['global']['base_url'] = $data['global']['base_url'];
|
||||
$settings['global']['title'] = $data['global']['title'];
|
||||
$settings['global']['descriptions'] = $data['global']['descriptions'];
|
||||
$settings['global']['base_url'] = $data['global']['base_url'];
|
||||
$settings['global']['private'] = $data['global']['private'];
|
||||
$settings['global']['renderOnSave'] = $data['global']['renderOnSave'];
|
||||
$settings['global']['theme'] = $data['global']['theme'];
|
||||
$settings['global']['externalAPI'] = $data['global']['externalAPI'];
|
||||
$settings['global']['dynamicRender'] = $data['global']['dynamicRender'];
|
||||
|
||||
Member::updateData('handle', $data['member']['handle']);
|
||||
Member::updateData('email', $data['member']['email']);
|
||||
|
||||
$settings['email']['active'] = $data['email']['active'];
|
||||
$settings['email']['smtp'] = $data['email']['smtp'];
|
||||
$settings['email']['mailgun'] = $data['email']['mailgun'];
|
||||
|
||||
DocTools::writeSettings('../config/settings.json', $settings);
|
||||
}
|
||||
|
||||
public static function navSync($data)
|
||||
{
|
||||
$settings = self::$settings;
|
||||
|
||||
$remove = $data['remove'];
|
||||
//if remove contains id, find nav item page and set menu to false
|
||||
if ($remove != null || $remove != '') {
|
||||
$page = (new Book('../content/pages'))->findPageById($remove);
|
||||
$page['menu'] = 'false';
|
||||
$page['published']
|
||||
? ($page['published'] = 'true')
|
||||
: ($page['published'] = 'false');
|
||||
$page['featured']
|
||||
? ($page['featured'] = 'true')
|
||||
: ($page['featured'] = 'false');
|
||||
$page['deleted']
|
||||
? ($page['deleted'] = 'true')
|
||||
: ($page['deleted'] = 'false');
|
||||
$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");
|
||||
|
||||
$md = DocTools::objectToMD($page);
|
||||
|
||||
if ($page['layout'] == 'index') {
|
||||
$writePath = '../content/pages/start/index.md';
|
||||
} else {
|
||||
$writePath = '../content/pages/' . $page['path'] . '/' . $page['slug'] . '.md';
|
||||
}
|
||||
|
||||
DocTools::writePages('write', $page['path'], $writePath, $md);
|
||||
}
|
||||
|
||||
$settings['menu'] = [];
|
||||
$items = $data['menu'];
|
||||
foreach ($items as $item) {
|
||||
array_push($settings['menu'], [
|
||||
'title' => $item['title'],
|
||||
'id' => $item['id'],
|
||||
'uuid' => $item['uuid'],
|
||||
'slug' => $item['slug'],
|
||||
'path' => $item['path'],
|
||||
]);
|
||||
}
|
||||
|
||||
DocTools::writeSettings('../config/settings.json', $settings);
|
||||
}
|
||||
|
||||
public function getFolks($key = null)
|
||||
{
|
||||
if (isset($key)) {
|
||||
$member = Session::get('member');
|
||||
$found = find($this->folks, ['handle' => $member['handle']]);
|
||||
if ($found) {
|
||||
return $found[$key];
|
||||
}
|
||||
} else {
|
||||
return $this->folks;
|
||||
}
|
||||
}
|
||||
|
||||
public function getSettings($key = null)
|
||||
{
|
||||
return self::$settings;
|
||||
}
|
||||
|
||||
public static function getTags()
|
||||
{
|
||||
return self::$tags;
|
||||
}
|
||||
|
||||
public static function updateGlobalData($key, $data)
|
||||
{
|
||||
$settings = self::$settings;
|
||||
$settings['global'][$key] = $data;
|
||||
DocTools::writeSettings('../config/settings.json', $settings);
|
||||
}
|
||||
|
||||
public static function getCurrentIndex()
|
||||
{
|
||||
$settings = self::$settings;
|
||||
return $settings['library_stats']['current_index'];
|
||||
}
|
||||
|
||||
public static function updateIndex()
|
||||
{
|
||||
$settings = self::$settings;
|
||||
|
||||
$settings['library_stats']['current_index'] = $settings['library_stats']['current_index'] + 1;
|
||||
|
||||
DocTools::writeSettings('../config/settings.json', $settings);
|
||||
}
|
||||
|
||||
public static function updateMenu($body)
|
||||
{
|
||||
$settings = self::$settings;
|
||||
//$menu = $settings["menu"];
|
||||
$item = [
|
||||
'title' => $body['title'],
|
||||
'id' => $body['id'],
|
||||
'uuid' => $body['uuid'],
|
||||
'slug' => $body['slug'],
|
||||
'path' => $body['path'],
|
||||
];
|
||||
if ($body['menu'] == 'true') {
|
||||
if (!find($settings['menu'], ['uuid' => $item['uuid']])) {
|
||||
array_push($settings['menu'], $item);
|
||||
}
|
||||
} else {
|
||||
if (find($settings['menu'], ['uuid' => $item['uuid']])) {
|
||||
pull($settings['menu'], $item);
|
||||
}
|
||||
}
|
||||
DocTools::writeSettings('../config/settings.json', $settings);
|
||||
}
|
||||
|
||||
public static function updateTags()
|
||||
{
|
||||
$tags = Sorting::tags();
|
||||
DocTools::writeSettings('../config/tags.json', $tags);
|
||||
}
|
||||
}
|
@ -0,0 +1,62 @@
|
||||
<?php
|
||||
|
||||
namespace brain\data;
|
||||
|
||||
class Themes
|
||||
{
|
||||
private $themes = [];
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$_themes = glob('../content/themes/*', GLOB_ONLYDIR);
|
||||
foreach ($_themes as $theme) {
|
||||
array_push(
|
||||
$this->themes,
|
||||
json_decode(file_get_contents($theme . '/theme.json'), true)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
public function getThemes()
|
||||
{
|
||||
return $this->themes;
|
||||
}
|
||||
|
||||
public function getCustomIndex()
|
||||
{
|
||||
$settings = (new Settings())->getSettings();
|
||||
$currentTheme = $settings['global']['theme'];
|
||||
$folder = '../content/themes/' . $currentTheme;
|
||||
$files = array_filter(glob("$folder/*twig"), 'is_file');
|
||||
$views = [];
|
||||
|
||||
foreach ($files as $file) {
|
||||
$path = explode('/', $file);
|
||||
$fileName = $path[4];
|
||||
if (str_contains($fileName, 'index')) {
|
||||
$page = explode('.', $fileName);
|
||||
$views[] = $page[0];
|
||||
}
|
||||
}
|
||||
return $views;
|
||||
}
|
||||
|
||||
public function getCustomViews()
|
||||
{
|
||||
$settings = (new Settings())->getSettings();
|
||||
$currentTheme = $settings['global']['theme'];
|
||||
$folder = '../content/themes/' . $currentTheme;
|
||||
$files = array_filter(glob("$folder/*twig"), 'is_file');
|
||||
$views = [];
|
||||
|
||||
foreach ($files as $file) {
|
||||
$path = explode('/', $file);
|
||||
$fileName = $path[4];
|
||||
if (str_contains($fileName, 'page')) {
|
||||
$page = explode('.', $fileName);
|
||||
$views[] = $page[0];
|
||||
}
|
||||
}
|
||||
return $views;
|
||||
}
|
||||
}
|
@ -0,0 +1,33 @@
|
||||
<?php
|
||||
|
||||
namespace brain\init;
|
||||
|
||||
use brain\utility\HandleCors;
|
||||
use Slim\Factory\AppFactory;
|
||||
use Slim\Views\Twig;
|
||||
use Slim\Views\TwigMiddleware;
|
||||
|
||||
class App
|
||||
{
|
||||
public function __construct()
|
||||
{
|
||||
// when a new class is made, run composer dump-autoload
|
||||
// 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}]]]]]',
|
||||
"brain\controller\RouteControl:get"
|
||||
);
|
||||
$app->post(
|
||||
'/[{first}[/{second}[/{third}[/{fourth}]]]]',
|
||||
"brain\controller\RouteControl:post"
|
||||
);
|
||||
// start the app
|
||||
|
||||
$app->run();
|
||||
}
|
||||
}
|
@ -1,138 +0,0 @@
|
||||
<?php
|
||||
|
||||
class DocTools
|
||||
{
|
||||
public function __construct()
|
||||
{
|
||||
}
|
||||
|
||||
public static function writePages($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;
|
||||
}
|
||||
}
|
||||
|
||||
public static function writeSettings($fileLocation, $fileContents)
|
||||
{
|
||||
if (!is_file($fileLocation)) {
|
||||
file_put_contents($fileLocation, json_encode($fileContents));
|
||||
} else {
|
||||
($new = fopen($fileLocation, "w")) or die("Unable to open file!");
|
||||
fwrite($new, json_encode($fileContents));
|
||||
fclose($new);
|
||||
}
|
||||
}
|
||||
|
||||
public static function writeHTML($location, $html, $path = null)
|
||||
{
|
||||
if ($path != null) {
|
||||
if (!is_dir($path)) {
|
||||
//Directory does not exist, so lets create it.
|
||||
mkdir($path, 0755, true);
|
||||
}
|
||||
}
|
||||
if (!is_file($location)) {
|
||||
file_put_contents($location, $html);
|
||||
} else {
|
||||
($new = fopen($location, "w")) or die("Unable to open file!");
|
||||
fwrite($new, $html);
|
||||
fclose($new);
|
||||
}
|
||||
}
|
||||
|
||||
public static function deleteFolder($path)
|
||||
{
|
||||
if (!empty($path) && is_dir($path)) {
|
||||
$dir = new RecursiveDirectoryIterator(
|
||||
$path,
|
||||
RecursiveDirectoryIterator::SKIP_DOTS
|
||||
); //upper dirs are not included,otherwise DISASTER HAPPENS :)
|
||||
$files = new RecursiveIteratorIterator(
|
||||
$dir,
|
||||
RecursiveIteratorIterator::CHILD_FIRST
|
||||
);
|
||||
foreach ($files as $f) {
|
||||
if (is_file($f)) {
|
||||
unlink($f);
|
||||
} else {
|
||||
$empty_dirs[] = $f;
|
||||
}
|
||||
}
|
||||
if (!empty($empty_dirs)) {
|
||||
foreach ($empty_dirs as $eachDir) {
|
||||
rmdir($eachDir);
|
||||
}
|
||||
}
|
||||
rmdir($path);
|
||||
}
|
||||
}
|
||||
|
||||
public static function objectToMD($object)
|
||||
{
|
||||
$markdown =
|
||||
"---\n" .
|
||||
"id: " .
|
||||
$object["id"] .
|
||||
"\n" .
|
||||
"uuid: " .
|
||||
$object["uuid"] .
|
||||
"\n" .
|
||||
"title: " .
|
||||
$object["title"] .
|
||||
"\n" .
|
||||
"feature: " .
|
||||
$object["feature"] .
|
||||
"\n" .
|
||||
"path: " .
|
||||
$object["path"] .
|
||||
"\n" .
|
||||
"layout: " .
|
||||
$object["layout"] .
|
||||
"\n" .
|
||||
"tags: " .
|
||||
$object["tags"] .
|
||||
"\n" .
|
||||
"author: " .
|
||||
$object["author"] .
|
||||
"\n" .
|
||||
"created: " .
|
||||
$object["created"] .
|
||||
"\n" .
|
||||
"updated: " .
|
||||
$object["updated"] .
|
||||
"\n" .
|
||||
"deleted: " .
|
||||
$object["deleted"] .
|
||||
"\n" .
|
||||
"slug: " .
|
||||
$object["slug"] .
|
||||
"\n" .
|
||||
"menu: " .
|
||||
$object["menu"] .
|
||||
"\n" .
|
||||
"published: " .
|
||||
$object["published"] .
|
||||
"\n" .
|
||||
"featured: " .
|
||||
$object["featured"] .
|
||||
"\n---\n" .
|
||||
$object["content"];
|
||||
|
||||
return $markdown;
|
||||
}
|
||||
}
|
@ -0,0 +1,144 @@
|
||||
<?php
|
||||
|
||||
namespace brain\utility;
|
||||
|
||||
class DocTools
|
||||
{
|
||||
public function __construct()
|
||||
{
|
||||
}
|
||||
|
||||
public static function writePages($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;
|
||||
}
|
||||
}
|
||||
|
||||
public static function writeSettings($fileLocation, $fileContents)
|
||||
{
|
||||
if (!is_file($fileLocation)) {
|
||||
file_put_contents($fileLocation, json_encode($fileContents));
|
||||
} else {
|
||||
($new = fopen($fileLocation, 'w')) or die('Unable to open file!');
|
||||
fwrite($new, json_encode($fileContents));
|
||||
fclose($new);
|
||||
}
|
||||
}
|
||||
|
||||
public static function writeHTML($location, $html, $path = null)
|
||||
{
|
||||
if ($path != null) {
|
||||
if (!is_dir($path)) {
|
||||
//Directory does not exist, so lets create it.
|
||||
mkdir($path, 0755, true);
|
||||
}
|
||||
}
|
||||
if (!is_file($location)) {
|
||||
file_put_contents($location, $html);
|
||||
} else {
|
||||
($new = fopen($location, 'w')) or die('Unable to open file!');
|
||||
fwrite($new, $html);
|
||||
fclose($new);
|
||||
}
|
||||
}
|
||||
|
||||
public static function deleteFolder($path)
|
||||
{
|
||||
if (!empty($path) && is_dir($path)) {
|
||||
$dir = new \RecursiveDirectoryIterator(
|
||||
$path,
|
||||
\RecursiveDirectoryIterator::SKIP_DOTS
|
||||
); //upper dirs are not included,otherwise DISASTER HAPPENS :)
|
||||
$files = new \RecursiveIteratorIterator(
|
||||
$dir,
|
||||
\RecursiveIteratorIterator::CHILD_FIRST
|
||||
);
|
||||
foreach ($files as $f) {
|
||||
if (is_file($f)) {
|
||||
unlink($f);
|
||||
} else {
|
||||
$empty_dirs[] = $f;
|
||||
}
|
||||
}
|
||||
if (!empty($empty_dirs)) {
|
||||
foreach ($empty_dirs as $eachDir) {
|
||||
rmdir($eachDir);
|
||||
}
|
||||
}
|
||||
rmdir($path);
|
||||
}
|
||||
}
|
||||
|
||||
public static function objectToMD($object)
|
||||
{
|
||||
$markdown = "---\n" .
|
||||
'id: ' .
|
||||
$object['id'] .
|
||||
"\n" .
|
||||
'uuid: ' .
|
||||
$object['uuid'] .
|
||||
"\n" .
|
||||
'title: ' .
|
||||
"'" .
|
||||
$object['title'] .
|
||||
"'" .
|
||||
"\n" .
|
||||
'feature: ' .
|
||||
$object['imageList'] .
|
||||
"\n" .
|
||||
'files: ' .
|
||||
$object['fileList'] .
|
||||
"\n" .
|
||||
'path: ' .
|
||||
$object['path'] .
|
||||
"\n" .
|
||||
'layout: ' .
|
||||
$object['layout'] .
|
||||
"\n" .
|
||||
'tags: ' .
|
||||
$object['tags'] .
|
||||
"\n" .
|
||||
'author: ' .
|
||||
$object['author'] .
|
||||
"\n" .
|
||||
'created: ' .
|
||||
$object['created'] .
|
||||
"\n" .
|
||||
'updated: ' .
|
||||
$object['updated'] .
|
||||
"\n" .
|
||||
'deleted: ' .
|
||||
$object['deleted'] .
|
||||
"\n" .
|
||||
'slug: ' .
|
||||
$object['slug'] .
|
||||
"\n" .
|
||||
'menu: ' .
|
||||
$object['menu'] .
|
||||
"\n" .
|
||||
'published: ' .
|
||||
$object['published'] .
|
||||
"\n" .
|
||||
'featured: ' .
|
||||
$object['featured'] .
|
||||
"\n---\n" .
|
||||
$object['content'];
|
||||
|
||||
return $markdown;
|
||||
}
|
||||
}
|
@ -1,32 +0,0 @@
|
||||
<?php
|
||||
use Psr\Http\Message\UploadedFileInterface;
|
||||
//include "brain/data/Auth.inc.php";
|
||||
define("MAXIMUM_FILESIZE", "10485760"); //10 MB
|
||||
class FileUploader
|
||||
{
|
||||
public static function uploadFile(string $directory, $file)
|
||||
{
|
||||
$response = [];
|
||||
try {
|
||||
if (!is_dir($directory)) {
|
||||
//Directory does not exist, so lets create it.
|
||||
mkdir($directory, 0755, true);
|
||||
}
|
||||
//$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);
|
||||
|
||||
//echo "**FILE** " . $file->getClientFileName();
|
||||
|
||||
$file->moveTo($directory . "/" . $file->getClientFileName());
|
||||
} catch (RuntimeException $e) {
|
||||
echo "ERROR " . $e->getMessage();
|
||||
|
||||
//echo "failed to upload image: " . $e->getMessage();
|
||||
//throw new Error("Failed to upload image file");
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,32 @@
|
||||
<?php
|
||||
|
||||
namespace brain\utility;
|
||||
|
||||
class FileUploader
|
||||
{
|
||||
public static function uploadFile(string $directory, $file)
|
||||
{
|
||||
$response = [];
|
||||
try {
|
||||
if (!is_dir($directory)) {
|
||||
// Directory does not exist, so lets create it.
|
||||
mkdir($directory, 0755, true);
|
||||
}
|
||||
// $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);
|
||||
|
||||
// echo "**FILE** " . $file->getClientFileName();
|
||||
|
||||
$file->moveTo($directory . '/' . urlencode($file->getClientFileName()));
|
||||
} catch (RuntimeException $e) {
|
||||
echo 'ERROR ' . $e->getMessage();
|
||||
|
||||
// echo "failed to upload image: " . $e->getMessage();
|
||||
// throw new Error("Failed to upload image file");
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,61 @@
|
||||
<?php
|
||||
|
||||
namespace brain\utility;
|
||||
|
||||
use brain\data\Settings;
|
||||
|
||||
class HandleCors
|
||||
{
|
||||
public function __construct()
|
||||
{
|
||||
//look to see if settings file exists. kinda important
|
||||
if (file_exists('../config/settings.json')) {
|
||||
//check settings to see if external api access is allowed
|
||||
$config = new Settings();
|
||||
$settings = $config->getSettings();
|
||||
if ($settings['global']['externalAPI']) {
|
||||
//echo "API STATUS: " . $settings["global"]["externalAPI"];
|
||||
if ($settings['global']['externalAPI'] == 'true') {
|
||||
//echo "API ACCESS ACTIVE";
|
||||
// checks to see if origin is set
|
||||
if (isset($_SERVER['HTTP_ORIGIN'])) {
|
||||
// You can decide if the origin in $_SERVER['HTTP_ORIGIN']
|
||||
//is something you want to allow, or as we do here, just allow all
|
||||
header("Access-Control-Allow-Origin: {$_SERVER['HTTP_ORIGIN']}");
|
||||
} else {
|
||||
//No HTTP_ORIGIN set, so we allow any. You can disallow if needed here
|
||||
//never allow just any domain, so turn CORS off if no No HTTP_ORIGIN is set
|
||||
//header("Access-Control-Allow-Origin: *");
|
||||
}
|
||||
|
||||
header('Access-Control-Allow-Credentials: true');
|
||||
header('Access-Control-Max-Age: 600'); // cache for 10 minutes
|
||||
|
||||
if ($_SERVER['REQUEST_METHOD'] == 'OPTIONS') {
|
||||
if (isset($_SERVER['HTTP_ACCESS_CONTROL_REQUEST_METHOD'])) {
|
||||
header(
|
||||
'Access-Control-Allow-Methods: POST, GET, OPTIONS, DELETE, PUT'
|
||||
);
|
||||
} //Make sure you remove those you do not want to support
|
||||
|
||||
if (isset($_SERVER['HTTP_ACCESS_CONTROL_REQUEST_HEADERS'])) {
|
||||
header(
|
||||
"Access-Control-Allow-Headers: {$_SERVER['HTTP_ACCESS_CONTROL_REQUEST_HEADERS']}"
|
||||
);
|
||||
}
|
||||
|
||||
//Just exit with 200 OK with the above headers for OPTIONS method
|
||||
exit(0);
|
||||
}
|
||||
} else {
|
||||
//echo "API ACCESS ACTIVE";
|
||||
}
|
||||
} else {
|
||||
//value doesn't exist, so whatevs
|
||||
//echo "API ACCESS VALUE NOT PRESENT";
|
||||
}
|
||||
} else {
|
||||
//init state, so chill
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,95 @@
|
||||
<?php
|
||||
|
||||
namespace brain\utility;
|
||||
|
||||
use PHPMailer\PHPMailer\PHPMailer;
|
||||
use PHPMailer\PHPMailer\Exception;
|
||||
use brain\data\Settings;
|
||||
use brain\data\Session;
|
||||
|
||||
class Mailer
|
||||
{
|
||||
public static function sendMail($body)
|
||||
{
|
||||
$config = new Settings();
|
||||
$settings = $config->getSettings();
|
||||
$mailConfig = $settings['email'];
|
||||
$mail = new PHPMailer();
|
||||
|
||||
switch ($body['mail_task']) {
|
||||
case 'TESTING':
|
||||
$html = "<h1>Hi! It's Fipamo!</h1><br>" .
|
||||
"<strong>It's just a test</strong><br>" .
|
||||
$body['content'];
|
||||
$member = Session::get('member');
|
||||
$mail->addAddress($member['email'], ''); //pull email address from current user
|
||||
$mail->Subject = 'A test email';
|
||||
break;
|
||||
case 'SEND_SECRET':
|
||||
$html = "<h1>Hi! It's Fipamo!</h1><br>" .
|
||||
'<strong>This is your secret key.</strong><br><br>' .
|
||||
'<h3>' .
|
||||
$body['secret'] .
|
||||
'</h3>' .
|
||||
'<br> Use this key to reset your password.';
|
||||
$mail->addAddress($body['email'], ''); //pull email address from current user
|
||||
$mail->Subject = "Shhhh! It's a secret!";
|
||||
break;
|
||||
default:
|
||||
return $result = [
|
||||
'type' => 'noMailService',
|
||||
'message' => 'Mail task is undefined. What are you doing??',
|
||||
];
|
||||
break;
|
||||
}
|
||||
|
||||
//set values based on current active protocol
|
||||
switch ($mailConfig['active']) {
|
||||
case 'option-smtp':
|
||||
$mail->setFrom($mailConfig['smtp']['email'], 'System Email');
|
||||
$mail->Host = 'playvicio.us';
|
||||
$mail->Username = $mailConfig['smtp']['email'];
|
||||
$mail->Password = $mailConfig['smtp']['password'];
|
||||
|
||||
break;
|
||||
case 'option-mg':
|
||||
$mail->setFrom($mailConfig['mailgun']['domain'], 'No Reply');
|
||||
$mail->Host = 'smtp.mailgun.org';
|
||||
$mail->Username = $mailConfig['mailgun']['domain'];
|
||||
$mail->Password = $mailConfig['mailgun']['key'];
|
||||
break;
|
||||
default:
|
||||
//no mail service
|
||||
return $result = [
|
||||
'type' => 'noMailService',
|
||||
'message' => 'Mail is not configured. Handle that.',
|
||||
];
|
||||
break;
|
||||
}
|
||||
|
||||
$mail->Body = $html;
|
||||
$mail->IsHTML(true);
|
||||
$mail->isSMTP();
|
||||
$mail->SMTPAuth = true;
|
||||
$mail->SMTPSecure = 'ssl';
|
||||
$mail->Port = 465;
|
||||
|
||||
// Uncomment for debug info
|
||||
//$mail->SMTPDebug = 4;
|
||||
|
||||
/* Finally send the mail. */
|
||||
try {
|
||||
$mail->send();
|
||||
$result = ['type' => 'mailSent', 'message' => 'Message Away!'];
|
||||
} catch (Exception $e) {
|
||||
//echo $e->errorMessage();
|
||||
$result = [
|
||||
'type' => 'mailNotSent',
|
||||
'message' => 'Message Not Away!',
|
||||
'error' => $e->errorMessage(),
|
||||
];
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
}
|
@ -1,99 +0,0 @@
|
||||
<?php
|
||||
class Maintenance
|
||||
{
|
||||
public function __construct()
|
||||
{
|
||||
}
|
||||
|
||||
public static function makeBackup()
|
||||
{
|
||||
//make sure back directory is there
|
||||
if (!is_dir("../config/backups")) {
|
||||
mkdir("../config/backups", 0755, true);
|
||||
}
|
||||
//creat backup zip
|
||||
$zip = new ZipArchive();
|
||||
$zip->open(
|
||||
"../config/backups/latest_back.zip",
|
||||
ZipArchive::CREATE | ZipArchive::OVERWRITE
|
||||
);
|
||||
//gather data and path info for md pages
|
||||
$pagePath = "../content/pages";
|
||||
$yearPaths = glob($pagePath . "/*", GLOB_ONLYDIR);
|
||||
foreach ($yearPaths as $years) {
|
||||
$year = explode("/", $years);
|
||||
//grap the index and save it
|
||||
if (trim($year[3]) == "start") {
|
||||
$options = [
|
||||
"add_path" => "content/pages/" . $year[3] . "/",
|
||||
"remove_all_path" => true,
|
||||
];
|
||||
$zip->addGlob($years . "/*.md", GLOB_BRACE, $options);
|
||||
}
|
||||
$monthsPath = glob($pagePath . "/" . $year[3] . "/*", GLOB_ONLYDIR);
|
||||
foreach ($monthsPath as $months) {
|
||||
$month = explode("/", $months);
|
||||
//once info is collected, add md pages to zip
|
||||
$options = [
|
||||
"add_path" => "content/pages/" . $year[3] . "/" . $month[4] . "/",
|
||||
"remove_all_path" => true,
|
||||
];
|
||||
$zip->addGlob($months . "/*.md", GLOB_BRACE, $options);
|
||||
}
|
||||
}
|
||||
|
||||
//gather data and path info for blog images
|
||||
$blogImagesPath = "../public/assets/images/blog";
|
||||
$yearPaths = glob($blogImagesPath . "/*", GLOB_ONLYDIR);
|
||||
foreach ($yearPaths as $years) {
|
||||
$year = explode("/", $years);
|
||||
$monthsPath = glob($blogImagesPath . "/" . $year[5] . "/*", GLOB_ONLYDIR);
|
||||
foreach ($monthsPath as $months) {
|
||||
$month = explode("/", $months);
|
||||
//once info is collected, add images pages to zip
|
||||
$options = [
|
||||
"add_path" =>
|
||||
"public/assets/images/blog/" . $year[5] . "/" . $month[6] . "/",
|
||||
"remove_all_path" => true,
|
||||
];
|
||||
$zip->addGlob($months . "/*.*", GLOB_BRACE, $options);
|
||||
}
|
||||
}
|
||||
|
||||
//gather data and path info for user images
|
||||
$userImagesPath = "../public/assets/images/user";
|
||||
$yearPaths = glob($userImagesPath . "/*", GLOB_ONLYDIR);
|
||||
foreach ($yearPaths as $years) {
|
||||
$year = explode("/", $years);
|
||||
$monthsPath = glob($userImagesPath . "/" . $year[5] . "/*", GLOB_ONLYDIR);
|
||||
foreach ($monthsPath as $months) {
|
||||
$month = explode("/", $months);
|
||||
//once info is collected, add images pages to zip
|
||||
$options = [
|
||||
"add_path" =>
|
||||
"public/assets/images/user/" . $year[5] . "/" . $month[6] . "/",
|
||||
"remove_all_path" => true,
|
||||
];
|
||||
$zip->addGlob($months . "/*.*", GLOB_BRACE, $options);
|
||||
}
|
||||
}
|
||||
|
||||
//add directory for settings and save them
|
||||
$zip->addEmptyDir("settings");
|
||||
$zip->addFile("../config/settings.json", "settings/settings.json");
|
||||
$zip->addFile("../config/folks.json", "settings/folks.json");
|
||||
$zip->addFile("../config/tags.json", "settings/tags.json");
|
||||
//save zip file
|
||||
$zip->close();
|
||||
|
||||
//update settings file with latest back up date
|
||||
$updated = new \Moment\Moment();
|
||||
Settings::updateGlobalData(
|
||||
"last_backup",
|
||||
$updated->format("Y-m-d\TH:i:sP")
|
||||
);
|
||||
|
||||
$result = ["message" => "Backup created. THIS IS A SAFE SPACE!"];
|
||||
return $result;
|
||||
}
|
||||
}
|
@ -0,0 +1,103 @@
|
||||
<?php
|
||||
|
||||
namespace brain\utility;
|
||||
|
||||
use brain\data\Settings;
|
||||
use Carbon\Carbon;
|
||||
|
||||
class Maintenance
|
||||
{
|
||||
public function __construct()
|
||||
{
|
||||
}
|
||||
|
||||
public static function makeBackup()
|
||||
{
|
||||
//make sure back directory is there
|
||||
if (!is_dir('../config/backups')) {
|
||||
mkdir('../config/backups', 0755, true);
|
||||
}
|
||||
//creat backup zip
|
||||
$zip = new \ZipArchive();
|
||||
$zip->open(
|
||||
'../config/backups/latest_back.zip',
|
||||
\ZipArchive::CREATE | \ZipArchive::OVERWRITE
|
||||
);
|
||||
//gather data and path info for md pages
|
||||
$pagePath = '../content/pages';
|
||||
$yearPaths = glob($pagePath . '/*', GLOB_ONLYDIR);
|
||||
foreach ($yearPaths as $years) {
|
||||
$year = explode('/', $years);
|
||||
//grap the index and save it
|
||||
if (trim($year[3]) == 'start') {
|
||||
$options = [
|
||||
'add_path' => 'content/pages/' . $year[3] . '/',
|
||||
'remove_all_path' => true,
|
||||
];
|
||||
$zip->addGlob($years . '/*.md', GLOB_BRACE, $options);
|
||||
}
|
||||
$monthsPath = glob($pagePath . '/' . $year[3] . '/*', GLOB_ONLYDIR);
|
||||
foreach ($monthsPath as $months) {
|
||||
$month = explode('/', $months);
|
||||
//once info is collected, add md pages to zip
|
||||
$options = [
|
||||
'add_path' => 'content/pages/' . $year[3] . '/' . $month[4] . '/',
|
||||
'remove_all_path' => true,
|
||||
];
|
||||
$zip->addGlob($months . '/*.md', GLOB_BRACE, $options);
|
||||
}
|
||||
}
|
||||
|
||||
//gather data and path info for blog images
|
||||
$blogImagesPath = '../public/assets/images/blog';
|
||||
$yearPaths = glob($blogImagesPath . '/*', GLOB_ONLYDIR);
|
||||
foreach ($yearPaths as $years) {
|
||||
$year = explode('/', $years);
|
||||
$monthsPath = glob($blogImagesPath . '/' . $year[5] . '/*', GLOB_ONLYDIR);
|
||||
foreach ($monthsPath as $months) {
|
||||
$month = explode('/', $months);
|
||||
//once info is collected, add images pages to zip
|
||||
$options = [
|
||||
'add_path' => 'public/assets/images/blog/' . $year[5] . '/' . $month[6] . '/',
|
||||
'remove_all_path' => true,
|
||||
];
|
||||
$zip->addGlob($months . '/*.*', GLOB_BRACE, $options);
|
||||
}
|
||||
}
|
||||
|
||||
//gather data and path info for user images
|
||||
$userImagesPath = '../public/assets/images/user';
|
||||
$yearPaths = glob($userImagesPath . '/*', GLOB_ONLYDIR);
|
||||
foreach ($yearPaths as $years) {
|
||||
$year = explode('/', $years);
|
||||
$monthsPath = glob($userImagesPath . '/' . $year[5] . '/*', GLOB_ONLYDIR);
|
||||
foreach ($monthsPath as $months) {
|
||||
$month = explode('/', $months);
|
||||
//once info is collected, add images pages to zip
|
||||
$options = [
|
||||
'add_path' => 'public/assets/images/user/' . $year[5] . '/' . $month[6] . '/',
|
||||
'remove_all_path' => true,
|
||||
];
|
||||
$zip->addGlob($months . '/*.*', GLOB_BRACE, $options);
|
||||
}
|
||||
}
|
||||
|
||||
//add directory for settings and save them
|
||||
$zip->addEmptyDir('settings');
|
||||
$zip->addFile('../config/settings.json', 'settings/settings.json');
|
||||
$zip->addFile('../config/folks.json', 'settings/folks.json');
|
||||
$zip->addFile('../config/tags.json', 'settings/tags.json');
|
||||
//save zip file
|
||||
$zip->close();
|
||||
|
||||
//update settings file with latest back up date
|
||||
$updated = Carbon::now();
|
||||
Settings::updateGlobalData(
|
||||
'last_backup',
|
||||
$updated->format("Y-m-d\TH:i:sP")
|
||||
);
|
||||
|
||||
$result = ['message' => 'Backup created. THIS IS A SAFE SPACE!'];
|
||||
return $result;
|
||||
}
|
||||
}
|
@ -1,201 +0,0 @@
|
||||
<?php
|
||||
use function _\find;
|
||||
class SetUp
|
||||
{
|
||||
public static function status()
|
||||
{
|
||||
if (file_exists("../config/settings.json")) {
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public static function init($body)
|
||||
{
|
||||
//grab template files
|
||||
$newFolks = json_decode(
|
||||
file_get_contents("../config/init/folks-template.json"),
|
||||
true
|
||||
);
|
||||
$newSettings = json_decode(
|
||||
file_get_contents("../config/init/settings-template.json"),
|
||||
true
|
||||
);
|
||||
//get form values
|
||||
//$body = $request->getParsedBody();
|
||||
$handle = $body["new_member_handle"];
|
||||
$email = $body["new_member_email"];
|
||||
$pass = $body["new_member_pass"];
|
||||
$title = $body["new_member_title"];
|
||||
|
||||
$now = new \Moment\Moment();
|
||||
//setup folks config
|
||||
$hash = password_hash($pass, PASSWORD_DEFAULT);
|
||||
$newFolks[0]["id"] = 0;
|
||||
$newFolks[0]["handle"] = $handle;
|
||||
$newFolks[0]["email"] = $email;
|
||||
$newFolks[0]["password"] = $hash;
|
||||
$newFolks[0]["key"] = password_hash($email, PASSWORD_DEFAULT);
|
||||
$newFolks[0]["secret"] = StringTools::randomString(12);
|
||||
$newFolks[0]["role"] = "hnic";
|
||||
$newFolks[0]["created"] = $now->format("Y-m-d\TH:i:sP");
|
||||
$newFolks[0]["updated"] = $now->format("Y-m-d\TH:i:sP");
|
||||
//set up settings config
|
||||
$newSettings["global"]["title"] = $title;
|
||||
|
||||
//create index file
|
||||
//$rightNow = $now->format("Y-m-d\TH:i:sP");
|
||||
//var_dump($now->format("Y-m-d\TH:i:sP"));
|
||||
$index = [
|
||||
"id" => 1,
|
||||
"uuid" => StringTools::createUUID(),
|
||||
"title" => "FIRST!",
|
||||
"feature" => "/assets/images/global/default-bg.jpg",
|
||||
"path" => "content/pages/start",
|
||||
"layout" => "index",
|
||||
"tags" => "start, welcome",
|
||||
"author" => $handle,
|
||||
"created" => $now->format("Y-m-d\TH:i:sP"),
|
||||
"updated" => $now->format("Y-m-d\TH:i:sP"),
|
||||
"deleted" => "false",
|
||||
"slug" => "first",
|
||||
"menu" => "false",
|
||||
"featured" => "false",
|
||||
"published" => "true",
|
||||
"content" =>
|
||||
"# F**k Yes \n\nIf you're seeing this, you're up and running. NICE WORK!\n\nFrom here, feel free to start dropping pages to your heart's content.\n\nFor some tips about using Fipamo, check out the ![docs](https://code.playvicio.us/Are0h/Fipamo/wiki/02-Usage)\n\nAll good? Feel free to edit this page to whatever you want!\n\nYOU'RE THE CAPTAIN NOW.",
|
||||
];
|
||||
|
||||
$freshIndex = DocTools::objectToMD($index);
|
||||
|
||||
//once all files created, write down
|
||||
|
||||
DocTools::writeSettings("../config/settings.json", $newSettings);
|
||||
DocTools::writeSettings("../config/folks.json", $newFolks);
|
||||
DocTools::writeSettings("../config/tags.json", []);
|
||||
DocTools::writePages(
|
||||
"create",
|
||||
"start",
|
||||
"../content/pages/start/index.md",
|
||||
$freshIndex
|
||||
);
|
||||
|
||||
//if there is an older session file, get rid of it
|
||||
if (is_file("../content/.session")) {
|
||||
unlink("../content/.session");
|
||||
}
|
||||
|
||||
$result = ["type" => "blogInitGood", "message" => "Site Created"];
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
public static function restore($request)
|
||||
{
|
||||
$result = [
|
||||
"type" => "requestLame",
|
||||
"message" => "Still working on it.",
|
||||
];
|
||||
$body = $request->getParsedBody();
|
||||
|
||||
$backup = $request->getUploadedFiles();
|
||||
$file = $backup["backup-upload"];
|
||||
$name = $file->getClientFileName();
|
||||
|
||||
//park it so it can be read
|
||||
$file->moveTo("../content" . "/" . $name);
|
||||
|
||||
//open it and get files to verify user
|
||||
$zip = new ZipArchive();
|
||||
if ($zip->open("../content" . "/" . $name) === true) {
|
||||
$folks = json_decode($zip->getFromName("settings/folks.json"), true);
|
||||
$found = find($folks, ["handle" => $body["restore_member_handle"]]);
|
||||
|
||||
//if member is found in back up, check pass
|
||||
if ($found) {
|
||||
if (password_verify($body["restore_member_pass"], $found["password"])) {
|
||||
//backup verified, restore site
|
||||
|
||||
//set new secret key for older folks configs
|
||||
$newFolks = [];
|
||||
if (!isset($found["secret"])) {
|
||||
$found["secret"] = StringTools::randomString(12);
|
||||
}
|
||||
array_push($newFolks, $found);
|
||||
//dump files in folder
|
||||
$zip->extractTo("../content");
|
||||
|
||||
//move to appropriate spots
|
||||
rename(
|
||||
"../content/settings/settings.json",
|
||||
"../config/settings.json"
|
||||
);
|
||||
|
||||
//rename("../content/settings/folks.json", "../config/folks.json");
|
||||
DocTools::writeSettings("../config/folks.json", $newFolks);
|
||||
|
||||
rename("../content/settings/tags.json", "../config/tags.json");
|
||||
|
||||
rename(
|
||||
"../content/public/assets/images/blog",
|
||||
"../public/assets/images/blog"
|
||||
);
|
||||
|
||||
rename(
|
||||
"../content/public/assets/images/user",
|
||||
"../public/assets/images/user"
|
||||
);
|
||||
|
||||
rename("../content/content/pages/", "../content/pages");
|
||||
|
||||
//legacy check for old file structure
|
||||
if (is_file("../content/pages/index.md")) {
|
||||
if (!is_dir("../content/pages/start")) {
|
||||
//Directory does not exist, so lets create it.
|
||||
mkdir("../content/pages/start", 0755, true);
|
||||
//move start page to appropriate spot
|
||||
rename(
|
||||
"../content/pages/index.md",
|
||||
"../content/pages/start/index.md"
|
||||
);
|
||||
}
|
||||
} else {
|
||||
//chill
|
||||
}
|
||||
|
||||
//clean up
|
||||
|
||||
DocTools::deleteFolder("../content/settings");
|
||||
DocTools::deleteFolder("../content/public");
|
||||
DocTools::deleteFolder("../content/content");
|
||||
$result = [
|
||||
"type" => "requestGood",
|
||||
"message" => "Site Restored! Redirecting",
|
||||
];
|
||||
} else {
|
||||
$result = [
|
||||
"type" => "requestLame",
|
||||
"message" => "Check that password, champ.",
|
||||
];
|
||||
}
|
||||
} else {
|
||||
$result = [
|
||||
"type" => "requestLame",
|
||||
"message" => "No member found by that name, hoss",
|
||||
];
|
||||
}
|
||||
|
||||
$zip->close();
|
||||
$zipPath = "../content/" . $name;
|
||||
//trash zip when done
|
||||
unlink($zipPath);
|
||||
} else {
|
||||
$result = [
|
||||
"type" => "requestLame",
|
||||
"message" => "Could not open backup. RATS!",
|
||||
];
|
||||
}
|
||||
return $result;
|
||||
}
|
||||
}
|
@ -0,0 +1,230 @@
|
||||
<?php
|
||||
|
||||
namespace brain\utility;
|
||||
|
||||
use Carbon\Carbon;
|
||||
|
||||
use function _\find;
|
||||
|
||||
class SetUp
|
||||
{
|
||||
public static function status()
|
||||
{
|
||||
if (file_exists('../config/settings.json')) {
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public static function init($body)
|
||||
{
|
||||
//grab template files
|
||||
$newFolks = json_decode(
|
||||
file_get_contents('../config/init/folks-template.json'),
|
||||
true
|
||||
);
|
||||
$newSettings = json_decode(
|
||||
file_get_contents('../config/init/settings-template.json'),
|
||||
true
|
||||
);
|
||||
//get form values
|
||||
//$body = $request->getParsedBody();
|
||||
$handle = $body['new_member_handle'];
|
||||
$email = $body['new_member_email'];
|
||||
$pass = $body['new_member_pass'];
|
||||
$title = $body['new_member_title'];
|
||||
|
||||
$now = Carbon::now();
|
||||
//setup folks config
|
||||
$hash = password_hash($pass, PASSWORD_DEFAULT);
|
||||
$newFolks[0]['id'] = 0;
|
||||
$newFolks[0]['handle'] = $handle;
|
||||
$newFolks[0]['email'] = $email;
|
||||
$newFolks[0]['password'] = $hash;
|
||||
$newFolks[0]['key'] = password_hash($email, PASSWORD_DEFAULT);
|
||||
$newFolks[0]['secret'] = StringTools::randomString(12);
|
||||
$newFolks[0]['role'] = 'hnic';
|
||||
$newFolks[0]['created'] = $now->format("Y-m-d\TH:i:sP");
|
||||
$newFolks[0]['updated'] = $now->format("Y-m-d\TH:i:sP");
|
||||
//set up settings config
|
||||
$newSettings['global']['title'] = $title;
|
||||
|
||||
//create index file
|
||||
//$rightNow = $now->format("Y-m-d\TH:i:sP");
|
||||
//var_dump($now->format("Y-m-d\TH:i:sP"));
|
||||
$index = [
|
||||
'id' => 1,
|
||||
'uuid' => StringTools::createUUID(),
|
||||
'title' => 'FIRST!',
|
||||
'imageList' => '/assets/images/global/default-bg.jpg',
|
||||
'fileList' => '',
|
||||
'path' => 'content/pages/start',
|
||||
'layout' => 'index',
|
||||
'tags' => 'start, welcome',
|
||||
'author' => $handle,
|
||||
'created' => $now->format("Y-m-d\TH:i:sP"),
|
||||
'updated' => $now->format("Y-m-d\TH:i:sP"),
|
||||
'deleted' => 'false',
|
||||
'slug' => 'first',
|
||||
'menu' => 'false',
|
||||
'featured' => 'false',
|
||||
'published' => 'true',
|
||||
'content' => "# F**k Yes \n\nIf you're seeing this, you're up and running. NICE WORK!\n\nFrom here, feel free to start dropping pages to your heart's content.\n\nFor some tips about using Fipamo, check out the ![docs](https://code.playvicio.us/Are0h/Fipamo/wiki/02-Usage)\n\nAll good? Feel free to edit this page to whatever you want!\n\nYOU'RE THE CAPTAIN NOW.",
|
||||
];
|
||||
|
||||
$freshIndex = DocTools::objectToMD($index);
|
||||
|
||||
//once all files created, write down
|
||||
|
||||
DocTools::writeSettings('../config/settings.json', $newSettings);
|
||||
DocTools::writeSettings('../config/folks.json', $newFolks);
|
||||
DocTools::writeSettings('../config/tags.json', []);
|
||||
DocTools::writePages(
|
||||
'create',
|
||||
'start',
|
||||
'../content/pages/start/index.md',
|
||||
$freshIndex
|
||||
);
|
||||
|
||||
//if there is an older session file, get rid of it
|
||||
if (is_file('../content/.session')) {
|
||||
unlink('../content/.session');
|
||||
}
|
||||
|
||||
$result = ['type' => 'blogInitGood', 'message' => 'Site Created'];
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
public static function restore($request)
|
||||
{
|
||||
$result = [
|
||||
'type' => 'requestLame',
|
||||
'message' => 'Still working on it.',
|
||||
];
|
||||
$body = $request->getParsedBody();
|
||||
|
||||
$backup = $request->getUploadedFiles();
|
||||
$file = $backup['backup-upload'];
|
||||
//NOTE: If this fails check 'post_max_size' in php.ini
|
||||
$size = $file->getSize();
|
||||
$name = $file->getClientFileName();
|
||||
|
||||
//park it so it can be read
|
||||
$file->moveTo('../content' . '/' . $name);
|
||||
|
||||
//open it and get files to verify user
|
||||
$zip = new \ZipArchive();
|
||||
if ($zip->open('../content' . '/' . $name) === true) {
|
||||
$folks = json_decode($zip->getFromName('settings/folks.json'), true);
|
||||
$found = find($folks, ['handle' => $body['restore_member_handle']]);
|
||||
|
||||
//if member is found in back up, check pass
|
||||
if ($found) {
|
||||
if (password_verify($body['restore_member_pass'], $found['password'])) {
|
||||
//backup verified, restore site
|
||||
|
||||
//set new secret key for older folks configs
|
||||
$newFolks = [];
|
||||
if (!isset($found['secret'])) {
|
||||
$found['secret'] = StringTools::randomString(12);
|
||||
}
|
||||
array_push($newFolks, $found);
|
||||
//dump files in folder
|
||||
$zip->extractTo('../content');
|
||||
|
||||
//move to appropriate spots
|
||||
/*
|
||||
rename(
|
||||
"../content/settings/settings.json",
|
||||
"../config/settings.json"
|
||||
);
|
||||
*/
|
||||
|
||||
//load up old config file
|
||||
$newConfig = json_decode(
|
||||
file_get_contents('../content/settings/settings.json'),
|
||||
true
|
||||
);
|
||||
//check for key, add if not there
|
||||
if (!isset($newConfig['global']['externalAPI'])) {
|
||||
$newConfig['global']['externalAPI'] = 'false';
|
||||
}
|
||||
//write new config file
|
||||
DocTools::writeSettings('../config/settings.json', $newConfig);
|
||||
|
||||
//rename("../content/settings/folks.json", "../config/folks.json");
|
||||
DocTools::writeSettings('../config/folks.json', $newFolks);
|
||||
|
||||
rename('../content/settings/tags.json', '../config/tags.json');
|
||||
|
||||
//images path for blog and user
|
||||
$blogImagePath = '../public/assets/images/blog';
|
||||
$userImagePath = '../public/assets/images/user';
|
||||
|
||||
//check to see if image dirs are empty, if not chill
|
||||
if ($globs = glob($blogImagePath . '/*')) {
|
||||
//directory not empty, relax
|
||||
} else {
|
||||
rename('../content/public/assets/images/blog', $blogImagePath);
|
||||
}
|
||||
|
||||
if ($globs = glob($userImagePath . '/*')) {
|
||||
//directory not empty, relax
|
||||
} else {
|
||||
rename('../content/public/assets/images/user', $userImagePath);
|
||||
}
|
||||
|
||||
rename('../content/content/pages/', '../content/pages');
|
||||
|
||||
//legacy check for old file structure
|
||||
if (is_file('../content/pages/index.md')) {
|
||||
if (!is_dir('../content/pages/start')) {
|
||||
//Directory does not exist, so lets create it.
|
||||
mkdir('../content/pages/start', 0755, true);
|
||||
//move start page to appropriate spot
|
||||
rename(
|
||||
'../content/pages/index.md',
|
||||
'../content/pages/start/index.md'
|
||||
);
|
||||
}
|
||||
} else {
|
||||
//chill
|
||||
}
|
||||
|
||||
//clean up
|
||||
|
||||
DocTools::deleteFolder('../content/settings');
|
||||
DocTools::deleteFolder('../content/public');
|
||||
DocTools::deleteFolder('../content/content');
|
||||
$result = [
|
||||
'type' => 'requestGood',
|
||||
'message' => 'Site Restored! Redirecting',
|
||||
];
|
||||
} else {
|
||||
$result = [
|
||||
'type' => 'requestLame',
|
||||
'message' => 'Check that password, champ.',
|
||||
];
|
||||
}
|
||||
} else {
|
||||
$result = [
|
||||
'type' => 'requestLame',
|
||||
'message' => 'No member found by that name, hoss',
|
||||
];
|
||||
}
|
||||
|
||||
$zip->close();
|
||||
$zipPath = '../content/' . $name;
|
||||
//trash zip when done
|
||||
unlink($zipPath);
|
||||
} else {
|
||||
$result = [
|
||||
'type' => 'requestLame',
|
||||
'message' => 'Could not open backup. RATS!',
|
||||
];
|
||||
}
|
||||
return $result;
|
||||
}
|
||||
}
|
@ -1,96 +0,0 @@
|
||||
<?php
|
||||
use function _\find;
|
||||
use function _\filter;
|
||||
|
||||
class Sorting
|
||||
{
|
||||
private static $_tags = [];
|
||||
private static $_archive = [];
|
||||
public function __construct()
|
||||
{
|
||||
}
|
||||
|
||||
public static function tags()
|
||||
{
|
||||
$pages = (new Book("../content/pages"))->getContents();
|
||||
foreach ($pages as $page) {
|
||||
$temp = [];
|
||||
$temp = explode(",", $page["tags"]);
|
||||
foreach ($temp as $tag) {
|
||||
$label = trim($tag);
|
||||
if (!find(self::$_tags, ["tag_name" => $label])) {
|
||||
array_push(self::$_tags, [
|
||||
"tag_name" => $label,
|
||||
"slug" => StringTools::safeString($label),
|
||||
"pages" => self::tagPages($label, $pages),
|
||||
]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return self::$_tags;
|
||||
}
|
||||
|
||||
private static function tagPages($tag, $pages)
|
||||
{
|
||||
$tagged = [];
|
||||
foreach ($pages as $page) {
|
||||
if (strpos($page["tags"], $tag) !== false) {
|
||||
array_push($tagged, [
|
||||
"title" => $page["title"],
|
||||
"slug" => $page["slug"],
|
||||
"path" => $page["path"],
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
return $tagged;
|
||||
}
|
||||
|
||||
public static function archive()
|
||||
{
|
||||
$pages = (new Book("../content/pages"))->getContents();
|
||||
$years = [];
|
||||
$archive = [];
|
||||
foreach ($pages as $page) {
|
||||
//$year = date("Y", date($page["rawCreated"]));
|
||||
$date = explode("/", $page["path"]);
|
||||
//echo $page["title"] . " : " . $year . "\n";
|
||||
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),
|
||||
]);
|
||||
}
|
||||
}
|
||||
foreach ($years as $year) {
|
||||
$sorted = [];
|
||||
$filtered = filter($pages, ["createdYear" => $year["year"]]);
|
||||
|
||||
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",
|
||||
]);
|
||||
array_push($sorted, [
|
||||
"month" => $month,
|
||||
"full_month" => date("F", date($obj["rawCreated"])),
|
||||
"count" => count($perMonth),
|
||||
"pages" => $perMonth,
|
||||
]);
|
||||
}
|
||||
}
|
||||
array_push(self::$_archive, [
|
||||
"year" => $year["year"],
|
||||
"year_data" => $sorted,
|
||||
]);
|
||||
}
|
||||
return self::$_archive;
|
||||
}
|
||||
}
|
@ -0,0 +1,269 @@
|
||||
<?php
|
||||
|
||||
namespace brain\utility;
|
||||
|
||||
use brain\data\Book;
|
||||
use brain\data\Settings;
|
||||
use Mni\FrontYAML\Parser;
|
||||
|
||||
use function _\filter;
|
||||
use function _\find;
|
||||
|
||||
class Sorting
|
||||
{
|
||||
private static $p_tags = [];
|
||||
private static $p_archive = [];
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
}
|
||||
|
||||
public static function tags()
|
||||
{
|
||||
$pages = (new Book('../content/pages'))->getContents();
|
||||
foreach ($pages as $page) {
|
||||
$temp = [];
|
||||
if (isset($page['tags'])) {
|
||||
$temp = explode(',', $page['tags']);
|
||||
foreach ($temp as $tag) {
|
||||
$label = trim($tag);
|
||||
if (!find(self::$p_tags, ['tag_name' => $label])) {
|
||||
array_push(self::$p_tags, [
|
||||
'tag_name' => $label,
|
||||
'slug' => StringTools::safeString($label),
|
||||
'pages' => self::tagPages($label, $pages),
|
||||
]);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return self::$p_tags;
|
||||
}
|
||||
|
||||
private static function tagPages($tag, $pages)
|
||||
{
|
||||
$tagged = [];
|
||||
foreach ($pages as $page) {
|
||||
if (isset($page['tags'])) {
|
||||
if (strpos($page['tags'], $tag) !== false) {
|
||||
array_push($tagged, [
|
||||
'title' => $page['title'],
|
||||
'slug' => $page['slug'],
|
||||
'path' => $page['path'],
|
||||
'feature' => $page['feature'],
|
||||
]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return $tagged;
|
||||
}
|
||||
|
||||
public static function archive()
|
||||
{
|
||||
$pages = (new Book('../content/pages'))->getContents();
|
||||
$years = [];
|
||||
$archive = [];
|
||||
foreach ($pages as $page) {
|
||||
// $year = date("Y", date($page["rawCreated"]));
|
||||
$date = explode('/', $page['path']);
|
||||
// echo $page["title"] . " : " . $year . "\n";
|
||||
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),
|
||||
]
|
||||
);
|
||||
}
|
||||
}
|
||||
foreach ($years as $year) {
|
||||
$sorted = [];
|
||||
$filtered = filter($pages, ['createdYear' => $year['year']]);
|
||||
|
||||
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',
|
||||
]
|
||||
);
|
||||
array_push($sorted, [
|
||||
'month' => $month,
|
||||
'full_month' => date('F', date($obj['rawCreated'])),
|
||||
'count' => count($perMonth),
|
||||
'pages' => $perMonth,
|
||||
]);
|
||||
}
|
||||
}
|
||||
array_push(self::$p_archive, [
|
||||
'year' => $year['year'],
|
||||
'year_data' => $sorted,
|
||||
]);
|
||||
}
|
||||
|
||||
return self::$p_archive;
|
||||
}
|
||||
|
||||
public static function page($page)
|
||||
{
|
||||
$config = new Settings();
|
||||
$settings = $config->getSettings();
|
||||
$pageOption = [];
|
||||
|
||||
$pageInfo = [
|
||||
'keywords' => isset($settings['global']['keywords'])
|
||||
? $settings['global']['keywords']
|
||||
: 'fipamo, blog, jamstack, php, markdown, js',
|
||||
'description' => $settings['global']['descriptions'],
|
||||
'image' => $settings['global']['base_url'] . $settings['global']['background'],
|
||||
'baseURL' => $settings['global']['base_url'],
|
||||
];
|
||||
$tags = [];
|
||||
if (isset($page['tags'])) {
|
||||
$taglist = explode(',', $page['tags']);
|
||||
foreach ($taglist as $tag) {
|
||||
$label = trim($tag);
|
||||
array_push($tags, [
|
||||
'label' => $label . ' ',
|
||||
'slug' => StringTools::safeString($label),
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
$meta = [
|
||||
'who' => $page['author'],
|
||||
'when' => $page['created'],
|
||||
'tags' => $tags,
|
||||
];
|
||||
|
||||
// render markdown content and clean it
|
||||
$parser = new Parser();
|
||||
$rendered = $parser->parse($page['content']);
|
||||
$sanitizer = \HtmlSanitizer\Sanitizer::create([
|
||||
'extensions' => ['basic', 'image', 'list', 'code'],
|
||||
'tags' => [
|
||||
'img' => [
|
||||
'allowed_attributes' => ['src', 'alt', 'title', 'class'],
|
||||
'allowed_hosts' => null,
|
||||
],
|
||||
],
|
||||
]);
|
||||
|
||||
$preclean = $sanitizer->sanitize($rendered->getContent());
|
||||
|
||||
// just clean renderd string for now, Sanitize doesn't like relative img urls
|
||||
// so another option is needed
|
||||
$cleaned = strip_tags($rendered->getContent(), [
|
||||
'a',
|
||||
'br',
|
||||
'p',
|
||||
'strong',
|
||||
'br',
|
||||
'img',
|
||||
'iframe',
|
||||
'ul',
|
||||
'li',
|
||||
'i',
|
||||
'em',
|
||||
'h1',
|
||||
'h2',
|
||||
'h3',
|
||||
'pre',
|
||||
'code',
|
||||
]);
|
||||
|
||||
// if page feature isn't empty, find image from list and set it as background image
|
||||
// if it is empty, just use global background
|
||||
if ($page['feature'] != '' || $page['feature'] != null) {
|
||||
$media = explode(',', $page['feature']);
|
||||
$set = false;
|
||||
foreach ($media as $file) {
|
||||
$item = trim($file);
|
||||
$ext = pathinfo($item, PATHINFO_EXTENSION);
|
||||
|
||||
if ($ext != 'mp4' && !$set) {
|
||||
$pageInfo['image'] = $pageInfo['baseURL'] . $item;
|
||||
$set = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ($page['layout'] == 'index') {
|
||||
// $template = $this->theme . "/index.twig";
|
||||
// $location = "../public/index.html";
|
||||
// $dir = null;
|
||||
|
||||
$recent = [];
|
||||
$featured = [];
|
||||
$limit = 4;
|
||||
$pages = (new Book())->getContents();
|
||||
foreach ($pages as $item) {
|
||||
if (!$item['deleted'] &&
|
||||
$item['published'] &&
|
||||
$item['menu'] != 'true'
|
||||
) {
|
||||
if (count($recent) < $limit) {
|
||||
array_push($recent, [
|
||||
'path' => $item['path'],
|
||||
'slug' => $item['slug'],
|
||||
'title' => $item['title'],
|
||||
'feature' => $item['feature'],
|
||||
]);
|
||||
}
|
||||
|
||||
if ($item['featured'] == true) {
|
||||
if (count($featured) < $limit) {
|
||||
array_push($featured, [
|
||||
'path' => $item['path'],
|
||||
'slug' => $item['slug'],
|
||||
'title' => $item['title'],
|
||||
'feature' => $item['feature'],
|
||||
]);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$pageOptions = [
|
||||
'title' => $page['title'],
|
||||
'background' => $page['feature'],
|
||||
'content' => $page['html'], // $cleaned,
|
||||
'meta' => $meta,
|
||||
'recent' => $recent,
|
||||
'featured' => $featured,
|
||||
'info' => $pageInfo,
|
||||
'menu' => $settings['menu'],
|
||||
'dynamicRender' => $settings['global']['dynamicRender'],
|
||||
'media' => $page['media'],
|
||||
'files' => $page['docs'],
|
||||
];
|
||||
} else {
|
||||
// $template = $this->theme . "/page.twig";
|
||||
// $location = "../public/" . $page["path"] . "/" . $page["slug"] . ".html";
|
||||
// $dir = "../public/" . $page["path"];
|
||||
$pageOptions = [
|
||||
'title' => $page['title'],
|
||||
'background' => $page['feature'],
|
||||
'content' => $page['html'], // $cleaned,
|
||||
'meta' => $meta,
|
||||
'info' => $pageInfo,
|
||||
'menu' => $settings['menu'],
|
||||
'dynamicRender' => $settings['global']['dynamicRender'],
|
||||
'media' => $page['media'],
|
||||
'files' => $page['docs'],
|
||||
];
|
||||
}
|
||||
|
||||
return $pageOptions;
|
||||
}
|
||||
}
|
@ -1,92 +0,0 @@
|
||||
<?php
|
||||
use ReallySimpleJWT\Token;
|
||||
use ReallySimpleJWT\Exception\BuildException;
|
||||
//include "brain/data/Auth.inc.php";
|
||||
|
||||
class StringTools
|
||||
{
|
||||
public static function createUUID()
|
||||
{
|
||||
if (function_exists("com_create_guid") === true) {
|
||||
return trim(com_create_guid(), "{}");
|
||||
}
|
||||
|
||||
return sprintf(
|
||||
"%04X%04X-%04X-%04X-%04X-%04X%04X%04X",
|
||||
mt_rand(0, 65535),
|
||||
mt_rand(0, 65535),
|
||||
mt_rand(0, 65535),
|
||||
mt_rand(16384, 20479),
|
||||
mt_rand(32768, 49151),
|
||||
mt_rand(0, 65535),
|
||||
mt_rand(0, 65535),
|
||||
mt_rand(0, 65535)
|
||||
);
|
||||
}
|
||||
|
||||
public static function safeString($string)
|
||||
{
|
||||
return strtolower(
|
||||
trim(
|
||||
preg_replace(
|
||||
"~[^0-9a-z]+~i",
|
||||
"_",
|
||||
html_entity_decode(
|
||||
preg_replace(
|
||||
"~&([a-z]{1,2})(?:acute|cedil|circ|grave|lig|orn|ring|slash|th|tilde|uml);~i",
|
||||
'$1',
|
||||
htmlentities($string, ENT_QUOTES, "UTF-8")
|
||||
),
|
||||
ENT_QUOTES,
|
||||
"UTF-8"
|
||||
)
|
||||
),
|
||||
"-"
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
public static function randomString(int $length)
|
||||
{
|
||||
$alphanum =
|
||||
"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";
|
||||
$special = '*&!@%^#$';
|
||||
$alphabet = $alphanum . $special;
|
||||
$random = openssl_random_pseudo_bytes($length);
|
||||
$alphabet_length = strlen($alphabet);
|
||||
$string = "";
|
||||
for ($i = 0; $i < $length; ++$i) {
|
||||
$string .= $alphabet[ord($random[$i]) % $alphabet_length];
|
||||
}
|
||||
|
||||
//secret needs to be a valid token
|
||||
if ($length == 12) {
|
||||
try {
|
||||
$secret = Token::create(12, $string, time() + 3600, "localhost");
|
||||
return $string;
|
||||
} catch (BuildException $e) {
|
||||
//bad secret, so try agiain
|
||||
//echo "BAD STRING";
|
||||
return self::randomString(12);
|
||||
}
|
||||
|
||||
if (Token::validate($key, $string)) {
|
||||
return $string;
|
||||
} else {
|
||||
return self::randomString(12);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static function checkSpecial($string)
|
||||
{
|
||||
$specials = ["*", "&", "!", "@", "%", "^", "#", "$"];
|
||||
$valid = false;
|
||||
foreach ($specials as $item) {
|
||||
if (strpos($string, $item)) {
|
||||
return $valid = true;
|
||||
}
|
||||
}
|
||||
return $valid;
|
||||
}
|
||||
}
|
@ -0,0 +1,131 @@
|
||||
<?php
|
||||
|
||||
namespace brain\utility;
|
||||
|
||||
use ReallySimpleJWT\Token;
|
||||
use ReallySimpleJWT\Exception\BuildException;
|
||||
use Mni\FrontYAML\Parser;
|
||||
|
||||
class StringTools
|
||||
{
|
||||
public static function createUUID()
|
||||
{
|
||||
if (function_exists('com_create_guid') === true) {
|
||||
return trim(com_create_guid(), '{}');
|
||||
}
|
||||
|
||||
return sprintf(
|
||||
'%04X%04X-%04X-%04X-%04X-%04X%04X%04X',
|
||||
mt_rand(0, 65535),
|
||||
mt_rand(0, 65535),
|
||||
mt_rand(0, 65535),
|
||||
mt_rand(16384, 20479),
|
||||
mt_rand(32768, 49151),
|
||||
mt_rand(0, 65535),
|
||||
mt_rand(0, 65535),
|
||||
mt_rand(0, 65535)
|
||||
);
|
||||
}
|
||||
|
||||
public static function sanitizeContent($entry)
|
||||
{
|
||||
$parser = new Parser();
|
||||
$rendered = $parser->parse($entry);
|
||||
$sanitizer = HtmlSanitizer\Sanitizer::create([
|
||||
'extensions' => ['basic', 'image', 'list', 'code'],
|
||||
'tags' => [
|
||||
'img' => [
|
||||
'allowed_attributes' => ['src', 'alt', 'title', 'class'],
|
||||
'allowed_hosts' => null,
|
||||
],
|
||||
],
|
||||
]);
|
||||
|
||||
$preclean = $sanitizer->sanitize($rendered->getContent());
|
||||
|
||||
$cleaned = strip_tags($rendered->getContent(), [
|
||||
'a',
|
||||
'br',
|
||||
'p',
|
||||
'strong',
|
||||
'br',
|
||||
'img',
|
||||
'iframe',
|
||||
'ul',
|
||||
'li',
|
||||
'i',
|
||||
'h1',
|
||||
'h2',
|
||||
'h3',
|
||||
'pre',
|
||||
'code',
|
||||
]);
|
||||
|
||||
return $cleaned;
|
||||
}
|
||||
|
||||
public static function safeString($string)
|
||||
{
|
||||
return strtolower(
|
||||
trim(
|
||||
preg_replace(
|
||||
'~[^0-9a-z]+~i',
|
||||
'_',
|
||||
html_entity_decode(
|
||||
preg_replace(
|
||||
'~&([a-z]{1,2})(?:acute|cedil|circ|grave|lig|orn|ring|slash|th|tilde|uml);~i',
|
||||
'$1',
|
||||
htmlentities($string, ENT_QUOTES, 'UTF-8')
|
||||
),
|
||||
ENT_QUOTES,
|
||||
'UTF-8'
|
||||
)
|
||||
),
|
||||
'-'
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
public static function randomString(int $length)
|
||||
{
|
||||
$alphanum = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789';
|
||||
$special = '*&!@%^#$';
|
||||
$alphabet = $alphanum . $special;
|
||||
$random = openssl_random_pseudo_bytes($length);
|
||||
$alphabet_length = strlen($alphabet);
|
||||
$string = '';
|
||||
for ($i = 0; $i < $length; ++$i) {
|
||||
$string .= $alphabet[ord($random[$i]) % $alphabet_length];
|
||||
}
|
||||
|
||||
//secret needs to be a valid token
|
||||
if ($length == 12) {
|
||||
try {
|
||||
$secret = Token::create(12, $string, time() + 3600, 'localhost');
|
||||
return $string;
|
||||
} catch (BuildException $e) {
|
||||
//bad secret, so try agiain
|
||||
//echo "BAD STRING";
|
||||
return self::randomString(12);
|
||||
}
|
||||
|
||||
if (Token::validate($key, $string)) {
|
||||
return $string;
|
||||
} else {
|
||||
return self::randomString(12);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static function checkSpecial($string)
|
||||
{
|
||||
$specials = ['*', '&', '!', '@', '%', '^', '#', '$'];
|
||||
$valid = false;
|
||||
foreach ($specials as $item) {
|
||||
if (strpos($string, $item)) {
|
||||
return $valid = true;
|
||||
}
|
||||
}
|
||||
return $valid;
|
||||
}
|
||||
}
|
@ -1,54 +1,49 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<title>
|
||||
{% block title %}
|
||||
{{ title }}
|
||||
{% endblock %}
|
||||
</title>
|
||||
{% block stylesheets %}{% endblock %}
|
||||
</head>
|
||||
<body>
|
||||
<div id="notifications" class="notifications">
|
||||
<div id="notifyMessage" class="notifyMessage">
|
||||
<div id="notify-good" class="notify-icon">
|
||||
<svg viewbox="0 0 20 20" class="icons"><use xlink:href="/assets/images/global/sprite.svg#entypo-emoji-flirt"/></svg>
|
||||
</div>
|
||||
<div id="notify-lame" class="notify-icon">
|
||||
<svg viewbox="0 0 20 20" class="icons"><use xlink:href="/assets/images/global/sprite.svg#entypo-emoji-sad"/></svg>
|
||||
</div>
|
||||
<div id="notify-working" class="notify-icon">
|
||||
<svg viewbox="0 0 20 20" class="icons"><use xlink:href="/assets/images/global/sprite.svg#entypo-cog"/></svg>
|
||||
</div>
|
||||
<p id="message-text"></p>
|
||||
</div>
|
||||
</div>
|
||||
<div id="main-content" class="main-container">
|
||||
<section id="dash-index-content">
|
||||
<header id="header">
|
||||
<div id="wrapper">
|
||||
<div id="left">
|
||||
<a href="/dashboard"><img id="the-logo" src="/assets/images/global/the-logo.svg"/></a>
|
||||
</div>
|
||||
|
||||
<div id="right">
|
||||
{% if status %}
|
||||
{% apply spaceless %}
|
||||
{{ include("dash/partials/navigation.twig") }}
|
||||
{% endapply %}
|
||||
{% endif %}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</header>
|
||||
{% block mainContent %}{% endblock %}
|
||||
</section>
|
||||
|
||||
|
||||
</div>
|
||||
|
||||
<footer></footer>
|
||||
{% block javascripts %}{% endblock %}
|
||||
</body>
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="theme-color" content="#FFFFFF"/>
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
<title>
|
||||
{% block title %}
|
||||
{{ title }}
|
||||
{% endblock %}
|
||||
</title>
|
||||
{% block stylesheets %}{% endblock %}
|
||||
</head>
|
||||
<body>
|
||||
{% if status %}
|
||||
<header>
|
||||
{% apply spaceless %}
|
||||
<nav role="top-nav">
|
||||
<div role="nav-left">
|
||||
<a href="/dashboard"><img id="the-logo" src="/assets/images/global/fipamo-logo.svg"/></a>
|
||||
</div>
|
||||
<div role="title">
|
||||
<h1>{{ title }}</h1>
|
||||
</div>
|
||||
<div role="nav-right">
|
||||
{% if status %}
|
||||
{% apply spaceless %}
|
||||
{{ include("dash/partials/navigation.twig") }}
|
||||
{% endapply %}
|
||||
{% endif %}
|
||||
</div>
|
||||
</nav>
|
||||
<div role="notify">
|
||||
{% apply spaceless %}
|
||||
{{ include("dash/partials/notifications.twig") }}
|
||||
{% endapply %}
|
||||
</div>
|
||||
{% endapply %}
|
||||
{% endif %}
|
||||
</header>
|
||||
<main>
|
||||
{% apply spaceless %}
|
||||
{% block mainContent %}{% endblock %}
|
||||
{% endapply %}
|
||||
</main>
|
||||
<footer></footer>
|
||||
<script type="module" src="/assets/scripts/dash.js"></script>
|
||||
</body>
|
||||
</html>
|
@ -1,85 +1,80 @@
|
||||
{% extends "dash/_frame.twig" %}
|
||||
|
||||
{% block title %}
|
||||
{{ title }}
|
||||
{{ title }}
|
||||
{% endblock %}
|
||||
|
||||
{% block stylesheets %}
|
||||
<link rel="stylesheet" type="text/css" href="/assets/css/dash.css?=adfdfa">
|
||||
{% endblock %}
|
||||
<link rel="stylesheet" type="text/css" href="/assets/css/dash/start.css?=vdthg">
|
||||
{% endblock %}
|
||||
|
||||
{% block mainContent %}
|
||||
<div id="post-index">
|
||||
<div id="post-index-wrapper">
|
||||
<div id="post-index-menu">
|
||||
<a href="/dashboard/pages/all">All Pages ({{ stats['all'] }})</a>
|
||||
.
|
||||
<a href="/dashboard/pages/published">Published ({{ stats['published'] }})</a>
|
||||
.
|
||||
<a href="/dashboard/pages/deleted">Deleted ({{ stats['deleted'] }})</a>
|
||||
</div>
|
||||
<div id="posts-list">
|
||||
{% for page in pages %}
|
||||
<a class="page-link" href="/dashboard/page/edit/{{ page.uuid }}">
|
||||
<div class="page-bg" style="background: url({{ page.feature }}) no-repeat center center / cover">
|
||||
<div id="meta">
|
||||
<span>
|
||||
{{ page.updated }}
|
||||
</span>
|
||||
<label>
|
||||
{{ page.title }}
|
||||
</label>
|
||||
{% block mainContent %}
|
||||
<section role="book-index-header">
|
||||
<div role="book-index-header-left">
|
||||
{{ filter }}
|
||||
Pages
|
||||
</div>
|
||||
<div role="book-index-header-right">
|
||||
<a href="/dashboard/pages/all" title="view all pages">
|
||||
<button>
|
||||
<i class="ti ti-clipboard-list"></i>
|
||||
{{ stats['all'] }}
|
||||
</button>
|
||||
</a>
|
||||
<a href="/dashboard/pages/published" title="view publised pages">
|
||||
<button>
|
||||
<i class="ti ti-clipboard-check"></i>
|
||||
{{ stats['published'] }}
|
||||
</button>
|
||||
</a>
|
||||
<a href="/dashboard/pages/deleted" title="view deleted pages">
|
||||
<button>
|
||||
<i class="ti ti-clipboard-off"></i>
|
||||
{{ stats['deleted'] }}
|
||||
</button>
|
||||
</a>
|
||||
</section>
|
||||
<section role="book-index-pages">
|
||||
{% for page in pages %}
|
||||
{% if page.media[0].type == 'mp4' %}
|
||||
<a href="/dashboard/page/edit/{{ page.uuid }}" id="{{ page.uuid }}" class="page-link">
|
||||
<div class="page-video">
|
||||
<video class="post-video" loop muted autoplay>
|
||||
<source src="{{ page.media[0].file }}" type="video/mp4">
|
||||
|
||||
{% if page.menu == 'true' %}
|
||||
{% set menu = "true" %}
|
||||
{% else %}
|
||||
{% set menu = "false" %}
|
||||
{% endif %}
|
||||
{% if page.published == 'true' %}
|
||||
{% set published = "true" %}
|
||||
{% else %}
|
||||
{% set published = "false" %}
|
||||
{% endif %}
|
||||
{% if page.featured == 'true' %}
|
||||
{% set featured = "true" %}
|
||||
{% else %}
|
||||
{% set featured = "false" %}
|
||||
{% endif %}
|
||||
<div id="options">
|
||||
<span class="meta-options" data-active="{{ menu }}">
|
||||
Menu Item</span>
|
||||
<span class="meta-options" data-active="{{ published }}">
|
||||
Published</span>
|
||||
<span class="meta-options" data-active="{{ featured }}">
|
||||
Featured</span>
|
||||
</div>
|
||||
<span>{{ page.prettyDate }}</span>
|
||||
Sorry, your browser doesn't support embedded videos.
|
||||
</video>
|
||||
<div id="meta">
|
||||
{{ include("dash/partials/recent-meta.twig") }}
|
||||
</div>
|
||||
</div>
|
||||
</a>
|
||||
{% else %}
|
||||
<a class="page-link" href="/dashboard/page/edit/{{ page.uuid }}">
|
||||
<div class="page-bg" style="background: url({{ page.media[0].file }}) no-repeat center center / cover #fc6399">
|
||||
<div id="meta">
|
||||
{{ include("dash/partials/recent-meta.twig") }}
|
||||
</div>
|
||||
</div>
|
||||
</a>
|
||||
{% endif %}
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</a>
|
||||
{% endfor %}
|
||||
{% if numOfPages > 1 %}
|
||||
<div class="paginate">
|
||||
<a class="page-btns" href="/dashboard/pages/{{ paginate['sort'] }}/{{ paginate['prevPage'] }}">
|
||||
<svg viewbox="0 0 20 20" class="icons"><use xlink:href="/assets/images/global/sprite.svg#entypo-chevron-left"/></svg>
|
||||
</a>
|
||||
<span class="count">
|
||||
{{ currentPage }}
|
||||
of
|
||||
{{ numOfPages }}
|
||||
</span>
|
||||
<a class="page-btns" href="/dashboard/pages/{{ paginate['sort'] }}/{{ paginate['nextPage'] }}">
|
||||
<svg viewbox="0 0 20 20" class="icons"><use xlink:href="/assets/images/global/sprite.svg#entypo-chevron-right"/></svg>
|
||||
</a>
|
||||
</div>
|
||||
{% endif %}
|
||||
{% endfor %}
|
||||
{% if numOfPages > 1 %}
|
||||
<div role="paginate">
|
||||
<a class="page-btns" href="/dashboard/pages/{{ paginate['sort'] }}/{{ paginate['prevPage'] }}">
|
||||
<i class="ti ti-square-arrow-left"></i>
|
||||
</a>
|
||||
<span class="count">
|
||||
{{ currentPage }}
|
||||
of
|
||||
{{ numOfPages }}
|
||||
</span>
|
||||
<a class="page-btns" href="/dashboard/pages/{{ paginate['sort'] }}/{{ paginate['nextPage'] }}">
|
||||
<i class="ti ti-square-arrow-right"></i>
|
||||
</a>
|
||||
</div>
|
||||
{% endif %}
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{% endblock %}
|
||||
|
||||
{% block javascripts %}
|
||||
<script src="/assets/scripts/dash.min.js" type="text/javascript"></script>
|
||||
{% endblock %}
|
||||
</section>
|
||||
{% endblock %}
|
||||
|
@ -0,0 +1,120 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta http-equiv='Content-Type' content='text/html; charset=utf-8' />
|
||||
<meta name='viewport' content='width=device-width, initial-scale=1.0' />
|
||||
<title>
|
||||
{{title}}
|
||||
</title>
|
||||
<style type="text/css">
|
||||
/* reset */
|
||||
#outlook a {
|
||||
padding: 0;
|
||||
}
|
||||
/* Force Outlook to provide a "view in browser" menu link. */
|
||||
.ExternalClass {
|
||||
width: 100%;
|
||||
}
|
||||
/* Force Hotmail to display emails at full width */
|
||||
.ExternalClass,
|
||||
.ExternalClass p,
|
||||
.ExternalClass span,
|
||||
.ExternalClass font,
|
||||
.ExternalClass td,
|
||||
.ExternalClass div {
|
||||
line-height: 100%;
|
||||
}
|
||||
/* Forces Hotmail to display normal line spacing. More on that: http://www.emailonacid.com/forum/viewthread/43/ */
|
||||
p {
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
font-size: 0px;
|
||||
line-height: 0px;
|
||||
}
|
||||
/* squash Exact Target injected paragraphs */
|
||||
table td {
|
||||
border-collapse: collapse;
|
||||
}
|
||||
/* Outlook 07, 10 padding issue fix */
|
||||
table {
|
||||
border-collapse: collapse;
|
||||
mso-table-lspace: 0pt;
|
||||
mso-table-rspace: 0pt;
|
||||
}
|
||||
/* remove spacing around Outlook 07, 10 tables */
|
||||
/* bring inline */
|
||||
img {
|
||||
display: block;
|
||||
outline: none;
|
||||
text-decoration: none;
|
||||
-ms-interpolation-mode: bicubic;
|
||||
}
|
||||
a img {
|
||||
border: none;
|
||||
}
|
||||
a {
|
||||
text-decoration: none;
|
||||
color: #000001;
|
||||
}
|
||||
/* text link */
|
||||
a.phone {
|
||||
text-decoration: none;
|
||||
color: #000001 !important;
|
||||
pointer-events: auto;
|
||||
cursor: default;
|
||||
}
|
||||
/* phone link, use as wrapper on phone numbers */
|
||||
span {
|
||||
font-size: 13px;
|
||||
line-height: 17px;
|
||||
font-family: monospace;
|
||||
color: #000001;
|
||||
}
|
||||
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<table cellpadding='0' cellspacing='0' border='0' style="margin:0; padding:0; width:100%; line-height: 100% !important;">
|
||||
<tr>
|
||||
<td valign='top'>
|
||||
{# edge wrapper #}
|
||||
<table cellpadding='0' cellspacing='0' border='0' align='center' width='600' style='background: #374857;'>
|
||||
<tr>
|
||||
<td valign='top' style='vertical-align: top;')>
|
||||
{# info table start #}
|
||||
<table cellpadding='0' cellspacing='0' border='0' align='center' style='width:100%'>
|
||||
<tr>
|
||||
<td valign='top' style='vertical-align: top;text-align: center; padding: 10px'>
|
||||
<span style='font-family: Arial,Helvetica Neue,Helvetica,sans-serif; color:#f5ab35; font-size:20px; font-weight: bold;'>
|
||||
{{ header }}
|
||||
</span>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td valign='top' style='vertical-align: top; background: #161d23; padding:10px;'>
|
||||
<span style='font-family: Arial,Helvetica Neue,Helvetica,sans-serif; color:#cecece; font-size:16px;'>
|
||||
{{ content }}
|
||||
</span>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td valign='top' style='vertical-align: top; padding: 10px;'>
|
||||
<span style='font-family: Arial,Helvetica Neue,Helvetica,sans-serif; color:#b2cce5; font-size:12px;'>
|
||||
{{ footer }}
|
||||
</span>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
{# info table end #}
|
||||
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
</td>
|
||||
|
||||
</tr>
|
||||
</table>
|
||||
</body>
|
||||
</html>
|
@ -0,0 +1,16 @@
|
||||
<div>
|
||||
<a href="/dashboard">
|
||||
<img id="the-logo" src="/assets/images/global/fipamo-logo.svg"/>
|
||||
</a>
|
||||
</div>
|
||||
<form id="init-restore" method="POST">
|
||||
<input type="text" name="restore_member_handle" id="restore_member_handle" placeholder="handle"/><input type="password" name="restore_member_pass" id="restore_member_pass" placeholder="password"/>
|
||||
<div>
|
||||
<label>Grab your backup zip</label>
|
||||
<input id="backup-upload" type="file" name="backup-upload" placeholder="Backup Zip"/>
|
||||
</div>
|
||||
<br/><br/>
|
||||
<button id="blog-restore" data-action='blog-restore' type='submit'>RESTORE</button>
|
||||
<br/><br/>
|
||||
<button class="init-option" id="init-switch-fresh">OR INSTALL FROM SCRATCH</button>
|
||||
</form>
|
@ -0,0 +1,15 @@
|
||||
<div>
|
||||
<a href="/dashboard">
|
||||
<img id="the-logo" src="/assets/images/global/fipamo-logo.svg"/>
|
||||
</a>
|
||||
</div>
|
||||
<form id="init-form" method="POST" onsubmit="return false;">
|
||||
<input type="text" name="new_member_handle" id="new_member_handle" placeholder="handle"/>
|
||||
<input type="text" name="new_member_email" id="new_member_email" placeholder="email"/>
|
||||
<input type="text" name="new_member_pass" id="new_member_pass" placeholder="password"/>
|
||||
<input type="text" name="new_member_pass2" id="new_member_pass2" placeholder="password confirm"/>
|
||||
<input type="text" name="new_member_title" id="new_member_title" placeholder="title"/>
|
||||
<button id="init-blog" data-action='blog-init' type='submit'>SET UP YOUR SITE</button>
|
||||
<br/><br/>
|
||||
<button class="init-option" id="init-switch-restore">RESTORE FROM BACKUP</button>
|
||||
</form>
|
@ -1,11 +1,13 @@
|
||||
<div id="dash-login">
|
||||
<div id="dash-form" class="dash-form">
|
||||
<form id="login" class='login' , name="login" action="/@/dashboard/login" method="POST">
|
||||
<input type="text" name="handle" class="form-control" placeholder="Handle" required ">
|
||||
<input type="password" name="password" class="form-control" placeholder="Password" required">
|
||||
<button id="login-btn" , class='login-btn' , type='submit'>
|
||||
Let's see some ID
|
||||
</button>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
<section role="login">
|
||||
<div>
|
||||
<img id="the-logo" src="/assets/images/global/fipamo-logo.svg"/>
|
||||
</div>
|
||||
<form id="login" class='login' name="login" method="POST" onsubmit="return false;">
|
||||
<input type="text" name="handle" class="form-control" placeholder="Handle" required/>
|
||||
<input type="password" name="password" class="form-control" placeholder="Password" required/>
|
||||
<button id="login-btn" class='login-btn'>
|
||||
ID, PLEASE
|
||||
</button>
|
||||
<a href="/dashboard/reset-password">?</a>
|
||||
</form>
|
||||
</section>
|
||||
|
@ -0,0 +1,21 @@
|
||||
<div>
|
||||
<a href="/dashboard">
|
||||
<img id="the-logo" src="/assets/images/global/fipamo-logo.svg"/>
|
||||
</a>
|
||||
</div>
|
||||
<form id="reset" class='login' name="reset" action="/dashboard/login" method="POST">
|
||||
|
||||
<input type="password" id="new_password" name="new_password" class="form-control" placeholder="New Password" required/>
|
||||
<input type="password" id="new_password2" name="new_password2" class="form-control" placeholder="New Password Confirm" required">
|
||||
<input type="password" id="secret" name="secret" class="form-control" placeholder="Account Secret" required/>
|
||||
<button id="reset-btn" class='login-btn' type='submit'>
|
||||
RESET PASSWORD
|
||||
</button><br/>
|
||||
<p>
|
||||
Use this to get your secret to verify it's you. If your email is set up, the secret will be sent there. If not, the form will be updated automatically(but please set up your email, once you reset your password).
|
||||
</p>
|
||||
<input type="text" id="email" name="email" class="form-control" placeholder="email to verify" required/>
|
||||
<button id="get-secret-btn" class='login-btn' type='submit'>
|
||||
VERIFY EMAIL
|
||||
</button><br/><br/>
|
||||
</form>
|
@ -1,98 +1,206 @@
|
||||
{% extends "dash/_frame.twig" %}
|
||||
{#
|
||||
if page is in 'edit' mode, set variables
|
||||
if not, just make them empty
|
||||
#}
|
||||
if page is in 'edit' mode, set variables
|
||||
if not, just make them empty
|
||||
#}
|
||||
{% if mode == 'edit' %}
|
||||
{% set id = page['id'] %}
|
||||
{% set uuid = page['uuid'] %}
|
||||
{% set slug = page['slug'] %}
|
||||
{% set layout = page['layout'] %}
|
||||
{% set feature = page['feature'] %}
|
||||
{% set _title = page['title'] %}
|
||||
{% set tags = page['tags'] %}
|
||||
{% set content = page['content'] %}
|
||||
{% set date = page['created'] %}
|
||||
{% set id = page['id'] %}
|
||||
{% set uuid = page['uuid'] %}
|
||||
{% set slug = page['slug'] %}
|
||||
{% set layout = page['layout'] %}
|
||||
{% set feature = page['feature'] %}
|
||||
{% set tags = page['tags'] %}
|
||||
{% set content = page['content'] %}
|
||||
{% set date = page['created'] %}
|
||||
{% set updated = page['updated'] %}
|
||||
{% set media = page['media'] %}
|
||||
{% set files = page['docs'] %}
|
||||
{% else %}
|
||||
{% set id = '' %}
|
||||
{% set uuid = '' %}
|
||||
{% set slug = '' %}
|
||||
{% set layout = 'page' %}
|
||||
{% set feature = '' %}
|
||||
{% set title = '' %}
|
||||
{% set tags = '' %}
|
||||
{% set content = '' %}
|
||||
{% set date = '' %}
|
||||
{% set id = '' %}
|
||||
{% set uuid = '' %}
|
||||
{% set slug = '' %}
|
||||
{% set layout = 'page' %}
|
||||
{% set feature = '' %}
|
||||
{% set title = '' %}
|
||||
{% set tags = '' %}
|
||||
{% set content = '' %}
|
||||
{% set date = '' %}
|
||||
{% set updated = '' %}
|
||||
{% set media = '' %}
|
||||
{% set files = '' %}
|
||||
{% endif %}
|
||||
|
||||
{% block title %}
|
||||
{{ title }}
|
||||
{{ title }}
|
||||
{% endblock %}
|
||||
|
||||
{% block stylesheets %}
|
||||
<link rel="stylesheet" type="text/css" href="/assets/css/dash.css?=adfdf">
|
||||
{% endblock %}
|
||||
<link rel="stylesheet" type="text/css" href="/assets/css/dash/start.css?=vdthg">
|
||||
{% endblock %}
|
||||
|
||||
{% block mainContent %}
|
||||
<div id="post-edit-index" data-index="{{ id }}" data-uuid="{{ uuid }}" data-slug="{{ slug }}" data-layout="{{ layout }}">
|
||||
<div id="post-edit-index-wrapper">
|
||||
<div id="post-feature">
|
||||
{% if page['feature'] == null %}
|
||||
<div id="featured-image-drop">
|
||||
DRAG AND DROP IMAGE OR <label for="featured-image-upload">CLICK TO CHOSE</label>
|
||||
</div>
|
||||
{% else %}
|
||||
<div id="featured-new-image-btn">
|
||||
<button id="new-feature-upload">
|
||||
<svg id="new-feature-upload" viewbox="0 0 20 20" class="icons"><use xlink:href="/assets/images/global/sprite.svg#entypo-image-inverted"/></svg>
|
||||
</button>
|
||||
</div>
|
||||
<div id="featured-image-drop">
|
||||
<img id="featured-image" src="{{ feature }}"/>
|
||||
</div>
|
||||
{% block mainContent %}
|
||||
<section data-index="{{ id }}" data-uuid="{{ uuid }}" data-slug="{{ slug }}" data-layout="{{ layout }}" role="file-manager">
|
||||
{% if page['feature'] == null %}
|
||||
<div role="file-drop">
|
||||
<label for="page-files-upload">DRAG AND DROP FILES OR CLICK TO SELECT</label>
|
||||
</div>
|
||||
<label role="list-title">IMAGES AND VIDEO</label>
|
||||
<div role="page-images-list"></div>
|
||||
<label role="list-title">FILES</label>
|
||||
<div role="page-files-list"></div>
|
||||
{% else %}
|
||||
<div role="file-drop">
|
||||
<label for="page-files-upload">DRAG AND DROP FILES OR CLICK TO SELECT</label>
|
||||
</div>
|
||||
<label role="list-title">IMAGES AND VIDEO</label>
|
||||
<div role="page-images-list">
|
||||
{% if media|length > 1 %}
|
||||
{% for item in media %}
|
||||
{% set fileName = item.file|split('/') %}
|
||||
{% if item.type == "mp4" %}
|
||||
|
||||
{% endif %}
|
||||
<div id="{{ loop.index0 }}" class="video-item" data-source="{{ item.file }}">
|
||||
<video>
|
||||
<source src="{{ item.file }}"/>
|
||||
</video>
|
||||
<button id="{{ loop.index0 }}" class="media-remove">
|
||||
<i class="ti ti-x"></i>
|
||||
</button>
|
||||
</div>
|
||||
{% else %}
|
||||
<div id="{{ loop.index0 }}" class="img-item" data-source="{{ item.file }}" style="background: url({{ item.file }}) no-repeat center center / cover">
|
||||
<button id="{{ loop.index0 }}" class="media-remove">
|
||||
<i class="ti ti-x"></i>
|
||||
</button>
|
||||
</div>
|
||||
{% endif %}
|
||||
{% endfor %}
|
||||
{% else %}
|
||||
{% if media[0] != '' %}
|
||||
{% set fileName = media[0].file|split('/') %}
|
||||
{% if media[0].type == "mp4" %}
|
||||
<div id="0" class="video-item" data-source="{{ media[0].file }}">
|
||||
<button id="{{ loop.index0 }}" class="media-remove">X</button>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
<div id="post-header">
|
||||
<div id="post-header-wrapper" class="columns">
|
||||
<div id="post-title" class="column">
|
||||
<label>TITLE</label>
|
||||
<textarea id="post_title" type="text" name="post_title" class="post-edit" placeholder="TITLE">
|
||||
{{- _title -}}
|
||||
</textarea>
|
||||
<label>CREATED</label>
|
||||
<br/>
|
||||
<span id="post-date" type="text">
|
||||
{{ date }}
|
||||
</span>
|
||||
</div>
|
||||
<div id="post-meta" class="column">
|
||||
<label>TAGS</label>
|
||||
<textarea id="post_tags" type="text" name="post_tags" class="form-control" placeholder="tags [comma seperated]">
|
||||
{{- tags -}}
|
||||
</textarea>
|
||||
<label>OPTIONS</label>
|
||||
{% apply spaceless %}
|
||||
{{ include("dash/partials/options.twig") }}
|
||||
{% endapply %}
|
||||
<input id="featured-image-upload" type="file" name="featured-image-upload"/>
|
||||
<input id="post-image-upload" type="file" name="post-image-upload"/>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div id="edit-post">
|
||||
{% apply spaceless %}
|
||||
{{ include("dash/partials/editor.twig") }}
|
||||
{% endapply %}
|
||||
<div id="edit-post-wrapper">
|
||||
<pre><code id="edit-post-text" contenteditable="true"> {{- content -}}</code></pre>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{% endblock %}
|
||||
{% else %}
|
||||
<div id="0" class="img-item" data-source="{{ media[0].file }}" style="background: url({{ media[0].file }}) no-repeat center center / cover">
|
||||
<button id="{{ loop.index0 }}" class="media-remove">
|
||||
<i class="ti ti-x"></i>
|
||||
</button>
|
||||
</div>
|
||||
{% endif %}
|
||||
{% else %}
|
||||
{% endif %}
|
||||
{% endif %}
|
||||
</div>
|
||||
<label role="list-title">FILES</label>
|
||||
<div role="page-files-list">
|
||||
{% if files|length > 1 %}
|
||||
{% for item in files %}
|
||||
{% set fileName = item.file|split('/') %}
|
||||
{% if item.type == "mp3" %}
|
||||
<div id="{{ loop.index0 }}" class="audio-item" data-source="{{ item.file }}">
|
||||
<audio controls>
|
||||
<source src="{{ item.file }}"/>
|
||||
</audio>
|
||||
<button id="{{ loop.index0 }}" class="media-remove">
|
||||
<i class="ti ti-x"></i>
|
||||
</button>
|
||||
</div>
|
||||
{% else %}
|
||||
<div id="{{ loop.index0 }}" class="file-item" data-source="{{ item.file }}">
|
||||
<a href="{{ item.file }}" target="_blank">{{ fileName[6] }}"</a>
|
||||
<button id="{{ loop.index0 }}" class="media-remove">
|
||||
<i class="ti ti-x"></i>
|
||||
</button>
|
||||
</div>
|
||||
{% endif %}
|
||||
{% endfor %}
|
||||
{% else %}
|
||||
{% if files[0] != '' %}
|
||||
{% set fileName = files[0].file|split('/') %}
|
||||
{% if files[0].type == "mp3" %}
|
||||
<div id="0" class="audio-item" data-source="{{ files[0].file }}">
|
||||
<audio controls>
|
||||
<source src="{{ files[0].file }}"/>
|
||||
</audio>
|
||||
<button id="{{ loop.index0 }}" class="media-remove">
|
||||
<i class="ti ti-x"></i>
|
||||
</button>
|
||||
</div>
|
||||
{% else %}
|
||||
<div id="0" class="file-item" data-source="{{ files[0].file }}">
|
||||
<a href="{{ item.file }}" target="_blank">{{ fileName[6] }}"</a>
|
||||
<button id="{{ loop.index0 }}" class="media-remove">
|
||||
<i class="ti ti-x"></i>
|
||||
</button>
|
||||
</div>
|
||||
{% endif %}
|
||||
|
||||
{% block javascripts %}
|
||||
<script src="/assets/scripts/dash.min.js" type="text/javascript"></script>
|
||||
{% endblock %}
|
||||
{% else %}
|
||||
|
||||
{% endif %}
|
||||
{% endif %}
|
||||
|
||||
</div>
|
||||
{% endif %}
|
||||
</section>
|
||||
<section role="page-meta">
|
||||
<div role="page-meta-wrapper">
|
||||
<div role="page-title">
|
||||
<strong>TITLE</strong>
|
||||
<textarea id="post-title-text" type="text" name="post-title-text" class="post-edit" placeholder="TITLE">{{ title }}</textarea>
|
||||
</div>
|
||||
<div role="page-tags">
|
||||
<strong>TAGS</strong>
|
||||
<textarea id="post-tags" type="text" name="post-tags" class="form-control" placeholder="tags [comma seperated]">{{ tags }}</textarea>
|
||||
</div>
|
||||
<div role="page-layouts">
|
||||
<strong>LAYOUTS</strong>
|
||||
<select id="page-templates">
|
||||
{% for view in views %}
|
||||
{% if view == page['layout'] %}
|
||||
<option value={{ view }} selected>{{ view }}</option>
|
||||
{% else %}
|
||||
<option value={{ view }}>{{ view }}</option>
|
||||
{% endif %}
|
||||
|
||||
{% endfor %}
|
||||
</select>
|
||||
</div>
|
||||
<div role="page-options">
|
||||
<strong>OPTIONS</strong>
|
||||
{% apply spaceless %}
|
||||
{{ include("dash/partials/options.twig") }}
|
||||
{% endapply %}
|
||||
</div>
|
||||
<div role="page-updated">
|
||||
<strong>UPDATED</strong>
|
||||
<span id="post-date" type="text">
|
||||
{{ updated }}
|
||||
</span>
|
||||
</div>
|
||||
<div role="page-created">
|
||||
<strong>CREATED</strong>
|
||||
<span id="post-date" type="text">
|
||||
{{ date }}
|
||||
</span>
|
||||
<input id="page-files-upload" type="file" name="page-files-upload" multiple/>
|
||||
<input id="post-image-upload" type="file" name="post-image-upload"/>
|
||||
<input id="form_token" name="token" type="hidden" value="{{ token }}"></div>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
<section role="text-editor">
|
||||
{% apply spaceless %}
|
||||
{{ include("dash/partials/editor.twig") }}
|
||||
{% endapply %}
|
||||
<div role="edit-post-wrapper">
|
||||
<textarea id="edit" spellcheck="false" class="language-md">{{ content }}</textarea>
|
||||
<pre id="highlight">
|
||||
<code id="highlight-content" class="language-md"></code>
|
||||
</pre>
|
||||
</div>
|
||||
</section>
|
||||
{% endblock %}
|
||||
|
@ -1,45 +1,38 @@
|
||||
<div id="edit-control">
|
||||
<button id="edit-bold" class="content-editor-btn-text editor-button" title="bold">B</button>
|
||||
<button id="edit-italic" class="content-editor-btn-text editor-button" title="italic">I</button>
|
||||
<button id="edit-strikethrough" class="content-editor-btn-text editor-button" title="strikethrough">D</button>
|
||||
<div role="text-editor-control">
|
||||
<button id="edit-bold" class="content-editor-btn-text editor-button" title="bold">
|
||||
<i id="edit-bold" class="ti ti-bold"></i>
|
||||
</button>
|
||||
<button id="edit-italic" class="content-editor-btn-text editor-button" title="italic">
|
||||
<i id="edit-italic" class="ti ti-italic"></i>
|
||||
</button>
|
||||
<button id="edit-strikethrough" class="content-editor-btn-text editor-button" title="strikethrough">
|
||||
<i id="edit-strikethrough" class="ti ti-strikethrough"></i>
|
||||
</button>
|
||||
<button id="edit-link" class="content-editor-btn-icon editor-button" title="insert link">
|
||||
<svg id="edit-link" viewbox="0 0 20 20" class="icons">
|
||||
<use id="edit-link" xlink:href="/assets/images/global/sprite.svg#entypo-link"/>
|
||||
</svg>
|
||||
<i id="edit-link" class="ti ti-link"></i>
|
||||
</button>
|
||||
<button id="edit-header1" class="content-editor-btn-text editor-button" title="header 1">
|
||||
<i id="edit-header1" class="ti ti-h-1"></i>
|
||||
</button>
|
||||
<button id="edit-header2" class="content-editor-btn-text editor-button" title="header 2">
|
||||
<i id="edit-header2" class="ti ti-h-2"></i>
|
||||
</button>
|
||||
<button id="edit-header3" class="content-editor-btn-text editor-button" title="header 3">
|
||||
<i id="edit-header3" class="ti ti-h-3"></i>
|
||||
</button>
|
||||
<button id="edit-header1" class="content-editor-btn-text editor-button" title="header 1">H1</button>
|
||||
<button id="edit-header2" class="content-editor-btn-text editor-button" title="header 2">H2</button>
|
||||
<button id="edit-header3" class="content-editor-btn-text editor-button" title="header 3">H3</button>
|
||||
<button id="edit-image" class="content-editor-btn-icon editor-button" title="insert image">
|
||||
<svg id="edit-image" viewbox="0 0 20 20" class="icons">
|
||||
<use id="edit-image" xlink:href="/assets/images/global/sprite.svg#entypo-image"/>
|
||||
</svg>
|
||||
<i id="edit-image" class="ti ti-photo"></i>
|
||||
</button>
|
||||
{% if mode == "edit" %}
|
||||
<button id="edit-update" class="post-sumbit-btn submit-start editor-button" data-action='blog-update' data-id=page.id type='submit' title="bold">
|
||||
<svg id="submit-update" viewbox="0 0 20 20" class="icons">
|
||||
<use id="submit-update" xlink:href="/assets/images/global/sprite.svg#entypo-save" data-action='blog-update' data-id="{{ page['uuid'] }}"/>
|
||||
</svg>
|
||||
<svg id="submit-good" class="icon-hide" viewbox="0 0 20 20" class="icons">
|
||||
<use xlink:href="/assets/images/global/sprite.svg#entypo-thumbs-up"/>
|
||||
</svg>
|
||||
<svg id="submit-error" class="icon-hide" viewbox="0 0 20 20" class="icons">
|
||||
<use xlink:href="/assets/images/global/sprite.svg#entypo-thumbs-down"/>
|
||||
</svg>
|
||||
<button id="edit-update" class="post-sumbit-btn submit-start editor-button" data-action='blog-update' data-id="{{ page['uuid'] }} type='submit' title=" bold">
|
||||
<i id="edit-update" class="ti ti-device-floppy"></i>
|
||||
</button>
|
||||
<button id="edit-delete" class="content-editor-btn-icon editor-button submit-delete" for="post-delete" title='delete post'>
|
||||
<svg id="edit-delete" viewbox="0 0 20 20" class="icons">
|
||||
<use id="edit-delete" xlink:href="/assets/images/global/sprite.svg#entypo-cross"/>
|
||||
</svg>
|
||||
<i id="edit-delete" class="ti ti-x"></i>
|
||||
</button>
|
||||
{% else %}
|
||||
<button id="edit-save" class="post-sumbit-btn submit-start editor-button" data-action='blog-add' type='submit'>
|
||||
<svg id="submit-save" viewbox="0 0 20 20" class="icons">
|
||||
<use id="submit-save" xlink:href="/assets/images/global/sprite.svg#entypo-plus"/>
|
||||
</svg>
|
||||
<i id="edit-save" class="ti ti-file-plus"></i>
|
||||
</button>
|
||||
{% endif %}
|
||||
|
||||
|
||||
|
||||
</div>
|
@ -1,53 +1,30 @@
|
||||
<div id="dash-recent">
|
||||
<div id="recent-list">
|
||||
<div class="recent-header">
|
||||
<h3>Recent</h3>
|
||||
<div class="index-menu">
|
||||
<a href='/dashboard/pages'>View Pages</a>
|
||||
.
|
||||
<a href='/dashboard/page/add/new'>Create Page</a>
|
||||
</div>
|
||||
</div>
|
||||
<br/>
|
||||
{% if data["entryCount"] != 0 %}
|
||||
{% for page in data['pages'] %}
|
||||
<a href="/dashboard/page/edit/{{ page.uuid }}" id="{{ page.uuid }}" class="post-link" style="background: url({{ page.feature }}) no-repeat center center / cover">
|
||||
<div>
|
||||
<label>
|
||||
{{ page.title }}
|
||||
</label>
|
||||
<section role="index-header">
|
||||
<div role="index-header-left">
|
||||
<h1>Recent</h1>
|
||||
</div>
|
||||
<div role="index-header-right"></div>
|
||||
</section>
|
||||
<section role="index-recent-pages">
|
||||
{% if data["entryCount"] != 0 %}
|
||||
{% for page in data['pages'] %}
|
||||
{% if page.media[0].type == 'mp4' %}
|
||||
|
||||
{% if page.menu == 'true' %}
|
||||
{% set menu = "true" %}
|
||||
{% else %}
|
||||
{% set menu = "false" %}
|
||||
{% endif %}
|
||||
{% if page.published == 'true' %}
|
||||
{% set published = "true" %}
|
||||
{% else %}
|
||||
{% set published = "false" %}
|
||||
{% endif %}
|
||||
{% if page.featured == 'true' %}
|
||||
{% set featured = "true" %}
|
||||
{% else %}
|
||||
{% set featured = "false" %}
|
||||
{% endif %}
|
||||
<div id="options">
|
||||
<span class="item-options" data-active="{{ menu }}">
|
||||
Menu Item</span>
|
||||
<span class="item-options" data-active="{{ published }}">
|
||||
Published</span>
|
||||
<span class="item-options" data-active="{{ featured }}">
|
||||
Featured</span>
|
||||
</div>
|
||||
<span>{{ page.updated }}</span>
|
||||
<a href="/dashboard/page/edit/{{ page.uuid }}" id="{{ page.uuid }}" class="post-video-link recent-link">
|
||||
{{ include("dash/partials/recent-meta.twig") }}
|
||||
<video class="post-video" loop muted autoplay>
|
||||
<source src="{{ page.media[0].file }}" type="video/mp4">
|
||||
Sorry, your browser doesn't support embedded videos.
|
||||
</video>
|
||||
</a>
|
||||
|
||||
</div>
|
||||
</a>
|
||||
{% endfor %}
|
||||
{% else %}
|
||||
There are no pages
|
||||
{% endif %}
|
||||
{% else %}
|
||||
<a href="/dashboard/page/edit/{{ page.uuid }}" id="{{ page.uuid }}" class="post-link recent-link" style="background: url({{ page.media[0].file }}) no-repeat center center / cover #fc6399">
|
||||
{{ include("dash/partials/recent-meta.twig") }}
|
||||
</a>
|
||||
{% endif %}
|
||||
{% endfor %}
|
||||
{% else %}
|
||||
There are no pages
|
||||
{% endif %}
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
|
@ -1,31 +1,31 @@
|
||||
{% if mailOption == "option-smtp" %}
|
||||
<div id="mail-smtp" data-enabled='true'>
|
||||
<input type='text' name='smtp-domain' id='smtp-domain' placeholder='domain'value="settings.email.smtp.domain"/>
|
||||
<input type='text' name='smtp-email' id='smtp-email' placeholder='email' value="settings.email.smtp.email" />
|
||||
<input type='text' name='smtp-pass' id='smtp-pass' placeholder='password' value="settings.email.smtp.password"/>
|
||||
<input type='text' name='smtp-domain' id='smtp-domain' placeholder='domain'value="{{mailConfig['smtp']['domain']}}"/>
|
||||
<input type='text' name='smtp-email' id='smtp-email' placeholder='email' value="{{mailConfig['smtp']['email']}}" />
|
||||
<input type='text' name='smtp-pass' id='smtp-pass' placeholder='password' value="{{mailConfig['smtp']['password']}}"/>
|
||||
</div>
|
||||
<div id="mail-mg" data-enabled='false'>
|
||||
<input type='text' name='mg-domain' id='mg-domain' placeholder='domain' value="settings.email.mailgun.domain" />
|
||||
<input type='text' name='mg-key' id='mg-key' placeholder='api key' value="settings.email.mailgun.key "/>
|
||||
<input type='text' name='mg-domain' id='mg-domain' placeholder='domain' value="{{mailConfig['mailgun']['domain']}}" />
|
||||
<input type='text' name='mg-key' id='mg-key' placeholder='api key' value="{{mailConfig['mailgun']['key']}}"/>
|
||||
</div>
|
||||
{% elseif(mailOption == 'option-mg') %}
|
||||
<div id="mail-smtp" data-enabled='false'>
|
||||
<input type='text' name='smtp-domain' id='smtp-domain' placeholder='domain'value="settings.email.smtp.domain"/>
|
||||
<input type='text' name='smtp-email' id='smtp-email' placeholder='email' value="settings.email.smtp.email" />
|
||||
<input type='text' name='smtp-pass' id='smtp-pass' placeholder='password' value="settings.email.smtp.password"/>
|
||||
<input type='text' name='smtp-domain' id='smtp-domain' placeholder='domain'value="{{mailConfig['smtp']['domain']}}"/>
|
||||
<input type='text' name='smtp-email' id='smtp-email' placeholder='email' value="{{mailConfig['smtp']['email']}}" />
|
||||
<input type='text' name='smtp-pass' id='smtp-pass' placeholder='password' value="{{mailConfig['smtp']['password']}}"/>
|
||||
</div>
|
||||
<div id="mail-mg" data-enabled='true'>
|
||||
<input type='text' name='mg-domain' id='mg-domain' placeholder='domain' value="settings.email.mailgun.domain" />
|
||||
<input type='text' name='mg-key' id='mg-key' placeholder='api key' value="settings.email.mailgun.key "/>
|
||||
<input type='text' name='mg-domain' id='mg-domain' placeholder='domain' value="{{mailConfig['mailgun']['domain']}}" />
|
||||
<input type='text' name='mg-key' id='mg-key' placeholder='api key' value="{{mailConfig['mailgun']['key']}}"/>
|
||||
</div>
|
||||
{% else %}
|
||||
<div id="mail-smtp" data-enabled='false'>
|
||||
<input type='text' name='smtp-domain' id='smtp-domain' placeholder='domain'value="settings.email.smtp.domain"/>
|
||||
<input type='text' name='smtp-email' id='smtp-email' placeholder='email' value="settings.email.smtp.email" />
|
||||
<input type='text' name='smtp-pass' id='smtp-pass' placeholder='password' value="settings.email.smtp.password"/>
|
||||
<input type='text' name='smtp-domain' id='smtp-domain' placeholder='domain'value="{{mailConfig['smtp']['domain']}}"/>
|
||||
<input type='text' name='smtp-email' id='smtp-email' placeholder='email' value="{{mailConfig['smtp']['email']}}" />
|
||||
<input type='text' name='smtp-pass' id='smtp-pass' placeholder='password' value="{{mailConfig['smtp']['password']}}"/>
|
||||
</div>
|
||||
<div id="mail-mg" data-enabled='false'>
|
||||
<input type='text' name='mg-domain' id='mg-domain' placeholder='domain' value="settings.email.mailgun.domain" />
|
||||
<input type='text' name='mg-key' id='mg-key' placeholder='api key' value="settings.email.mailgun.key "/>
|
||||
<input type='text' name='mg-domain' id='mg-domain' placeholder='domain' value="{{mailConfig['mailgun']['domain']}}" />
|
||||
<input type='text' name='mg-key' id='mg-key' placeholder='api key' value="{{mailConfig['mailgun']['key']}}"/>
|
||||
</div>
|
||||
{% endif %}
|
@ -1,5 +1,57 @@
|
||||
<div id="dash-menu">
|
||||
<a id="settings" href="/dashboard/settings" >Settings</a> .
|
||||
<a id="navigation" href="/dashboard/navigation" >Navigation</a> .
|
||||
<a id="navigation" href="/dashboard/logout" >Log Out</a>
|
||||
<div role="menu">
|
||||
{% if title == "Settings" %}
|
||||
{% apply spaceless %}
|
||||
{{ include("dash/partials/submenu_settings.twig") }}
|
||||
{% endapply %}
|
||||
{% elseif title=="Start" %}
|
||||
{% apply spaceless %}
|
||||
{{ include("dash/partials/submenu_start.twig") }}
|
||||
{% endapply %}
|
||||
{% endif %}
|
||||
<a id="settings" href="/dashboard/settings" title="settings">
|
||||
<button>
|
||||
<i class="ti ti-home-cog"></i>
|
||||
</button>
|
||||
</a>
|
||||
<a id="navigation" href="/dashboard/navigation" title="edit navigation">
|
||||
<button>
|
||||
<i class="ti ti-arrow-autofit-height"></i>
|
||||
</button>
|
||||
</a>
|
||||
<a id="navigation" href="/dashboard/logout" title="log out">
|
||||
<button>
|
||||
<i class="ti ti-logout"></i>
|
||||
</button>
|
||||
</a>
|
||||
</div>
|
||||
|
||||
<button role="menu-toggle">
|
||||
<i class="ti ti-menu-2"></i>
|
||||
</button>
|
||||
|
||||
<div role="mobile-menu">
|
||||
{% if title == "Settings" %}
|
||||
{% apply spaceless %}
|
||||
{{ include("dash/partials/submenu_settings.twig") }}
|
||||
{% endapply %}
|
||||
{% elseif title=="Start" %}
|
||||
{% apply spaceless %}
|
||||
{{ include("dash/partials/submenu_start.twig") }}
|
||||
{% endapply %}
|
||||
{% endif %}
|
||||
<a id="settings" href="/dashboard/settings" title="settings">
|
||||
<button>
|
||||
<i class="ti ti-home-cog"></i>
|
||||
</button>
|
||||
</a>
|
||||
<a id="navigation" href="/dashboard/navigation" title="edit navigation">
|
||||
<button>
|
||||
<i class="ti ti-arrow-autofit-height"></i>
|
||||
</button>
|
||||
</a>
|
||||
<a id="navigation" href="/dashboard/logout" title="log out">
|
||||
<button>
|
||||
<i class="ti ti-logout"></i>
|
||||
</button>
|
||||
</a>
|
||||
</div>
|
@ -0,0 +1,10 @@
|
||||
<div role="notify-message">
|
||||
<div role="notify-icons">
|
||||
<i class="ti ti-mood-smile" role="notify-good"></i>
|
||||
<i class="ti ti-mood-sad" role="notify-notgood"></i>
|
||||
<i class="ti ti-settings" role="notify-working"></i>
|
||||
</div>
|
||||
<div role="notify-text">
|
||||
<span role="response-text">Hey Hey</span>
|
||||
</div>
|
||||
</div>
|
@ -1,35 +1,40 @@
|
||||
{% if page['menu'] %}
|
||||
{% if page['menu'] %}
|
||||
{% set menu = 'true' %}
|
||||
{% else %}
|
||||
{% set menu = 'false' %}
|
||||
{% endif %}
|
||||
|
||||
{% if page['featured'] %}
|
||||
{% if page['featured'] %}
|
||||
{% set featured = 'true' %}
|
||||
{% else %}
|
||||
{% set featured = 'false' %}
|
||||
{% endif %}
|
||||
|
||||
{% if page['published'] %}
|
||||
{% if page['published'] %}
|
||||
{% set published = 'true' %}
|
||||
{% else %}
|
||||
{% set published = 'false' %}
|
||||
{% endif %}
|
||||
|
||||
<div id="post-options">
|
||||
<button id="option-menu-pin" class="option-inactive post-option-btn" data-active="{{ menu }}" title='Pin to Menu'>
|
||||
<svg id="option-page-icon" viewbox="0 0 20 20" class="icons">
|
||||
<use id="option-page-icon" xlink:href="/assets/images/global/sprite.svg#entypo-pin"/>
|
||||
</svg>
|
||||
</button>
|
||||
<button id="option-feature" class="option-inactive post-option-btn" data-active="{{ featured }}" title='Feature'>
|
||||
<svg id="option-feature-icon" viewbox="0 0 20 20" class="icons">
|
||||
<use id="option-feature-icon" xlink:href="/assets/images/global/sprite.svg#entypo-star"/>
|
||||
</svg>
|
||||
</button>
|
||||
<button id="option-published" class="option-inactive post-option-btn" data-active="{{ published }}" title='Published'>
|
||||
<svg id="option-published-icon" viewbox="0 0 20 20" class="icons">
|
||||
<use id="option-published-icon" xlink:href="/assets/images/global/sprite.svg#entypo-eye"/>
|
||||
</svg>
|
||||
</button>
|
||||
</div>
|
||||
<br>
|
||||
<button id="option-menu-pin" class="option-inactive post-option-btn" data-active="{{ menu }}" title='Pin to Menu'>
|
||||
<svg id="option-page-icon" role="icon">
|
||||
<use id="option-page-icon" xlink:href="/assets/images/global/sprite.svg#entypo-add-to-list"/>
|
||||
</svg>
|
||||
</button>
|
||||
<button id="option-feature" class="option-inactive post-option-btn" data-active="{{ featured }}" title='Feature'>
|
||||
<svg id="option-feature-icon" role="icon">
|
||||
<use id="option-feature-icon" xlink:href="/assets/images/global/sprite.svg#entypo-star"/>
|
||||
</svg>
|
||||
</button>
|
||||
<button id="option-published" class="option-inactive post-option-btn" data-active="{{ published }}" title='Published'>
|
||||
<svg id="option-published-icon" role="icon">
|
||||
<use id="option-published-icon" xlink:href="/assets/images/global/sprite.svg#entypo-globe"/>
|
||||
</svg>
|
||||
</button>
|
||||
<a href="/dashboard/page/preview/{{ uuid }}" target="_blank">
|
||||
<button id="option-preview" class="option-inactive post-option-btn" data-active="false" title='preview page'>
|
||||
<svg id="option-preview-icon" role="icon">
|
||||
<use id="option-preview-icon" xlink:href="/assets/images/global/sprite.svg#entypo-eye"/>
|
||||
</svg>
|
||||
</button>
|
||||
</a>
|
||||
|
@ -0,0 +1,37 @@
|
||||
{% if page.menu == 'true' %}
|
||||
{% set menu = "true" %}
|
||||
{% else %}
|
||||
{% set menu = "false" %}
|
||||
{% endif %}
|
||||
{% if page.published == 'true' %}
|
||||
{% set published = "true" %}
|
||||
{% else %}
|
||||
{% set published = "false" %}
|
||||
{% endif %}
|
||||
{% if page.featured == 'true' %}
|
||||
{% set featured = "true" %}
|
||||
{% else %}
|
||||
{% set featured = "false" %}
|
||||
{% endif %}
|
||||
|
||||
<aside>
|
||||
<strong>
|
||||
{{ page.updated }}
|
||||
</strong>
|
||||
<hr/>
|
||||
<strong>
|
||||
{{ page.title }}
|
||||
</strong>
|
||||
<hr/>
|
||||
<button data-active="{{ menu }}">
|
||||
<i class="ti ti-navigation"></i>
|
||||
</button>
|
||||
<button data-active="{{ published }}">
|
||||
<i class="ti ti-world"></i>
|
||||
</button>
|
||||
|
||||
<button data-active="{{ featured }}">
|
||||
<i class="ti ti-star"></i>
|
||||
</button>
|
||||
|
||||
</aside>
|
@ -0,0 +1,11 @@
|
||||
<div role="submenu">
|
||||
<button id="save-toggle" title="save settings">
|
||||
<i class="ti ti-device-floppy"></i>
|
||||
</button>
|
||||
<button id="publish-pages" title="publish site">
|
||||
<i class="ti ti-world-upload"></i>
|
||||
</button>
|
||||
<button id="render-toggle" title="render on save toggle" data-render="{{ renderOnSave }}">
|
||||
<i class="ti ti-circle-dashed"></i>
|
||||
</button>
|
||||
</div>
|
@ -0,0 +1,12 @@
|
||||
<div role="submenu">
|
||||
<a href='/dashboard/pages' title="view pages">
|
||||
<button>
|
||||
<i class="ti ti-book-2"></i>
|
||||
</button>
|
||||
</a>
|
||||
<a href='/dashboard/page/add/new' title="add new page">
|
||||
<button>
|
||||
<i class="ti ti-square-plus"></i>
|
||||
</button>
|
||||
</a>
|
||||
</div>
|
@ -0,0 +1,18 @@
|
||||
{% extends "dash/_frame.twig" %}
|
||||
|
||||
{% block title %}
|
||||
{{ title }}
|
||||
{% endblock %}
|
||||
|
||||
{% block stylesheets %}
|
||||
<link rel="stylesheet" type="text/css" href="/assets/css/dash/start.css">
|
||||
{% endblock %}
|
||||
|
||||
{% block mainContent %}
|
||||
<section role="password-reset">
|
||||
{% apply spaceless %}
|
||||
{{ include("dash/forms/reset.twig") }}
|
||||
{% endapply %}
|
||||
|
||||
</section>
|
||||
{% endblock %}
|
@ -1,123 +1,123 @@
|
||||
{% extends "dash/_frame.twig" %}
|
||||
|
||||
{% if render %}
|
||||
{% set renderOnSave = 'true' %}
|
||||
{% else %}
|
||||
{% set renderOnSave = 'false' %}
|
||||
{% endif %}
|
||||
|
||||
{% block title %}
|
||||
{{ title }}
|
||||
{% endblock %}
|
||||
|
||||
{% block stylesheets %}
|
||||
<link rel="stylesheet" type="text/css" href="/assets/css/dash.css?=adfafd">
|
||||
<link rel="stylesheet" type="text/css" href="/assets/css/dash/start.css?=cvnbm">
|
||||
{% endblock %}
|
||||
|
||||
{% block mainContent %}
|
||||
<div id="settings-actions">
|
||||
<div id="buttons">
|
||||
<button id="save-toggle">
|
||||
<svg id="submit-update" viewbox="0 0 20 20" class="icons">
|
||||
<use id="submit-update" xlink:href="/assets/images/global/sprite.svg#entypo-save"/>
|
||||
</svg>
|
||||
</button>
|
||||
<button id="publish-pages">
|
||||
<svg id="submit-update" viewbox="0 0 20 20" class="icons">
|
||||
<use id="submit-update" xlink:href="/assets/images/global/sprite.svg#entypo-publish"/>
|
||||
</svg>
|
||||
</button>
|
||||
<button id="render-toggle" data-render="{{render}}">
|
||||
<svg id="submit-update" viewbox="0 0 20 20" class="icons">
|
||||
<use id="submit-update" xlink:href="/assets/images/global/sprite.svg#entypo-ccw"/>
|
||||
</svg>
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
<div id="site-background">
|
||||
<label>Site Header</label>
|
||||
<img id="background" src="{{background}}" alt="image for site background" for="background-upload"/>
|
||||
<input id="background-upload" type="file" name="backgrond-upload" />
|
||||
</div>
|
||||
<div id="settings-index">
|
||||
<div id="settings-index-wrapper">
|
||||
<div id="member-settings" class="columns">
|
||||
<div id="member-settings-1" class="column">
|
||||
<label> AVATAR </label>
|
||||
<div id="member-avatar-drop">
|
||||
<img id="avatar" src="{{member['avatar']}}" for="avatar-upload"/>
|
||||
<input id="avatar-upload" type="file" name="avatar-upload" />
|
||||
</div>
|
||||
</div>
|
||||
<div id="member-settings-2" class="column">
|
||||
<label>INFO</label>
|
||||
<input type='text' name='handle' id='settings-handle' placeholder='handle' value="{{member['handle']}}" autofocus />
|
||||
<input type='text' name='email' id='settings-email' placeholder='email' value="{{member['email']}}" autofocus />
|
||||
<input type='text' name='base-url' id='settings-url' placeholder='url' value="{{baseUrl}}" autofocus />
|
||||
<input type='text' name='base-title' id='settings-title' placeholder='site title' value="{{siteTitle}}" autofocus />
|
||||
<textarea id="settings-desc" type='text' name='settings_desc' class='settings-dec' placeholder='description stuff', autofocus>{{desc}}</textarea>
|
||||
</div>
|
||||
<article role="settings">
|
||||
<section role="member-settings">
|
||||
<div role="member-avatar">
|
||||
<div role="avatar" style="background: url({{ member['avatar'] }} ) no-repeat center center / cover"></div>
|
||||
<input id="avatar-upload" type="file" name="avatar-upload"/>
|
||||
</div>
|
||||
<div role="site-background">
|
||||
<div role="background" style="background: url({{ background }} ) no-repeat center center / cover"></div>
|
||||
<input id="background-upload" type="file" name="backgrond-upload"/>
|
||||
</div>
|
||||
<div>
|
||||
<input type='text' name='handle' id='settings-handle' placeholder='handle' value="{{ member['handle'] }}" autofocus/>
|
||||
<input type='text' name='email' id='settings-email' placeholder='email' value="{{ member['email'] }}" autofocus/>
|
||||
<input type='text' name='base-url' id='settings-url' placeholder='url' value="{{ baseUrl }}" autofocus/>
|
||||
<input type='text' name='base-title' id='settings-title' placeholder='site title' value="{{ siteTitle }}" autofocus/>
|
||||
<textarea id="settings-desc" type='text' name='settings_desc' class='settings-dec' placeholder='description stuff' , autofocus>{{ desc }}</textarea>
|
||||
</div>
|
||||
<div id="member-utils" class="columns">
|
||||
<div id="util-1" class="column">
|
||||
<label>BACK UP TOOLS</label> <br />
|
||||
<button id="create-backup">CREATE BACK UP</button><br />
|
||||
{% if lastBackup != '' %}
|
||||
<div class="backup-meta">
|
||||
The last back up was created <a href="/api/v1/files">{{lastBackup}}</a><br />
|
||||
</div>
|
||||
{% else %}
|
||||
<span>span No back ups. Frowny face.</span>
|
||||
{% endif %}
|
||||
</div>
|
||||
<div id="util-2" class="column">
|
||||
<label> MAINTENANCE </label><br />
|
||||
<button id="reindex-pages">REINDEX PAGES</button>
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<button id="create-backup">
|
||||
<i class="ti ti-disc"></i>
|
||||
<span>BACK UP YOUR SITE</span>
|
||||
</button><br/>
|
||||
{% if lastBackup != '' %}
|
||||
LAST BACK UP<br/>
|
||||
<a href="/api/v1/files">{{ lastBackup }}</a><br/>
|
||||
{% else %}
|
||||
<span>span No back ups. Frowny face.</span>
|
||||
{% endif %}
|
||||
</div>
|
||||
<div id="option-settings" class="columns">
|
||||
<div id="theme-settings" class="column">
|
||||
<label>THEMES</label>
|
||||
{% for theme in themes %}
|
||||
{% if theme.name == currentTheme %}
|
||||
<a href="#" id="{{theme.name}}" class="theme-select" data-enabled="true">{{theme['display-name']}}</a>
|
||||
{% else %}
|
||||
<a href="#" id="{{theme.name}}" class="theme-select" data-enabled="false">{{theme['display-name']}}</a>
|
||||
{% endif %}
|
||||
<div role="features">
|
||||
{% if apiStatus is defined and apiStatus == "true" %}
|
||||
<button id="api-access-toggle" title="allow external api" data-enabled="true">
|
||||
<i class="ti ti-phone-incoming"></i>
|
||||
<span id="api-status">API ACCESS ENABLED</span>
|
||||
</button>
|
||||
|
||||
{% endfor %}
|
||||
</div>
|
||||
<div id="mail-settings" class="column">
|
||||
<label>EMAIL</label>
|
||||
{% if mailOption == "option-none" or mailOption == "" %}
|
||||
<a href="#" class="mail-option" id="option-none" data-enabled="true">NONE</a>
|
||||
{% else %}
|
||||
<a href="#" class="mail-option" id="option-none" data-enabled="false">NONE</a>
|
||||
{% endif %}
|
||||
{% if mailOption == "option-mg" or mailOption == "" %}
|
||||
<a href="#" class="mail-option" id="option-mg" data-enabled="true">MAILGUN</a>
|
||||
{% else %}
|
||||
<a href="#" class="mail-option" id="option-mg" data-enabled="false">MAILGUN</a>
|
||||
{% endif %}
|
||||
{% if mailOption == "option-smtp" or mailOption == "" %}
|
||||
<a href="#" class="mail-option" id="option-smtp" data-enabled="true">SMTP</a>
|
||||
{% else %}
|
||||
<button id="api-access-toggle" title="allow external api" data-enabled="false">
|
||||
<i class="ti ti-phone-incoming"></i>
|
||||
<span id="api-status">API ACCESS NOT ENABLED</span>
|
||||
</button>
|
||||
|
||||
{% endif %}
|
||||
{% if dynamicRenderStatus is defined and dynamicRenderStatus == "true" %}
|
||||
<button id="dynamic-render-toggle" title="allow external api" data-enabled="true">
|
||||
<i class="ti ti-arrow-merge"></i>
|
||||
<span id="dynamic-render-status">DYNAMIC PAGE RENDERING</span>
|
||||
</button>
|
||||
|
||||
{% else %}
|
||||
<button id="dynamic-render-toggle" title="allow external api" data-enabled="false">
|
||||
<i class="ti ti-arrow-merge"></i>
|
||||
<span id="dynamic-render-status">STATIC PAGE RENDERING</span>
|
||||
</button>
|
||||
|
||||
{% endif %}
|
||||
</div>
|
||||
<div role="theme">
|
||||
<label>Themes</label><br/>
|
||||
{% for theme in themes %}
|
||||
{% if theme.name == currentTheme %}
|
||||
<button id="{{ theme.name }}" class="theme-select" data-enabled="true">
|
||||
<i class="ti ti-brush"></i>
|
||||
<span>{{ theme['display-name'] }}</span>
|
||||
</button>
|
||||
{% else %}
|
||||
<a href="#" class="mail-option" id="option-smtp" data-enabled="false">SMTP</a>
|
||||
<button href="#" id="{{ theme.name }}" class="theme-select" data-enabled="false">
|
||||
<i class="ti ti-brush-off"></i>
|
||||
<span>{{ theme['display-name'] }}</span>
|
||||
</button>
|
||||
{% endif %}
|
||||
|
||||
{% apply spaceless %}
|
||||
{{ include("dash/partials/mailforms.twig") }}
|
||||
{% endapply %}
|
||||
<button id="send-mail">TEST MAIL</button>
|
||||
</div>
|
||||
{% endfor %}
|
||||
</div>
|
||||
<div role="mail">
|
||||
<label>Email</label><br/>
|
||||
{% if mailOption == "option-none" or mailOption == "" %}
|
||||
<a href="#" class="mail-option" id="option-none" data-enabled="true">NONE</a>
|
||||
{% else %}
|
||||
<a href="#" class="mail-option" id="option-none" data-enabled="false">NONE</a>
|
||||
{% endif %}
|
||||
{% if mailOption == "option-mg" or mailOption == "" %}
|
||||
<a href="#" class="mail-option" id="option-mg" data-enabled="true">MAILGUN</a>
|
||||
{% else %}
|
||||
<a href="#" class="mail-option" id="option-mg" data-enabled="false">MAILGUN</a>
|
||||
{% endif %}
|
||||
{% if mailOption == "option-smtp" or mailOption == "" %}
|
||||
<a href="#" class="mail-option" id="option-smtp" data-enabled="true">SMTP</a>
|
||||
{% else %}
|
||||
<a href="#" class="mail-option" id="option-smtp" data-enabled="false">SMTP</a>
|
||||
{% endif %}
|
||||
|
||||
</div>
|
||||
|
||||
</div>
|
||||
{% endblock %}
|
||||
|
||||
{% block javascripts %}
|
||||
<script src="/assets/scripts/dash.min.js" type="text/javascript"></script>
|
||||
{% apply spaceless %}
|
||||
{{ include("dash/partials/mailforms.twig") }}
|
||||
{% endapply %}
|
||||
<button id="send-mail">
|
||||
<i class="ti ti-mailbox"></i>
|
||||
<span>TEST MAIL</span>
|
||||
</button>
|
||||
</div>
|
||||
<div>
|
||||
<label>API KEY</label>
|
||||
<br/>
|
||||
{{ member['key'] }}
|
||||
<br/>
|
||||
<label>FORM TOKEN</label><br/>
|
||||
{{ ftoken }}
|
||||
</div>
|
||||
</section>
|
||||
</article>
|
||||
{% endblock %}
|
@ -1,25 +1,19 @@
|
||||
{% extends "dash/_frame.twig" %}
|
||||
|
||||
{% block title %}
|
||||
{{ title }}
|
||||
{{ title }}
|
||||
{% endblock %}
|
||||
|
||||
{% block stylesheets %}
|
||||
<link rel="stylesheet" type="text/css" href="/assets/css/dash.css?=tyurtyuryu">
|
||||
{% endblock %}
|
||||
<link rel="stylesheet" type="text/css" href="/assets/css/dash/start.css?=dfdfrtr">
|
||||
{% endblock %}
|
||||
|
||||
{% block mainContent %}
|
||||
<div id="dash-index">
|
||||
<div id="dash-index-wrapper">
|
||||
{% if status %}
|
||||
{{ include("dash/partials/index.twig") }}
|
||||
{% else %}
|
||||
{{ include("dash/forms/login.twig") }}
|
||||
{% endif %}
|
||||
</div>
|
||||
</div>
|
||||
{% endblock %}
|
||||
|
||||
{% block javascripts %}
|
||||
<script src="/assets/scripts/dash.min.js" type="text/javascript"></script>
|
||||
{% endblock %}
|
||||
{% block mainContent %}
|
||||
{% if status %}
|
||||
{% apply spaceless %}
|
||||
{{ include("dash/partials/index.twig") }}
|
||||
{% endapply %}
|
||||
{% else %}
|
||||
{{ include("dash/forms/login.twig") }}
|
||||
{% endif %}
|
||||
{% endblock %}
|
||||
|
@ -1,13 +1,37 @@
|
||||
{
|
||||
"require": {
|
||||
"slim/slim": "4.*",
|
||||
"slim/psr7": "^1.2",
|
||||
"twig/twig": "^3.0",
|
||||
"slim/twig-view": "^3.0",
|
||||
"mnapoli/front-yaml": "^1.8",
|
||||
"lodash-php/lodash-php": "^0.0.7",
|
||||
"rbdwllr/reallysimplejwt": "^4.0",
|
||||
"fightbulc/moment": "^1.33",
|
||||
"tgalopin/html-sanitizer": "^1.4"
|
||||
"name": "are0h/fipamo",
|
||||
"descriptions": "The most chill no database blog framework ever.",
|
||||
"version": "2.6.1-beta",
|
||||
"homepage": "https://fipamo.blog",
|
||||
"authors": [
|
||||
{
|
||||
"name": "Are0h",
|
||||
"homepage": "https://roiskinda.cool"
|
||||
}
|
||||
],
|
||||
"support": {
|
||||
"source": "https://koodu.ubiqueros.com/are0h/Fipamo",
|
||||
"wiki": "https://koodu.ubiqueros.com/are0h/Fipamo/wiki/?action=_pages",
|
||||
"issues": "https://koodu.ubiqueros.com/are0h/Fipamo/issues"
|
||||
},
|
||||
"require": {
|
||||
"slim/slim": "4.*",
|
||||
"slim/psr7": "^1.2",
|
||||
"twig/twig": "^3.0",
|
||||
"slim/twig-view": "^3.0",
|
||||
"mnapoli/front-yaml": "^1.8",
|
||||
"lodash-php/lodash-php": "^0.0.7",
|
||||
"rbdwllr/reallysimplejwt": "^4.0",
|
||||
"tgalopin/html-sanitizer": "^1.4",
|
||||
"phpmailer/phpmailer": "^6.4",
|
||||
"league/commonmark": "^2.1",
|
||||
"symfony/yaml": "^5.4",
|
||||
"olegatro/html-sanitizer-relative": "^1.0",
|
||||
"nesbot/carbon": "^2.62"
|
||||
},
|
||||
"scripts": {
|
||||
"start": [
|
||||
"@php -S localhost:8000 -t public/"
|
||||
]
|
||||
}
|
||||
}
|
||||
|
File diff suppressed because it is too large
Load Diff
File diff suppressed because one or more lines are too long
@ -0,0 +1,2 @@
|
||||
(()=>{class e{constructor(){this.currentSlide=0,this.slides=document.querySelectorAll("#media .slide"),this.start()}start(){this.slides.length>1&&(this.slideInterval=setInterval((()=>{this.slides[this.currentSlide].className="slide hide",this.currentSlide=(this.currentSlide+1)%this.slides.length,this.slides[this.currentSlide].className="slide show"}),3e3))}}document.addEventListener("DOMContentLoaded",(function(){new e}),!1)})();
|
||||
//# sourceMappingURL=ThemeStart.js.map
|
@ -0,0 +1 @@
|
||||
{"mappings":"4BAKIA,KAAKC,aAAe,EACpBD,KAAKE,OAASC,SAASC,iBAAiB,iBACxCJ,KAAKK,QAEPA,QACML,KAAKE,OAAOI,OAAS,IACvBN,KAAKO,cAAgBC,aAAW,KAC9BR,KAAKE,OAAOF,KAAKC,cAAcQ,UAAY,aAC3CT,KAAKC,cAAgBD,KAAKC,aAAe,GAAKD,KAAKE,OAAOI,OAC1DN,KAAKE,OAAOF,KAAKC,cAAcQ,UAAY,eAC1C,OCbTN,SAASO,iBACP,oBACA,WACa,IAAIC,KAEjB","sources":["src/themes/theme-fipamo-default/com/Base.js","src/themes/theme-fipamo-default/com/ThemeStart.js"],"sourcesContent":["export default class Base {\n //--------------------------\n // constructor\n //--------------------------\n constructor() {\n this.currentSlide = 0;\n this.slides = document.querySelectorAll(\"#media .slide\");\n this.start();\n }\n start() {\n if (this.slides.length > 1) {\n this.slideInterval = setInterval(() => {\n this.slides[this.currentSlide].className = \"slide hide\";\n this.currentSlide = (this.currentSlide + 1) % this.slides.length;\n this.slides[this.currentSlide].className = \"slide show\";\n }, 3000);\n }\n }\n //--------------------------\n // methods\n //--------------------------\n\n //--------------------------\n // event handlers\n //--------------------------\n}\n","import Base from \"./Base.js\";\n\ndocument.addEventListener(\n \"DOMContentLoaded\",\n function () {\n var base = new Base();\n },\n false\n);\n"],"names":["this","currentSlide","slides","document","querySelectorAll","start","length","slideInterval","setInterval","className","addEventListener","$b8d4b81eabebe07b$export$2e2bcd8739ae039"],"version":3,"file":"ThemeStart.js.map"}
|
@ -1,2 +0,0 @@
|
||||
!function(){"use strict";function n(n,e){for(var t=0;t<e.length;t++){var o=e[t];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(n,o.key,o)}}var e=function(){function e(){!function(n,e){if(!(n instanceof e))throw new TypeError("Cannot call a class as a function")}(this,e),this.start()}var t,o,r;return t=e,(o=[{key:"start",value:function(){console.log("Connected like F.E.")}}])&&n(t.prototype,o),r&&n(t,r),e}();document.addEventListener("DOMContentLoaded",(function(){new e}),!1)}();
|
||||
//# sourceMappingURL=start.min.js.map
|
File diff suppressed because one or more lines are too long
@ -0,0 +1,18 @@
|
||||
{% extends "frame.twig" %}
|
||||
|
||||
{% block title %}
|
||||
{{ title }}
|
||||
{% endblock %}
|
||||
|
||||
{% block mainContent %}
|
||||
<section>
|
||||
<div class="page-title">
|
||||
<span>{{title}}</span>
|
||||
</div>
|
||||
</section>
|
||||
<article>
|
||||
<div class="page">
|
||||
<p>{{content | raw}}</p>
|
||||
</div>
|
||||
</article>
|
||||
{% endblock %}
|
@ -0,0 +1,60 @@
|
||||
{% extends "frame.twig" %}
|
||||
|
||||
{% block title %}
|
||||
{{ title }}
|
||||
{% endblock %}
|
||||
|
||||
{% block mainContent %}
|
||||
<section>
|
||||
<div class="page-title">
|
||||
<span>{{title}}</span><br>
|
||||
This is a custom temlate
|
||||
</div>
|
||||
</section>
|
||||
<article>
|
||||
<div class="page">
|
||||
<p>{{content | raw}}</p>
|
||||
<div>
|
||||
<div class="page_files">
|
||||
<div class="page_doc">
|
||||
<strong>Files</strong><br/>
|
||||
{% for doc in files %}
|
||||
{% if doc.type != "mp3" %}
|
||||
{% set path = doc.file|split('/') %}
|
||||
<a href="{{doc.file}}">{{path[6]}}</a>
|
||||
|
||||
{% endif %}
|
||||
{% endfor %}
|
||||
</div>
|
||||
<div class="page_sounds">
|
||||
<strong>Sounds</strong><br/>
|
||||
{% for doc in files %}
|
||||
{% if doc.type == "mp3" %}
|
||||
<audio controls>
|
||||
<source src="{{doc.file}}" type="audio/mpeg">
|
||||
Your browser does not support the audio element.
|
||||
</audio>
|
||||
{% endif %}
|
||||
{% endfor %}
|
||||
</div>
|
||||
|
||||
</div>
|
||||
<br/>
|
||||
{{meta['who']}} dropped this {{ meta['when'] }}<br />
|
||||
<strong>tags: </strong>
|
||||
{% for tag in meta['tags'] %}
|
||||
{% if dynamicRender is defined %}
|
||||
{% if dynamicRender == 'true' %}
|
||||
<a href="{{ "/tags/"~tag.slug }}">{{ tag.label }}</a>
|
||||
{% else %}
|
||||
<a href="{{ "/tags/"~tag.slug~".html" }}">{{ tag.label }}</a>
|
||||
{% endif %}
|
||||
{% else %}
|
||||
<a href="{{ "/tags/"~tag.slug~".html" }}">{{ tag.label }}</a>
|
||||
{% endif %}
|
||||
{% endfor %}
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</article>
|
||||
{% endblock %}
|
@ -1,26 +1,62 @@
|
||||
{% extends "fipamo-default/frame.twig" %}
|
||||
{% extends "frame.twig" %}
|
||||
|
||||
{% block title %}
|
||||
{{ title }}
|
||||
{% endblock %}
|
||||
|
||||
{% block mainContent %}
|
||||
<section>
|
||||
<div class="page-title">
|
||||
<span>{{title}}</span>
|
||||
</div>
|
||||
</section>
|
||||
<article>
|
||||
<div class="page">
|
||||
<p>{{content | raw}}</p>
|
||||
<div>
|
||||
{% block mainContent %}
|
||||
<section>
|
||||
<div class="page-title">
|
||||
<span>{{title}}</span>
|
||||
</div>
|
||||
</section>
|
||||
<article>
|
||||
<div class="page">
|
||||
<p>{{content | raw}}</p>
|
||||
<div>
|
||||
<div class="page_files">
|
||||
<div class="page_doc">
|
||||
<strong>Files</strong><br/>
|
||||
{% for doc in files %}
|
||||
{% if doc.type != "mp3" %}
|
||||
{% set path = doc.file|split('/') %}
|
||||
<a href="{{doc.file}}">{{path[6]}}</a>
|
||||
|
||||
{% endif %}
|
||||
{% endfor %}
|
||||
</div>
|
||||
<div class="page_sounds">
|
||||
<strong>Sounds</strong><br/>
|
||||
{% for doc in files %}
|
||||
{% if doc.type == "mp3" %}
|
||||
<audio controls>
|
||||
<source src="{{doc.file}}" type="audio/mpeg">
|
||||
Your browser does not support the audio element.
|
||||
</audio>
|
||||
{% endif %}
|
||||
{% endfor %}
|
||||
</div>
|
||||
|
||||
{{meta['who']}} dropped this {{ meta['when'] }}<br />
|
||||
<strong>tags: </strong>
|
||||
{% for tag in meta['tags'] %}
|
||||
<a href="{{ "/tags/"~tag.slug~".html" }}">{{ tag.label }}</a>
|
||||
{% endfor %}
|
||||
</div>
|
||||
<br/>
|
||||
{{meta['who']}}
|
||||
dropped this
|
||||
{{ meta['when'] }}<br/>
|
||||
<strong>tags:
|
||||
</strong>
|
||||
{% for tag in meta['tags'] %}
|
||||
{% if dynamicRender is defined %}
|
||||
{% if dynamicRender == 'true' %}
|
||||
<a href="{{ "/tags/"~tag.slug }}">{{ tag.label }}</a>
|
||||
{% else %}
|
||||
<a href="{{ "/tags/"~tag.slug~".html" }}">{{ tag.label }}</a>
|
||||
{% endif %}
|
||||
{% else %}
|
||||
<a href="{{ "/tags/"~tag.slug~".html" }}">{{ tag.label }}</a>
|
||||
{% endif %}
|
||||
{% endfor %}
|
||||
|
||||
</div>
|
||||
</article>
|
||||
{% endblock %}
|
||||
</div>
|
||||
</article>
|
||||
{% endblock %}
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,34 @@
|
||||
{
|
||||
"name": "fipamo-dash",
|
||||
"version": "2.6.1-beta",
|
||||
"private": true,
|
||||
"apidoc": {
|
||||
"name": "Fipamo API",
|
||||
"version": "1.0.0",
|
||||
"description": "The most chill API for the most chill blog framework"
|
||||
},
|
||||
"source": "src/com/Start.js",
|
||||
"main": "public/assets/scripts/dash.js",
|
||||
"targets": {
|
||||
"main": {
|
||||
"includeNodeModules": true
|
||||
}
|
||||
},
|
||||
"scripts": {
|
||||
"watch": "parcel watch",
|
||||
"build": "parcel build"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@babel/core": "^7.21.3",
|
||||
"babel-plugin-prismjs": "^2.1.0",
|
||||
"parcel": "^2.8.3",
|
||||
"prettier": "^2.8.4",
|
||||
"stylelint": "^15.3.0",
|
||||
"stylelint-config-standard": "^31.0.0"
|
||||
},
|
||||
"dependencies": {
|
||||
"animejs": "^3.2.1",
|
||||
"prismjs": "^1.29.0",
|
||||
"sortablejs": "^1.15.0"
|
||||
}
|
||||
}
|
File diff suppressed because it is too large
Load Diff
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue