rfcs/draft.php

33 lines
1.3 KiB
PHP

<?php
include 'vendor/autoload.php';
class MDParse implements Mni\FrontYAML\Markdown\MarkdownParser {
public function parse($markdown) {
return Michelf\MarkdownExtra::defaultTransform($markdown);
}
}
$parser = new Mni\FrontYAML\Parser(null, new MDParse());
$filename = 'draft-'.$_GET["name"].'.md';
if (!file_exists($filename)) {
header("Location: https://rfc.tildeverse.org/");
die();
}
$document = $parser->parse(file_get_contents($filename));
$yml = $document->getYAML();
$content = $document->getContent();
$title = ($yml['title'] ?? 'invalid');
$author_san = htmlspecialchars($yml['author']);
$description = "Draft {$_GET['name']}: {$yml['title']} by {$author_san}";
include 'header.php';
?>
<h1>Draft <?=$_GET['name']?>: <?=$yml['title']?></h1>
<p>Author: <?=htmlspecialchars($yml['author'])?><br />
<?php if(isset($yml['updates'])){?>
Updates: <?php $arr=explode(", ",$yml['updates']); foreach($arr as $num) { echo "<a href='./rfc.php?number={$num}'>{$num}</a>"; if(next($arr)) { echo ", "; }}?><br />
<?php };?>
<?php if(isset($yml['updated-by'])){?>
Updated by: <?php $arr=explode(", ",$yml['updated-by']); foreach($arr as $num) { echo "<a href='./rfc.php?number={$num}'>{$num}</a>"; if(next($arr)) { echo ", "; }}?><br />
<?php };?>
<?=$content?>
<?php include 'footer.php'; ?>