forked from tylda-public/main
43 lines
977 B
PHP
43 lines
977 B
PHP
<?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'
|
|
|
|
?>
|