blob: 1f99be96de5026c1b71b088090ad7005486b7281 (
plain)
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
|
<?php
include_once $_SERVER['DOCUMENT_ROOT'] . '/../lib/partials.php';
include_once $_SERVER['DOCUMENT_ROOT'] . '/../vendor/autoload.php';
include_once $_SERVER['DOCUMENT_ROOT'] . '/../config.php';
if (str_starts_with(WIKI_PAGE_DIRECTORY, "http")) {
header("Location: " . WIKI_PAGE_DIRECTORY);
exit;
}
$page_id = $_GET['p'] ?? 'README';
$page_name = "$page_id.md";
$iter = new RecursiveDirectoryIterator(WIKI_PAGE_DIRECTORY);
$page_path = null;
foreach (new RecursiveIteratorIterator($iter) as $filename => $cur) {
if (basename($filename) == $page_name) {
$page_path = $filename;
break;
}
}
if (!isset($page_path) || !is_file($page_path)) {
http_response_code(404);
exit;
}
$parsedown = new Parsedown();
$contents = $parsedown->parse(file_get_contents($page_path));
if ($sidebar = file_get_contents(WIKI_PAGE_DIRECTORY . '/summary.md')) {
$sidebar = $parsedown->parse($sidebar);
}
?>
<html>
<head>
<title><?= isset($page_path) ? "Page $page_id - " : '' ?>Wiki - <?= BOT_USERNAME_FORMATTED ?></title>
<meta http-equiv="Content-Type" content="text/html;charset=UTF-8">
<link rel="stylesheet" href="/static/style.css">
<link rel="shortcut icon" href="/static/favicon.ico" type="image/x-icon">
</head>
<body>
<main>
<?php html_navigation_bar() ?>
<content>
<div class="row gap-8 background-colorful p-4" style="box-shadow: 0 2px 1px rgba(0, 0, 0, 0.25);z-index:1;">
<img src="/static/img/icons/book.png" alt="">
<h2>Wiki</h2>
</div>
<div class="row">
<?php if (isset($sidebar)): ?>
<!-- SIDE BAR -->
<div class="wiki-sidebar">
<?= $sidebar ?>
</div>
<?php endif; ?>
<!-- WIKI CONTENT -->
<div class="wiki-content">
<?= $contents ?>
</div>
</div>
</content>
</main>
<?php html_footer() ?>
</body>
</html>
|