Skip to content

Commit 301fa5c

Browse files
committed
Initial commit
Signed-off-by: Pieter Hordijk <[email protected]>
1 parent f0378c6 commit 301fa5c

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

78 files changed

+15375
-0
lines changed

.gitignore

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
.idea
2+
vendor
3+
phpunit.xml
4+
encryption.key

bootstrap.php

+173
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,173 @@
1+
<?php declare(strict_types=1);
2+
3+
namespace Gitilicious;
4+
5+
use CodeCollab\Http\Request\Request;
6+
use CodeCollab\Http\Cookie\Factory as CookieFactory;
7+
use CodeCollab\Http\Session\Session;
8+
use CodeCollab\Http\Session\Native as NativeSession;
9+
use CodeCollab\Authentication\Authentication;
10+
use CodeCollab\Authentication\User;
11+
use CodeCollab\Encryption\Encryptor;
12+
use CodeCollab\Encryption\Defuse\Encryptor as EncryptorImpl;
13+
use CodeCollab\Encryption\Decryptor;
14+
use CodeCollab\Encryption\Defuse\Decryptor as DecryptorImpl;
15+
use CodeCollab\Router\Router;
16+
use FastRoute\RouteParser;
17+
use FastRoute\RouteParser\Std as StdRouteParser;
18+
use FastRoute\DataGenerator;
19+
use FastRoute\DataGenerator\GroupCountBased as GroupCountBasedDataGenerator;
20+
use FastRoute\Dispatcher\GroupCountBased as RouteDispatcher;
21+
use CodeCollab\Router\Injector;
22+
use CodeCollab\Router\FrontController;
23+
use Gitilicious\Presentation\Template\Html;
24+
use CodeCollab\Theme\Loader as ThemeLoader;
25+
use CodeCollab\Theme\Theme;
26+
use CodeCollab\I18n\Translator;
27+
use CodeCollab\I18n\FileTranslator;
28+
use CodeCollab\CsrfToken\Generator\Generator as TokenGenerator;
29+
use CodeCollab\CsrfToken\Generator\RandomBytes32;
30+
use CodeCollab\CsrfToken\Storage\Storage as TokenStorage;
31+
use Gitilicious\Storage\TokenSession;
32+
use CodeCollab\CsrfToken\Token;
33+
use CodeCollab\CsrfToken\Handler as CsrfToken;
34+
use Gitilicious\Form\Install as InstallForm;
35+
use Auryn\Injector as Auryn;
36+
37+
/**
38+
* Setup the project autoloader
39+
*/
40+
require_once __DIR__ . '/vendor/autoload.php';
41+
42+
/**
43+
* Setup the environment
44+
*/
45+
require_once __DIR__ . '/init.deployment.php';
46+
47+
/**
48+
* Load the configuration
49+
*/
50+
require_once __DIR__ . '/config/config.php';
51+
52+
/**
53+
* Prevent further execution when on CLI
54+
*/
55+
if (php_sapi_name() === 'cli') {
56+
return;
57+
}
58+
59+
/**
60+
* Setup DI
61+
*/
62+
$auryn = new Auryn();
63+
$injector = new Injector($auryn);
64+
$auryn->share($auryn); // yolo
65+
66+
/**
67+
* Setup encryption
68+
*/
69+
$auryn->share(Decryptor::class);
70+
$auryn->alias(Decryptor::class, DecryptorImpl::class);
71+
$auryn->alias(Encryptor::class, EncryptorImpl::class);
72+
$auryn->define(DecryptorImpl::class, [':key' => file_get_contents(__DIR__ . '/encryption.key')]);
73+
$auryn->define(EncryptorImpl::class, [':key' => file_get_contents(__DIR__ . '/encryption.key')]);
74+
75+
/**
76+
* Setup the request object
77+
*/
78+
$auryn->share(Request::class);
79+
$request = $auryn->make(Request::class, [
80+
':server' => $_SERVER,
81+
':get' => $_GET,
82+
':post' => $_POST,
83+
':files' => $_FILES,
84+
':cookies' => $_COOKIE,
85+
':input' => file_get_contents('php://input'),
86+
]);
87+
88+
/**
89+
* Setup cookies
90+
*/
91+
$auryn->define(CookieFactory::class, [
92+
':domain' => $request->server('SERVER_NAME'),
93+
':secure' => $request->isEncrypted(),
94+
]);
95+
96+
/**
97+
* Setup the session
98+
*/
99+
$auryn->share(Session::class);
100+
$auryn->alias(Session::class, NativeSession::class);
101+
$auryn->define(NativeSession::class, [
102+
':path' => '/',
103+
':domain' => $request->server('SERVER_NAME'),
104+
':secure' => $request->isEncrypted()
105+
]);
106+
107+
/**
108+
* Setup the user authentication
109+
*/
110+
$auryn->share(User::class);
111+
$auryn->alias(Authentication::class, User::class);
112+
$user = $auryn->make(User::class);
113+
114+
/**
115+
* Setup the router
116+
*/
117+
$cacheFile = $user->isLoggedIn() ? __DIR__ . '/cache/routes-authenticated.php' : __DIR__ . '/cache/routes.php';
118+
/** @var array $config */
119+
$cacheFile = $config['initialized'] ? $cacheFile : __DIR__ . '/cache/routes-installation.php';
120+
$auryn->share(Router::class);
121+
$auryn->alias(RouteParser::class, StdRouteParser::class);
122+
$auryn->alias(DataGenerator::class, GroupCountBasedDataGenerator::class);
123+
/** @var bool $production */
124+
$auryn->define(Router::class, [
125+
':dispatcherFactory' => function($dispatchData) {
126+
return new RouteDispatcher($dispatchData);
127+
},
128+
':cacheFile' => $cacheFile,
129+
':forceReload' => !$production,
130+
]);
131+
$router = $auryn->make(Router::class);
132+
133+
/**
134+
* Setup the templating
135+
*/
136+
$auryn->define(Html::class, [':basePage' => '/page.phtml']);
137+
$auryn->alias(ThemeLoader::class, Theme::class);
138+
/** @var array $config */
139+
$auryn->define(Theme::class, [':themePath' => __DIR__ . '/themes', ':theme' => $config['theme']]);
140+
141+
/**
142+
* Setup translator
143+
*/
144+
$auryn->share(Translator::class);
145+
$auryn->alias(Translator::class, FileTranslator::class);
146+
$auryn->define(FileTranslator::class, [':translationDirectory' => __DIR__ . '/texts', ':languageCode' => 'en_US']);
147+
148+
/**
149+
* Setup the CSRF token
150+
*/
151+
$auryn->alias(Token::class, CsrfToken::class);
152+
$auryn->alias(TokenStorage::class, TokenSession::class);
153+
$auryn->alias(TokenGenerator::class, RandomBytes32::class);
154+
155+
/**
156+
* Setup custom form data
157+
*/
158+
$auryn->define(InstallForm::class, [':baseDirectory' => __DIR__]);
159+
160+
/**
161+
* Load the routes
162+
*/
163+
require_once __DIR__ . '/routes.php';
164+
165+
/**
166+
* Setup the front controller
167+
*/
168+
$frontController = $auryn->make(FrontController::class);
169+
170+
/**
171+
* Run the application
172+
*/
173+
$frontController->run($request);

