feat: add wiki

This commit is contained in:
iodomi
2026-06-22 16:02:50 +02:00
parent a9dd0ab799
commit fe38b3db2d
10 changed files with 601 additions and 44 deletions

42
wiki/page.php Normal file
View File

@@ -0,0 +1,42 @@
<?php
include '../header.php';
include '../parsedown/Parsedown.php';
include '../parsedown-extra/ParsedownExtra.php';
$Parsedown = new Parsedown();
$Parsedown->setMarkupEscaped(true);
$Extra = new ParsedownExtra();
$article = $_GET['article'] ?? '';
$article = basename($article);
$path = __DIR__ . "/source/{$article}.md";
if (!is_file($path)) {
http_response_code(404);
exit;
}
$raw = file_get_contents($path);
$title = preg_match("/^title:\s*(.*)$/mi", $raw, $m) ? trim($m[1]) : ucfirst($article);
$authors = preg_match("/^authors:\s*(.*)$/mi", $raw, $m) ? trim($m[1]) : ucfirst($article);
$body = preg_replace("/^(title|category|authors):[^\r\n]*\r?\n/m", "", $raw);
$html = $Extra->text($body);
?>
<div id="top-bar">
<h1>> <?php echo htmlspecialchars($title); ?></h1>
<p>osoby autorskie: <a href=/~<?php echo $authors ?>>~<?php echo $authors ?></a></p>
</div>
<article id="content">
<?php echo $html; ?>
</article>
<?php
include '../footer.php'
?>