diff options
Diffstat (limited to 'blog/posts/post.php')
| -rw-r--r-- | blog/posts/post.php | 129 |
1 files changed, 75 insertions, 54 deletions
diff --git a/blog/posts/post.php b/blog/posts/post.php index e6b13b6..65d2661 100644 --- a/blog/posts/post.php +++ b/blog/posts/post.php @@ -1,17 +1,36 @@ <?php +/*ini_set('display_errors', 1); +ini_set('display_startup_errors', 1); +error_reporting(E_ALL);*/ + +if($_SERVER['REQUEST_URI'] === "/blog/posts/post.php") { + header("Location: /blog/"); + die(); +} + $cwd = preg_replace('/^.*\//', '', getcwd()); $feed = simplexml_load_file($_SERVER['DOCUMENT_ROOT']."/blog/blog.atom"); $pdate = ""; $udate = ""; $title = ""; $descr = ""; +$prevtitle = ""; +$prevlink = ""; +$nexttitle = ""; +$nextlink = ""; 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; + } else if($title) { + $nextlink = $entry->link["href"]; + $nexttitle = $entry->title; break; + } else { + $prevlink = $entry->link["href"]; + $prevtitle = $entry->title; } } ?> @@ -21,27 +40,50 @@ foreach($feed->entry as $entry) { <meta charset="utf-8"> <meta name="viewport" content="width=device-width, initial-scale=1"> <link href="/style.css" rel="stylesheet" type="text/css" media="all"> - <link href="/blog/comment/comments.css" rel="stylesheet" type="text/css" media="all"> + <link href="/guestbook/comments.css" rel="stylesheet" type="text/css" media="all"> <?php echo("<title>$title</title><meta name='description' content='$descr'>"); $bgfile = glob('bg.*')[0]; if(!is_null($bgfile)) { - echo("<style> h1 { background-image: url('$bgfile') } </style>"); + echo("<style> body > h1:first-of-type { background-image: url('$bgfile') } </style>"); } ?> <style> - td { - display: table-cell; + form { + display: flex; + flex-direction: column; + gap: calc(var(--stdpadding) / 2); + } + #commentform-top, #commentform-bottom { + display: flex; + gap: calc(var(--stdpadding) / 2); + align-items: center; + } + #commentform-bottom { + justify-content: right; + } + input[type="submit"] { + width: fit-content; + } + .error, .success { + flex-grow: 1; + } + @media only screen and (hover: none) { + #commentform-top { + flex-direction: column; + } } </style> <?php include($_SERVER['DOCUMENT_ROOT'] . '/seasonal.php'); ?> </head> <body> - <?php + <?php include($_SERVER['DOCUMENT_ROOT'] . '/nav.php'); + include($_SERVER['DOCUMENT_ROOT'] . '/common.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>"); + //echo("<p style='text-align: right;'>I'm testing in prod right now. don't worry about it"); include("../../../Parsedown.php"); $Parsedown = new Parsedown(); echo $Parsedown->text(file_get_contents("index.md")); @@ -49,57 +91,36 @@ foreach($feed->entry as $entry) { $return = $_GET["return"]; ?> <hr> + <nav style="flex-direction: column;"> + <?php + if($prevlink) { + echo("<a style='width: 100%; box-sizing: border-box;' href='$prevlink'><svg style='max-height: 1em;' xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 4 28 16' stroke-width='1.5' stroke='currentColor' class='size-6'><path stroke-linecap='round' stroke-linejoin='round' d='m4.5 18.75 7.5-7.5 7.5 7.5' /><path stroke-linecap='round' stroke-linejoin='round' d='m4.5 12.75 7.5-7.5 7.5 7.5' /></svg>$prevtitle</a>"); + } + if($nextlink) { + echo("<a style='width: 100%; box-sizing: border-box;' href='$nextlink'><svg style='max-height: 1em;' xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 4 28 16' stroke-width='1.5' stroke='currentColor' class='size-6'><path stroke-linecap='round' stroke-linejoin='round' d='m4.5 5.25 7.5 7.5 7.5-7.5m-15 6 7.5 7.5 7.5-7.5' /></svg>$nexttitle</a>"); + } + ?> + </nav> + <hr> <h2>Comments</h2> - <form action="/blog/comment/submit.php" method="post" autocomplete="off"> + <form action="/guestbook/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> + <textarea name="msg" placeholder="I know what you are." style="opacity: 0; position: absolute; left: -10000rem; height: 0; width: 0; overflow: clip;"></textarea> + <div id="commentform-top"> + <input type="text" name="name" placeholder="Name"> + <input type="text" name="website" placeholder="Website (optional)"> + <input type="text" name="botcheck" placeholder="Bot test (type "isopod")"> + </div> + <textarea name="message" placeholder="Comment (Now supports Markdown!)"></textarea> + <div id="commentform-bottom"> + <?php + if($return) { + echo($gbform_messages[$return]); + } + ?> + <input type="submit" value="Submit"> + </div> </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; ?> + <?php include('../../../guestbook/comments.php'); echo_comments(preg_replace("/^.*\//","",getcwd()), $Parsedown); ?> </body> </html> |