cache/routes-installation.php

+145
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,145 @@
1+
<?php return array (
2+
0 =>
3+
array (
4+
'GET' =>
5+
array (
6+
'/not-found' =>
7+
array (
8+
0 => 'Gitilicious\\Presentation\\Controller\\Error',
9+
1 => 'notFound',
10+
),
11+
'/method-not-allowed' =>
12+
array (
13+
0 => 'Gitilicious\\Presentation\\Controller\\Error',
14+
1 => 'methodNotAllowed',
15+
),
16+
'/' =>
17+
array (
18+
0 => 'Gitilicious\\Presentation\\Controller\\Installation',
19+
1 => 'render',
20+
),
21+
'/preflight' =>
22+
array (
23+
0 => 'Gitilicious\\Presentation\\Controller\\Preflight',
24+
1 => 'preflight',
25+
),
26+
'/preflight/database-connection' =>
27+
array (
28+
0 => 'Gitilicious\\Presentation\\Controller\\Preflight',
29+
1 => 'databaseConnection',
30+
),
31+
'/preflight/empty-database' =>
32+
array (
33+
0 => 'Gitilicious\\Presentation\\Controller\\Preflight',
34+
1 => 'emptyDatabase',
35+
),
36+
'/preflight/create-table' =>
37+
array (
38+
0 => 'Gitilicious\\Presentation\\Controller\\Preflight',
39+
1 => 'createTable',
40+
),
41+
'/preflight/drop-table' =>
42+
array (
43+
0 => 'Gitilicious\\Presentation\\Controller\\Preflight',
44+
1 => 'dropTable',
45+
),
46+
'/preflight/repo-directory' =>
47+
array (
48+
0 => 'Gitilicious\\Presentation\\Controller\\Preflight',
49+
1 => 'repoDirectory',
50+
),
51+
'/preflight/sendmail' =>
52+
array (
53+
0 => 'Gitilicious\\Presentation\\Controller\\Preflight',
54+
1 => 'sendmail',
55+
),
56+
),
57+
'POST' =>
58+
array (
59+
'/' =>
60+
array (
61+
0 => 'Gitilicious\\Presentation\\Controller\\Installation',
62+
1 => 'handle',
63+
),
64+
'/preflight/database-connection/test' =>
65+
array (
66+
0 => 'Gitilicious\\Presentation\\Controller\\Preflight',
67+
1 => 'testDatabaseConnection',
68+
),
69+
'/preflight/empty-database/test' =>
70+
array (
71+
0 => 'Gitilicious\\Presentation\\Controller\\Preflight',
72+
1 => 'testEmptyDatabase',
73+
),
74+
'/preflight/create-table/test' =>
75+
array (
76+
0 => 'Gitilicious\\Presentation\\Controller\\Preflight',
77+
1 => 'testCreateTable',
78+
),
79+
'/preflight/drop-table/test' =>
80+
array (
81+
0 => 'Gitilicious\\Presentation\\Controller\\Preflight',
82+
1 => 'testDropTable',
83+
),
84+
'/preflight/repo-directory/test' =>
85+
array (
86+
0 => 'Gitilicious\\Presentation\\Controller\\Preflight',
87+
1 => 'testRepoDirectory',
88+
),
89+
'/preflight/sendmail/test' =>
90+
array (
91+
0 => 'Gitilicious\\Presentation\\Controller\\Preflight',
92+
1 => 'testSendmail',
93+
),
94+
),
95+
),
96+
1 =>
97+
array (
98+
'GET' =>
99+
array (
100+
0 =>
101+
array (
102+
'regex' => '~^(?|/js/(.+)|/css/(.+)()|/fonts/(.+)()())$~',
103+
'routeMap' =>
104+
array (
105+
2 =>
106+
array (
107+
0 =>
108+
array (
109+
0 => 'Gitilicious\\Presentation\\Controller\\Resource',
110+
1 => 'renderJavascript',
111+
),
112+
1 =>
113+
array (
114+
'filename' => 'filename',
115+
),
116+
),
117+
3 =>
118+
array (
119+
0 =>
120+
array (
121+
0 => 'Gitilicious\\Presentation\\Controller\\Resource',
122+
1 => 'renderStylesheet',
123+
),
124+
1 =>
125+
array (
126+
'filename' => 'filename',
127+
),
128+
),
129+
4 =>
130+
array (
131+
0 =>
132+
array (
133+
0 => 'Gitilicious\\Presentation\\Controller\\Resource',
134+
1 => 'renderFont',
135+
),
136+
1 =>
137+
array (
138+
'filename' => 'filename',
139+
),
140+
),
141+
),
142+
),
143+
),
144+
),
145+
);

