This repository has been archived by the owner on Oct 31, 2018. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.php
77 lines (53 loc) · 1.9 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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
<?php
ini_set("session.auto_start", "1") ? 0 : session_start();
require __DIR__ . '/vendor/autoload.php';
use \CareyLi\s2h;
use \utilphp\util;
$whoops = new \Whoops\Run;
$whoops->pushHandler(new \Whoops\Handler\PrettyPageHandler);
$whoops->register();
$model = new s2h\Model();
$view = new \League\Plates\Engine("./src/templates");
$controller = new s2h\Controller($model, $view);
$ajax = new s2h\AjaxController($model);
$router = new \Klein\Klein();
/*
* Check for first run, redirect if so.
*/
if ($model->isFirstRun() && strpos(util::get_current_url(), 'first-run') === FALSE) {
header("Location: ./first-run");
exit;
}
$router->respond('GET', '/', function($request) use ($controller) {
$controller->index();
});
$router->respond('GET', '/spotify_callback/?', function($request) use ($controller) {
$controller->spotify_oauth();
});
$router->with('/first-run', function() use ($router, $controller, $model) {
$router->respond('GET', '/?', function($request) use ($controller) {
$controller->firstRun();
});
$router->respond('POST', '/?', function($request) use ($controller) {
$controller->firstRunSave();
});
});
$router->with('/ajax', function() use ($router, $ajax, $model) {
$router->respond('GET', '/playlist_songs/[:user]/[:playlist]/[:html]?', function($request) use ($ajax) {
if ($request->html === "html") {
$ajax->html_playlist_songs($request->user, $request->playlist);
} else {
$ajax->playlist_songs($request->user, $request->playlist);
}
});
$router->respond('GET', '/queue_album/[:artist]/[:album]', function($request) use ($ajax) {
$ajax->queue_album(base64_decode($request->artist), base64_decode($request->album));
});
});
$router->with('/settings', function() use ($router, $controller) {
$router->respond('GET', '/', function($request) use ($controller) {
$controller->settings();
});
});
$router->dispatch();
?>