diff options
| author | moderndevslulw <moderndevslulw@alright.party> | 2025-07-05 20:38:22 +0500 |
|---|---|---|
| committer | moderndevslulw <moderndevslulw@alright.party> | 2025-07-05 20:38:22 +0500 |
| commit | e24572790514bbe8b5e1e360cf136cf5388025b0 (patch) | |
| tree | 8cfc653f3213d5da6baccbd2b5244f6ee094e881 /public/wiki.php | |
| parent | c93f2cff12f47702266118617e8ee4369ff41173 (diff) | |
feat: wiki
Diffstat (limited to 'public/wiki.php')
| -rw-r--r-- | public/wiki.php | 66 |
1 files changed, 66 insertions, 0 deletions
diff --git a/public/wiki.php b/public/wiki.php new file mode 100644 index 0000000..4cb1189 --- /dev/null +++ b/public/wiki.php @@ -0,0 +1,66 @@ +<?php +include_once $_SERVER['DOCUMENT_ROOT'] . '/../lib/partials.php'; +include_once $_SERVER['DOCUMENT_ROOT'] . '/../vendor/autoload.php'; +include_once $_SERVER['DOCUMENT_ROOT'] . '/../config.php'; + +$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><?= $page_id ?> - Wiki - The Tinybot Project</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>
\ No newline at end of file |
