forked from aubymori/hitchhiker
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.php
68 lines (55 loc) · 1.34 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
<?php
ob_start();
require "base/path.php"; // Prereq path parser
(
function /* preinit */ ()
{
$path = getPath();
// YTS folder stores resources
if ("yts" == $path["path"][0])
{
staticInit($path); // Avoid unnecessary processing
}
else
{
mainInit($path);
}
}
)();
function mainInit($path)
{
require "vendor/autoload.php"; // Install composer packages
require "base/auth.php";
require "base/request.php";
require "base/utils.php";
require "base/signin.php";
require "base/GlobalStore.php";
require "youtubei/Youtubei.php";
require "pages.php";
GlobalStore::import("json", "config", "config.json");
$twigVars = [];
$twigTemplate = "";
$twigGlobal = [];
// Page Controller callback mechanism
getPage($path)($twigTemplate, $twigVars, $twigGlobal);
// Init twig and render new data
$twig = initTwig();
$twig->addGlobal("global", $twigGlobal);
$output = renderTwig($twig, $twigTemplate, $twigVars);
echo $output;
ob_end_flush();
}
function staticInit($path)
{
(require "base/staticld.php")($path);
}
function initTwig()
{
$fsLoader = new \Twig\Loader\FilesystemLoader("hitchhiker");
$twig = new \Twig\Environment($fsLoader);
return $twig;
}
function renderTwig($handle, $template, $vars)
{
return $handle->render($template, $vars);
}