1038b3c577
- Added Markdown support to guestbook and blog comments - Moved comment rendering code to post rendering script - Markdownized final remaining blog post - Fixed one page that was still designed for the old code block css
99 lines
3.6 KiB
PHP
99 lines
3.6 KiB
PHP
<?php
|
|
$cwd = preg_replace('/^.*\//', '', getcwd());
|
|
$feed = simplexml_load_file($_SERVER['DOCUMENT_ROOT']."/blog/blog.atom");
|
|
$pdate = "";
|
|
$udate = "";
|
|
$title = "";
|
|
$descr = "";
|
|
foreach($feed->entry as $entry) {
|
|
if($entry->id == $cwd) {
|
|
$pdate = preg_replace('/T.*$/', ' ', $entry->published);
|
|
$udate = preg_replace('/T.*$/', ' ', $entry->updated);
|
|
$title = $entry->title;
|
|
$descr = $entry->summary;
|
|
break;
|
|
}
|
|
}
|
|
?>
|
|
<!DOCTYPE html>
|
|
<html lang="en">
|
|
<head>
|
|
<meta charset="utf-8">
|
|
<meta name="viewport" content="width=device-width, initial-scale=1">
|
|
<title><?php echo($title); ?></title>
|
|
<?php echo("<meta name='description' content='$descr'>"); ?>
|
|
<link href="/style.css" rel="stylesheet" type="text/css" media="all">
|
|
<link href="/blog/comment/comments.css" rel="stylesheet" type="text/css" media="all">
|
|
<style>
|
|
h1 {
|
|
background-image: url('bg.svg'), url('bg.png'), url('bg.jpg'), url('bg.webp');
|
|
}
|
|
</style>
|
|
</head>
|
|
<body>
|
|
<?php
|
|
include($_SERVER['DOCUMENT_ROOT'] . '/nav.php');
|
|
$udates = "";
|
|
if($pdate != $udate) { $udates = " | Updated on $udate"; }
|
|
echo("<h1>isoblog</h1><h2 id='caption'>$title</h2><p style='text-align: center;'><em>Posted on $pdate$udates</em></p>");
|
|
include("../../../Parsedown.php");
|
|
$Parsedown = new Parsedown();
|
|
echo $Parsedown->text(file_get_contents("index.md"));
|
|
$Parsedown->setSafeMode(true);
|
|
$return = $_GET["return"];
|
|
?>
|
|
<hr>
|
|
<h2>Comments</h2>
|
|
<form action="/blog/comment/submit.php" method="post" autocomplete="off">
|
|
<?php echo "<input type='text' name='entry' value='".preg_replace("/^.*\//","",getcwd())."' style='display: none;' readonly>"; ?>
|
|
<table>
|
|
<tr>
|
|
<td><input type="text" name="name" placeholder="Name"></td>
|
|
<td><input type="text" name="botcheck" placeholder="Bot test (type "isopod")"></td>
|
|
</tr>
|
|
<tr>
|
|
<td colspan="2"><textarea name="message" placeholder="Comment (Now supports Markdown!)"></textarea></td>
|
|
</tr>
|
|
|
|
<tr>
|
|
<?php
|
|
switch ($return) {
|
|
case 'noname':
|
|
echo "<td><span class='error'>Name required!</span></td>";
|
|
break;
|
|
case 'nomessage':
|
|
echo "<td><span class='error'>Message required!</span></td>";
|
|
break;
|
|
case 'botcheckfailed':
|
|
echo "<td><span class='error'>You failed the bot check!</span></td>";
|
|
break;
|
|
case 'success':
|
|
echo "<td><span class='success'>Successfully posted!</span></td>";
|
|
break;
|
|
default:
|
|
echo "<td></td>";
|
|
break;
|
|
}
|
|
?>
|
|
<td style="text-align: right;"><input type="submit" value="Post"></td>
|
|
</tr>
|
|
</table>
|
|
</form>
|
|
<?php
|
|
|
|
$totaloutput = "";
|
|
$postlist = json_decode(file_get_contents("../../comment/posts.json"));
|
|
foreach($postlist as $post) {
|
|
if ($post->entry == preg_replace("/^.*\//","",getcwd())) {
|
|
$output = "";
|
|
$date = date("Y-m-d h:iA", $post->date);
|
|
$name = $post->name;
|
|
$message = $Parsedown->text(html_entity_decode($post->message));
|
|
|
|
$output = $output."<hr><article><table><tr><td style='text-align: left;'>".$name."</td><td style='text-align: right;'>".$date."</td></tr><tr><td colspan='2'>".$message."</td></tr></table></article>";
|
|
$totaloutput = $output.$totaloutput;
|
|
}
|
|
}
|
|
echo $totaloutput; ?>
|
|
</body>
|
|
</html>
|