/
index.php
60 lines (46 loc) · 2.45 KB
/
index.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
<?php
chdir('..');
include('vendor/autoload.php');
use Psr\Http\Message\ResponseInterface;
use Psr\Http\Message\ServerRequestInterface;
$container = new League\Container\Container;
$container->share('response', Zend\Diactoros\Response::class);
$container->share('request', function () {
return Zend\Diactoros\ServerRequestFactory::fromGlobals(
$_SERVER, $_GET, $_POST, $_COOKIE, $_FILES
);
});
$container->share('emitter', Zend\Diactoros\Response\SapiEmitter::class);
$route = new League\Route\RouteCollection($container);
$route->map('GET', '/', 'App\\Controller::index');
$route->map('GET', '/debug', 'App\\Controller::debug');
$route->map('GET', '/login', 'App\\LoginController::login');
$route->map('POST', '/login', 'App\\LoginController::login_start');
$route->map('GET', '/login/callback', 'App\\LoginController::login_callback');
$route->map('GET', '/logout', 'App\\LoginController::logout');
$route->map('GET', '/channel/{uid}', 'App\\Controller::timeline');
$route->map('GET', '/channel/{uid}/{source}', 'App\\Controller::timeline');
$route->map('POST', '/channels/reload', 'App\\Controller::reload_channels');
$route->map('POST', '/microsub/mark_read', 'App\\Controller::mark_as_read');
$route->map('POST', '/microsub/mark_all_as_read', 'App\\Controller::mark_all_as_read');
$route->map('POST', '/microsub/mark_unread', 'App\\Controller::mark_as_unread');
$route->map('POST', '/microsub/remove', 'App\\Controller::remove_entry');
$route->map('POST', '/micropub', 'App\\Controller::micropub');
$route->map('POST', '/micropub/refresh', 'App\\Controller::micropub_refresh');
$route->map('GET', '/preview', 'App\\PreviewController::get');
$route->map('POST', '/preview', 'App\\PreviewController::post');
$route->map('GET', '/widget/{uid}', 'App\\Controller::widget');
$route->map('GET', '/{path}', 'App\\Controller::path');
$templates = new League\Plates\Engine(dirname(__FILE__).'/../views');
try {
$response = $route->dispatch($container->get('request'), $container->get('response'));
$container->get('emitter')->emit($response);
} catch(League\Route\Http\Exception\NotFoundException $e) {
$response = $container->get('response');
$response->getBody()->write("Not Found\n");
$container->get('emitter')->emit($response->withStatus(404));
} catch(League\Route\Http\Exception\MethodNotAllowedException $e) {
$response = $container->get('response');
$response->getBody()->write("Method not allowed\n");
$container->get('emitter')->emit($response->withStatus(405));
}