Skip to content

Commit

Permalink
Move Parvula core to core/
Browse files Browse the repository at this point in the history
  • Loading branch information
BafS committed Apr 12, 2019
1 parent 5ca6ad0 commit 0a85058
Show file tree
Hide file tree
Showing 71 changed files with 61 additions and 77 deletions.
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
<?php

namespace Parvula\Repositories\Flatfiles;
namespace App\Repositories\Flatfiles;

use Parvula\Repositories\BaseRepository;

abstract class BaseRepositoryFlatfiles extends BaseRepository {

abstract class BaseRepositoryFlatfiles extends BaseRepository
{
/**
* Collection
* @var Parvula\Collections\Collection Collection of model
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
<?php

namespace Parvula\Repositories\Flatfiles;
namespace App\Repositories\Flatfiles;

use Parvula\ArrayTrait;
use Parvula\FileParser;
use Parvula\FilesSystem as Files;
use Parvula\Models\Config;
use Parvula\Collections\Collection;

class ConfigRepositoryFlatfiles extends BaseRepositoryFlatfiles
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

namespace Parvula\Repositories\Flatfiles;
namespace App\Repositories\Flatfiles;

use SplFileInfo;
use Parvula\Models\Page;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
<?php

namespace Parvula\Repositories\Flatfiles;
namespace App\Repositories\Flatfiles;

use Parvula\ArrayTrait;
use Parvula\FileParser;
use Parvula\Models\User;
use Parvula\Collections\Collection;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
<?php
namespace Parvula\Repositories\Mongo;

namespace App\Repositories\Mongo;

use Exception;
use Parvula\Collections\MongoCollection;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
<?php

namespace Parvula\Repositories\Mongo;
namespace App\Repositories\Mongo;

use Exception;
use Parvula\ArrayTrait;
use Parvula\FileParser;
use Parvula\FilesSystem as Files;
use Parvula\Models\Config;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
<?php

namespace Parvula\Repositories\Mongo;
namespace App\Repositories\Mongo;

use MongoDB\Collection as MongoCollectionBase;
use Parvula\BaseRepository;
use Parvula\Models\Page;
use Parvula\Exceptions\IOException;
use Parvula\Exceptions\PageException;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
<?php

namespace Parvula\Repositories\Mongo;
namespace App\Repositories\Mongo;

use Parvula\ArrayTrait;
use Parvula\FileParser;
use Parvula\Models\User;
use MongoDB\Collection as MongoCollectionBase;

Expand Down
6 changes: 2 additions & 4 deletions app/bootstrap.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<?php

namespace Parvula;
use Parvula\Parvula;
use function Parvula\classAliases;

require 'constants.php';

Expand All @@ -22,9 +23,6 @@
// Register services and helpers
require _APP_ . 'services.php';

// Load helpers
require _APP_ . 'helpers.php';

$config = $app['config'];
$config->set('__time__', $time);

Expand Down
7 changes: 1 addition & 6 deletions app/routes/api/auth.php
Original file line number Diff line number Diff line change
@@ -1,11 +1,6 @@
<?php

namespace Parvula;

use DateTime;
use Exception;
use Firebase\JWT\JWT;
use Parvula\Exceptions\IOException;

/**
* @api {get} /auth Login
Expand Down Expand Up @@ -72,7 +67,7 @@
'exp' => $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?');
Expand Down
3 changes: 1 addition & 2 deletions app/routes/api/config.php
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
<?php

namespace Parvula;

use Rs\Json\Patch;
use Rs\Json\Patch\InvalidPatchDocumentJsonException;
use Rs\Json\Patch\InvalidTargetDocumentJsonException;
use Rs\Json\Patch\InvalidOperationException;
use function Parvula\app;

// @ALPHA

Expand Down
6 changes: 1 addition & 5 deletions app/routes/api/files.php
Original file line number Diff line number Diff line change
@@ -1,12 +1,8 @@
<?php

namespace Parvula;

use Exception;
use SplFileInfo;
use RuntimeException;
use Parvula\FilesSystem;
use Parvula\Exceptions\IOException;
use function Parvula\url;

// @ALPHA.2

Expand Down
4 changes: 1 addition & 3 deletions app/routes/api/index.php
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
<?php

namespace Parvula;

use Exception;
use function Parvula\app;

function checkTokenScope(array $scope, $token) {
$scopeToken = isset($token->scope) ? $token->scope : [];
Expand Down
7 changes: 1 addition & 6 deletions app/routes/api/pages.php
Original file line number Diff line number Diff line change
@@ -1,15 +1,10 @@
<?php

namespace Parvula;

use Exception;
use Parvula\Models\Page;
use Parvula\Models\PagesFlatFiles;
use Parvula\Exceptions\IOException;
use Rs\Json\Patch;
use Rs\Json\Patch\InvalidOperationException;
use Rs\Json\Patch\InvalidPatchDocumentJsonException;
use Rs\Json\Patch\InvalidTargetDocumentJsonException;
use function Parvula\app;

/**
* @api {post} /pages Create a new page
Expand Down
8 changes: 4 additions & 4 deletions app/routes/api/pages.public.php
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<?php

namespace Parvula;

use Parvula\Models\Page;
use Parvula\Transformers\PageHeadTransformer;
use function Parvula\app;

/**
* @api {get} /pages Get all pages
Expand Down Expand Up @@ -80,14 +80,14 @@
], 404);
}

return $this->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
]
],
];
}

Expand Down
5 changes: 1 addition & 4 deletions app/routes/api/themes.php
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
<?php

namespace Parvula;

use Exception;
use Parvula\Exceptions\IOException;
use function Parvula\app;

/**
* @api {get} /themes List of themes
Expand Down
5 changes: 1 addition & 4 deletions app/routes/api/users.php
Original file line number Diff line number Diff line change
@@ -1,10 +1,7 @@
<?php

namespace Parvula;

use Exception;
use Parvula\Exceptions\IOException;
use Parvula\Models\User;
use function Parvula\app;

/**
* @api {get} /users List of users usernames
Expand Down
5 changes: 3 additions & 2 deletions app/routes/web.php
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
<?php

namespace Parvula;

// Pages handler (slug must be `a-z0-9-_+/` (will be rewritten to lowercase if needed))
use function Parvula\app;
use function Parvula\url;

$router->map(['GET', 'POST'], '/{slug:[a-zA-Z0-9\-_\+\/]*}', function ($req, $res, $args) use ($app) {
$view = $app['view'];
$pages = $app['pages'];
Expand Down
21 changes: 16 additions & 5 deletions app/services.php
Original file line number Diff line number Diff line change
Expand Up @@ -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.';
Expand Down Expand Up @@ -89,7 +100,7 @@
'routerCacheFile' => $cacheFile,
'displayErrorDetails' => $c['config']->get('debug', false)
],
'api' => new Http\APIResponse(),
'api' => new APIResponse(),
'logger' => $c['loggerHandler']
];

Expand Down Expand Up @@ -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));
};

Expand Down Expand Up @@ -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'));
});

Expand Down
8 changes: 6 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
namespace Parvula\ContentParser;

use ParsedownExtra;
use function Parvula\url;

/**
* Extends ParsedownExtra to add link functionalities.
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

namespace Parvula\Repositories;

abstract class BaseRepository {

abstract class BaseRepository
{
/**
* The repository current's class name model
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
<?php

namespace Parvula\Service;
namespace Parvula\Services;

use Parvula\Models\User;

class AuthenticationService {
use Parvula\Session;

class AuthenticationService
{
/**
* @var mixed Token
*/
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion app/helpers.php → core/helpers.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

use Parvula\Parvula;
namespace Parvula;

/**
* Create multiple class aliases.
Expand Down
6 changes: 3 additions & 3 deletions public/plugins/Admin/main.php
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<?php

use Parvula\Parvula;
use Parvula\Parvula\Core\Config;
use Parvula\Parvula\Core\Models\Pages;
use function Parvula\app;
use function Parvula\url;
use function Parvula\themesPath;

$templates = new League\Plates\Engine(__DIR__ . '/view', 'html');

Expand Down
1 change: 1 addition & 0 deletions public/plugins/ComponentsLoader/ComponentsLoader.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
use Exception;
use Parvula\Plugin;
use Parvula\Models\Page;
use function Parvula\pluginsPath;

if (!defined('_APP_')) exit;

Expand Down

0 comments on commit 0a85058

Please sign in to comment.