commit eed3b67ba7be87f830e2a0914bd5ac95da3c4d83
Author: Robert D Herb <github@robertdherb.com>
Date: Fri, 29 Jan 2016 22:33:50 -0600
Initial commit
Diffstat:
11 files changed, 134 insertions(+), 0 deletions(-)
diff --git a/.htaccess b/.htaccess
@@ -0,0 +1,4 @@
+DirectoryIndex index.php
+
+RewriteEngine On
+RewriteRule ^(.*)/(.*)$ index.php?post=$1 [NC,L]
diff --git a/blogdir.txt b/blogdir.txt
@@ -0,0 +1 @@
+blog
diff --git a/functions.php b/functions.php
@@ -0,0 +1,38 @@
+<?php
+
+function write_html() {
+
+ $argc = func_num_args();
+ $argv = func_get_args();
+
+ $output = $argv[0];
+
+ if( $argc > 0 ) {
+ for( $i = 1; $i < $argc; $i++ ) {
+ $searchThisPunk = "(\{" . ($i - 1) . "\})";
+ if( is_array( $argv[$i] ) ) {
+ foreach( $argv[$i] as $thisArg ) {
+ $output = preg_replace( $searchThisPunk, $thisArg, $output );
+ }
+ }
+
+ else {
+ $output = preg_replace( $searchThisPunk, $argv[$i], $output );
+ }
+ }
+ }
+
+ print( $output );
+
+}
+
+function format_name( $name ) {
+
+ $returnThisName = preg_replace( "(_)", " ", $name );
+ $returnThisName = substr( $returnThisName, 0, strpos( $returnThisName, ".md" ) );
+ $returnThisName = ucwords( $returnThisName );
+
+ return $returnThisName;
+
+}
+?>
diff --git a/header.php b/header.php
@@ -0,0 +1,15 @@
+<?php
+$nav = "<ul class=\"nav\">\n";
+foreach( $pages as $thisPage ) {
+ $nav .= "<li id=\"" . $thisPage . "\"><a href=\"" . $url . $blogDir . "/pages/" . $thisPage . "\">" . format_name( $thisPage ) . "</a></li>\n";
+}
+$nav .= "</ul>";
+$title = "Just a Blog";
+
+if( isset( $_GET['page'] ) ) {
+ $thisPage = $_GET['page'];
+ $title .= " - " . format_name( $thisPage );
+}
+
+write_html( file_get_contents( "html/header.html" ), $title, $nav );
+?>
diff --git a/html/.header.html.swp b/html/.header.html.swp
Binary files differ.
diff --git a/html/header.html b/html/header.html
@@ -0,0 +1,8 @@
+<!DOCTYPE html>
+<html>
+ <head>
+ <title>{0}</title>
+ </head>
+
+ <body>
+ {1}
diff --git a/index.php b/index.php
@@ -0,0 +1,59 @@
+<?php
+ /*
+ *
+ * Just a Blog
+ * http://qualityretro.net
+ *
+ * A simple blogging software that leaves presentation up to the user.
+ *
+ * (c) 2016 Robert D Herb
+ * All rights reserved.
+ *
+ * For more information see LICENSE.md
+ *
+ */
+
+$documentRoot = $_SERVER["DOCUMENT_ROOT"];
+require_once( "functions.php" );
+
+ /* This should probably be an ini file */
+$url = "http://localhost/";
+if( file_exists( "./blogdir.txt" ) ) {
+ $blogDir = file_get_contents( "blogdir.txt" );
+}
+
+else {
+ trigger_error( "Could not find blogdir.txt, make sure it is in the same
+ directory as index.php. Assuming blog is at \"/\"", E_USER_NOTICE );
+
+ $blogDir = "";
+}
+
+//$blogDir = $documentRoot . "/" .
+ preg_match( "([0-9A-Za-z_\-]+)", $blogDir ) . "/";
+
+$pages = scandir( "pages/" );
+$pages = array_diff( $pages, array( "..", "." ) );
+$posts = scandir( "posts/" );
+$posts = array_diff( $posts, array( "..", "." ) );
+
+ /* Make sure a home page exists. One should be supplied for you. */
+if( !file_exists( "pages/home.md" ) ) {
+ trigger_error( "No home page. Make sure there is a file named home.md in
+ the pages directory.", E_USER_ERROR );
+}
+
+$postDates = array();
+foreach( $posts as $thisPost ) {
+ $postDates[filectime( "pages/" . $thisPage)] = $thisPage;
+}
+
+sort( $pages );
+rsort( $postDates );
+
+$headerHtml = "templates/header.html";
+include( "header.php" );
+
+//foreach( $pageDates as $thisDate ) {}
+
+?>
diff --git a/lib/parsedown b/lib/parsedown
@@ -0,0 +1 @@
+Subproject commit 94688f21cc5d8bc85f1783b4c8b98b3288d712cb
diff --git a/ls.php b/ls.php
@@ -0,0 +1,8 @@
+<?php
+
+$ls = scandir( "./" );
+
+echo "<pre>", print_r( $ls ), "</pre>";
+
+echo $_SERVER['DOCUMENT_ROOT'];
+?>
diff --git a/pages/home.md b/pages/home.md
diff --git a/pages/this_is_a_test.md b/pages/this_is_a_test.md