BlueGit

timfa 66wiki

Files

66wiki / web / index.php

index.php

Initial commit
timfa Tim · pushed by timfa · 11 months ago
dd360904 History
index.php 1.0 KiB Download Raw
1<?php
2require_once("folderNode.php");
3require_once __DIR__ . '/templateRenderer.php';
4require_once __DIR__ . '/templateCssLinker.php';
5
6$renderer = new TemplateRenderer(__DIR__ . DIRECTORY_SEPARATOR . '/templates');
7
8if (isset($_GET['path'])) {
9 $html = $renderer->renderFromJsonFile($_GET['path']);
10} else {
11 $data = loadFolderTree(__DIR__ . DIRECTORY_SEPARATOR . 'data');
12
13 if ($data) {
14 // Non-recursive (only proficiencies/*.json):
15 $onlyHere = $data->jsonNonRecursive();
16
17 // Recursive (proficiencies/**/*.json):
18 $allUnder = $data->jsonRecursive();
19 }
20
21 try {
22 $html = $renderer->renderAll($allUnder);
23 } catch (Throwable $e) {
24 $html = '<pre class="error">' . htmlspecialchars($e->getMessage()) . '</pre>';
25 }
26}
27?>
28<!DOCTYPE html>
29<html lang="en">
30
31<head>
32 <meta charset="UTF-8">
33 <title>66 Wiki</title>
34 <link rel="stylesheet" href="main.css">
35 <?php echoTemplateCssLinks(__DIR__ . DIRECTORY_SEPARATOR . 'templates', 'templates'); ?>
36</head>
37
38<body>
39
40 <?= $html ?>
41
42</body>
43
44</html>