cache/routes.php

+72
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
<?php return array (
2+
0 =>
3+
array (
4+
'GET' =>
5+
array (
6+
'/not-found' =>
7+
array (
8+
0 => 'Gitilicious\\Presentation\\Controller\\Error',
9+
1 => 'notFound',
10+
),
11+
'/method-not-allowed' =>
12+
array (
13+
0 => 'Gitilicious\\Presentation\\Controller\\Error',
14+
1 => 'methodNotAllowed',
15+
),
16+
'/' =>
17+
array (
18+
0 => 'Gitilicious\\Presentation\\Controller\\Index',
19+
1 => 'index',
20+
),
21+
),
22+
),
23+
1 =>
24+
array (
25+
'GET' =>
26+
array (
27+
0 =>
28+
array (
29+
'regex' => '~^(?|/js/(.+)|/css/(.+)()|/fonts/(.+)()())$~',
30+
'routeMap' =>
31+
array (
32+
2 =>
33+
array (
34+
0 =>
35+
array (
36+
0 => 'Gitilicious\\Presentation\\Controller\\Resource',
37+
1 => 'renderJavascript',
38+
),
39+
1 =>
40+
array (
41+
'filename' => 'filename',
42+
),
43+
),
44+
3 =>
45+
array (
46+
0 =>
47+
array (
48+
0 => 'Gitilicious\\Presentation\\Controller\\Resource',
49+
1 => 'renderStylesheet',
50+
),
51+
1 =>
52+
array (
53+
'filename' => 'filename',
54+
),
55+
),
56+
4 =>
57+
array (
58+
0 =>
59+
array (
60+
0 => 'Gitilicious\\Presentation\\Controller\\Resource',
61+
1 => 'renderFont',
62+
),
63+
1 =>
64+
array (
65+
'filename' => 'filename',
66+
),
67+
),
68+
),
69+
),
70+
),
71+
),
72+
);

0 commit comments

Comments
 (0)