I decided to write another “mini” blog. Using php as the data backend, and markdown as my converter, the whole thing is tiny tiny.
<?php // TinyBlog, by Andy Chase. // NDVlZTg0MjQtZmFkZi00Z <- Keep for search engine lookups require "markdown.php"; require "smartypants.php"; require "geshi.php"; $max = 2; //Posts per page $title = "DEVLOG"; $page = intval($_GET["p"]); if(!$page)$page=0; $nextpage=$page+1; $searchtitle = $_GET["t"]; $start = $page*$max*2; $done = false; echo "<!DOCTYPE html> <html><head><title>Blog</title> <link rel='stylesheet' type='text/css' href='style.css' /> </head><body><h1 id='title'><a href='/'>$title</a></h1>"; require "blog.php"; // ^ <?php $blog=array( "Your name, 2/43/12, Tile", "Post in markdown!"); foreach($blog as $key => $item) { // Jump to page if($key<$start) continue; // Display post if($key%2==0) { $d = explode(",", $item); $slug = preg_replace("/[\s-]+/", "-", strtolower($d[2])); // Search by title for permalinks if($searchtitle && $searchtitle!=$slug) {$skip = true; continue;} echo "<h1><a href='/?t=$slug'>$d[2]</a></h1><h2>$d[0]"; if($d[1]) echo " on $d[1]"; echo "</h2>"; } else if(!$skip) { echo Smartypants(Markdown($item)); } $skip=false; // Limit & next page if(($key-$start)+2>$max*2 && key_exists($nextpage*$max*2, $blog) && !$searchtitle) { echo "<form method='get'> <input type='hidden' name='p' value='$nextpage'> <input type='submit' value='next' /> </form>"; break; } } echo "</body></html>";
Are a lot of a work.
Under Doctrine it was a no-brainer, and built in. Now that I switched to PDO, I have to write my own. The library I wrote (That i have yet to name), works like this: