diff --git a/app/Parvula/Repositories/Flatfiles/BaseRepositoryFlatfiles.php b/app/Repositories/Flatfiles/BaseRepositoryFlatfiles.php similarity index 93% rename from app/Parvula/Repositories/Flatfiles/BaseRepositoryFlatfiles.php rename to app/Repositories/Flatfiles/BaseRepositoryFlatfiles.php index 9affac1..ed322f8 100644 --- a/app/Parvula/Repositories/Flatfiles/BaseRepositoryFlatfiles.php +++ b/app/Repositories/Flatfiles/BaseRepositoryFlatfiles.php @@ -1,11 +1,11 @@ set('__time__', $time); diff --git a/app/routes/api/auth.php b/app/routes/api/auth.php index d10d3a6..dea12ef 100644 --- a/app/routes/api/auth.php +++ b/app/routes/api/auth.php @@ -1,11 +1,6 @@ $future->getTimeStamp(), // expiration time 'jti' => JWT::urlsafeB64Encode(random_bytes(32)), // unique identifier 'sub' => $username, // subject - 'scope' => $user->getRoles() + 'scope' => $user->getRoles(), ]; } catch (Exception $e) { die('Could not generate a random string. Is our OS secure?'); diff --git a/app/routes/api/config.php b/app/routes/api/config.php index b560f7e..182cbc3 100644 --- a/app/routes/api/config.php +++ b/app/routes/api/config.php @@ -1,11 +1,10 @@ scope) ? $token->scope : []; diff --git a/app/routes/api/pages.php b/app/routes/api/pages.php index c1bb595..f99c9aa 100644 --- a/app/routes/api/pages.php +++ b/app/routes/api/pages.php @@ -1,15 +1,10 @@ api->json($res, $result->transform(function (Models\Page $page) { + return $this->api->json($res, $result->transform(function (Page $page) { $pageArr = $page->toArray(); if ($page->hasParent()) { $pageArr += [ 'parent' => [ 'href' => '/pages/' . $page->parent->slug - ] + ], ]; } diff --git a/app/routes/api/themes.php b/app/routes/api/themes.php index ef75a3d..d950ead 100644 --- a/app/routes/api/themes.php +++ b/app/routes/api/themes.php @@ -1,9 +1,6 @@ map(['GET', 'POST'], '/{slug:[a-zA-Z0-9\-_\+\/]*}', function ($req, $res, $args) use ($app) { $view = $app['view']; $pages = $app['pages']; diff --git a/app/services.php b/app/services.php index c350fc3..2b9ab02 100644 --- a/app/services.php +++ b/app/services.php @@ -3,16 +3,27 @@ // Register services // ----------------------------- // -namespace Parvula; +namespace App; use DateTime; use Exception; use RuntimeException; -use Pimple\Container; +use Parvula\Models\Page; use Parvula\Models\Config; +use Parvula\FileParser; +use Parvula\Http\APIResponse; +use Parvula\PluginMediator; +use Parvula\Session; +use Pimple\Container; +use Parvula\Parsers; +use Parvula\Services; +use Parvula\ContentParser; use Parvula\FilesSystem as Files; use Monolog\Logger; use Monolog\Handler\StreamHandler; +use function Parvula\listPagesRoot; +use function Parvula\getPluginList; +use function Parvula\listPagesAndChildren; $app['config'] = function (Container $c) { $base = _CONFIG_ . 'system.'; @@ -89,7 +100,7 @@ 'routerCacheFile' => $cacheFile, 'displayErrorDetails' => $c['config']->get('debug', false) ], - 'api' => new Http\APIResponse(), + 'api' => new APIResponse(), 'logger' => $c['loggerHandler'] ]; @@ -208,7 +219,7 @@ function ($arr) { }; $app['auth'] = function (Container $c) { - return new Service\AuthenticationService($c['session'], hash('sha1', '@TODO')); + return new Services\AuthenticationService($c['session'], hash('sha1', '@TODO')); // Service\AuthenticationService($c['session'], hash('sha1', $c['request']->ip . $c['request']->userAgent)); }; @@ -373,7 +384,7 @@ function ($arr) { }); // System date format - $view->registerFunction('pageDateFormat', function (Models\Page $page) use ($config) { + $view->registerFunction('pageDateFormat', function (Page $page) use ($config) { return $page->getDateTime()->format($config->get('dateFormat')); }); diff --git a/composer.json b/composer.json index 40151c1..bac5d0f 100644 --- a/composer.json +++ b/composer.json @@ -42,9 +42,13 @@ }, "autoload": { "psr-4": { - "Parvula\\": "app/Parvula", + "App\\": "app", + "Parvula\\": "core", "Plugins\\": "public/plugins" - } + }, + "files": [ + "core/helpers.php" + ] }, "config": { "preferred-install": "dist" diff --git a/app/Parvula/AccessorTrait.php b/core/AccessorTrait.php similarity index 100% rename from app/Parvula/AccessorTrait.php rename to core/AccessorTrait.php diff --git a/app/Parvula/ArrayableInterface.php b/core/ArrayableInterface.php similarity index 100% rename from app/Parvula/ArrayableInterface.php rename to core/ArrayableInterface.php diff --git a/app/Parvula/Asset.php b/core/Asset.php similarity index 100% rename from app/Parvula/Asset.php rename to core/Asset.php diff --git a/app/Parvula/Cache.php b/core/Cache.php similarity index 100% rename from app/Parvula/Cache.php rename to core/Cache.php diff --git a/app/Parvula/Collections/Collection.php b/core/Collections/Collection.php similarity index 100% rename from app/Parvula/Collections/Collection.php rename to core/Collections/Collection.php diff --git a/app/Parvula/Collections/MongoCollection.php b/core/Collections/MongoCollection.php similarity index 100% rename from app/Parvula/Collections/MongoCollection.php rename to core/Collections/MongoCollection.php diff --git a/app/Parvula/Collections/Traits/PageCollectionTrait.php b/core/Collections/Traits/PageCollectionTrait.php similarity index 100% rename from app/Parvula/Collections/Traits/PageCollectionTrait.php rename to core/Collections/Traits/PageCollectionTrait.php diff --git a/app/Parvula/Console/DevTasks.php b/core/Console/DevTasks.php similarity index 100% rename from app/Parvula/Console/DevTasks.php rename to core/Console/DevTasks.php diff --git a/app/Parvula/Console/Doctor.php b/core/Console/Doctor.php similarity index 100% rename from app/Parvula/Console/Doctor.php rename to core/Console/Doctor.php diff --git a/app/Parvula/ContentParser/ContentParserInterface.php b/core/ContentParser/ContentParserInterface.php similarity index 100% rename from app/Parvula/ContentParser/ContentParserInterface.php rename to core/ContentParser/ContentParserInterface.php diff --git a/app/Parvula/ContentParser/Markdown.php b/core/ContentParser/Markdown.php similarity index 100% rename from app/Parvula/ContentParser/Markdown.php rename to core/ContentParser/Markdown.php diff --git a/app/Parvula/ContentParser/None.php b/core/ContentParser/None.php similarity index 100% rename from app/Parvula/ContentParser/None.php rename to core/ContentParser/None.php diff --git a/app/Parvula/ContentParser/ParvulaParsedownExtra.php b/core/ContentParser/ParvulaParsedownExtra.php similarity index 96% rename from app/Parvula/ContentParser/ParvulaParsedownExtra.php rename to core/ContentParser/ParvulaParsedownExtra.php index 4761120..a2d9092 100644 --- a/app/Parvula/ContentParser/ParvulaParsedownExtra.php +++ b/core/ContentParser/ParvulaParsedownExtra.php @@ -3,6 +3,7 @@ namespace Parvula\ContentParser; use ParsedownExtra; +use function Parvula\url; /** * Extends ParsedownExtra to add link functionalities. diff --git a/app/Parvula/Exceptions/BadObjectCallException.php b/core/Exceptions/BadObjectCallException.php similarity index 100% rename from app/Parvula/Exceptions/BadObjectCallException.php rename to core/Exceptions/BadObjectCallException.php diff --git a/app/Parvula/Exceptions/IOException.php b/core/Exceptions/IOException.php similarity index 100% rename from app/Parvula/Exceptions/IOException.php rename to core/Exceptions/IOException.php diff --git a/app/Parvula/Exceptions/NotFoundException.php b/core/Exceptions/NotFoundException.php similarity index 100% rename from app/Parvula/Exceptions/NotFoundException.php rename to core/Exceptions/NotFoundException.php diff --git a/app/Parvula/Exceptions/PageException.php b/core/Exceptions/PageException.php similarity index 100% rename from app/Parvula/Exceptions/PageException.php rename to core/Exceptions/PageException.php diff --git a/app/Parvula/Exceptions/ParseException.php b/core/Exceptions/ParseException.php similarity index 100% rename from app/Parvula/Exceptions/ParseException.php rename to core/Exceptions/ParseException.php diff --git a/app/Parvula/Exceptions/SectionException.php b/core/Exceptions/SectionException.php similarity index 100% rename from app/Parvula/Exceptions/SectionException.php rename to core/Exceptions/SectionException.php diff --git a/app/Parvula/FileParser.php b/core/FileParser.php similarity index 100% rename from app/Parvula/FileParser.php rename to core/FileParser.php diff --git a/app/Parvula/FilesSystem.php b/core/FilesSystem.php similarity index 100% rename from app/Parvula/FilesSystem.php rename to core/FilesSystem.php diff --git a/app/Parvula/Html.php b/core/Html.php similarity index 100% rename from app/Parvula/Html.php rename to core/Html.php diff --git a/app/Parvula/Http/APIResponse.php b/core/Http/APIResponse.php similarity index 100% rename from app/Parvula/Http/APIResponse.php rename to core/Http/APIResponse.php diff --git a/app/Parvula/IOInterface.php b/core/IOInterface.php similarity index 100% rename from app/Parvula/IOInterface.php rename to core/IOInterface.php diff --git a/app/Parvula/IterableTrait.php b/core/IterableTrait.php similarity index 100% rename from app/Parvula/IterableTrait.php rename to core/IterableTrait.php diff --git a/app/Parvula/Models/Config.php b/core/Models/Config.php similarity index 100% rename from app/Parvula/Models/Config.php rename to core/Models/Config.php diff --git a/app/Parvula/Models/Model.php b/core/Models/Model.php similarity index 100% rename from app/Parvula/Models/Model.php rename to core/Models/Model.php diff --git a/app/Parvula/Models/Page.php b/core/Models/Page.php similarity index 100% rename from app/Parvula/Models/Page.php rename to core/Models/Page.php diff --git a/app/Parvula/Models/Section.php b/core/Models/Section.php similarity index 100% rename from app/Parvula/Models/Section.php rename to core/Models/Section.php diff --git a/app/Parvula/Models/Theme.php b/core/Models/Theme.php similarity index 100% rename from app/Parvula/Models/Theme.php rename to core/Models/Theme.php diff --git a/app/Parvula/Models/User.php b/core/Models/User.php similarity index 100% rename from app/Parvula/Models/User.php rename to core/Models/User.php diff --git a/app/Parvula/PageRenderers/DatabasePageRenderer.php b/core/PageRenderers/DatabasePageRenderer.php similarity index 100% rename from app/Parvula/PageRenderers/DatabasePageRenderer.php rename to core/PageRenderers/DatabasePageRenderer.php diff --git a/app/Parvula/PageRenderers/FlatFilesPageRenderer.php b/core/PageRenderers/FlatFilesPageRenderer.php similarity index 100% rename from app/Parvula/PageRenderers/FlatFilesPageRenderer.php rename to core/PageRenderers/FlatFilesPageRenderer.php diff --git a/app/Parvula/PageRenderers/PageRendererInterface.php b/core/PageRenderers/PageRendererInterface.php similarity index 100% rename from app/Parvula/PageRenderers/PageRendererInterface.php rename to core/PageRenderers/PageRendererInterface.php diff --git a/app/Parvula/Parsers/Json.php b/core/Parsers/Json.php similarity index 100% rename from app/Parvula/Parsers/Json.php rename to core/Parsers/Json.php diff --git a/app/Parvula/Parsers/ParserInterface.php b/core/Parsers/ParserInterface.php similarity index 100% rename from app/Parvula/Parsers/ParserInterface.php rename to core/Parsers/ParserInterface.php diff --git a/app/Parvula/Parsers/Php.php b/core/Parsers/Php.php similarity index 100% rename from app/Parvula/Parsers/Php.php rename to core/Parsers/Php.php diff --git a/app/Parvula/Parsers/Yaml.php b/core/Parsers/Yaml.php similarity index 100% rename from app/Parvula/Parsers/Yaml.php rename to core/Parsers/Yaml.php diff --git a/app/Parvula/Parvula.php b/core/Parvula.php similarity index 100% rename from app/Parvula/Parvula.php rename to core/Parvula.php diff --git a/app/Parvula/Plugin.php b/core/Plugin.php similarity index 100% rename from app/Parvula/Plugin.php rename to core/Plugin.php diff --git a/app/Parvula/PluginMediator.php b/core/PluginMediator.php similarity index 100% rename from app/Parvula/PluginMediator.php rename to core/PluginMediator.php diff --git a/app/Parvula/Repositories/BaseRepository.php b/core/Repositories/BaseRepository.php similarity index 97% rename from app/Parvula/Repositories/BaseRepository.php rename to core/Repositories/BaseRepository.php index 6209dc9..a42dc62 100644 --- a/app/Parvula/Repositories/BaseRepository.php +++ b/core/Repositories/BaseRepository.php @@ -2,8 +2,8 @@ namespace Parvula\Repositories; -abstract class BaseRepository { - +abstract class BaseRepository +{ /** * The repository current's class name model * diff --git a/app/Parvula/Repositories/PageRepositoryTrait.php b/core/Repositories/PageRepositoryTrait.php similarity index 95% rename from app/Parvula/Repositories/PageRepositoryTrait.php rename to core/Repositories/PageRepositoryTrait.php index 350a621..2823f5e 100644 --- a/app/Parvula/Repositories/PageRepositoryTrait.php +++ b/core/Repositories/PageRepositoryTrait.php @@ -2,9 +2,6 @@ namespace Parvula\Repositories; -use Iterator; -use Parvula\ArrayableInterface; -use Parvula\Models\Page; use Parvula\PageRenderers\PageRendererInterface; // abstract class PageRepository extends BaseRepository implements Iterator, ArrayableInterface { diff --git a/app/Parvula/Services/AuthenticationService.php b/core/Services/AuthenticationService.php similarity index 92% rename from app/Parvula/Services/AuthenticationService.php rename to core/Services/AuthenticationService.php index d3527c6..18cd6b6 100644 --- a/app/Parvula/Services/AuthenticationService.php +++ b/core/Services/AuthenticationService.php @@ -1,11 +1,11 @@