commit d0109d324a4a3e4778b18ffe54399d5613341c09
parent e0b1869c9a59998cedb6c7b1ab85b674c46626c7
Author: Robert D Herb <github@robertdherb.com>
Date: Wed, 3 Feb 2016 10:50:10 -0600
Make pages and post work. Next task: Start Parsedown integration
Diffstat:
9 files changed, 51 insertions(+), 6 deletions(-)
diff --git a/.htaccess b/.htaccess
@@ -1,4 +1,4 @@
DirectoryIndex index.php
RewriteEngine On
-RewriteRule ^(.*)/(.*)$ index.php?post=$1 [NC,L]
+RewriteRule ^(.*)/(.*)$ index.php?$1=$2 [NC,L]
diff --git a/README.md b/README.md
@@ -1,2 +1,22 @@
# just-a-blog
A simple blog software that doesn't require a database, and separates content from presentation.
+
+## Features
+- Respects the user
+-- just-a-blog tries to stay out of your way as much as possible.
+-- Doesn't force jquery or any other framework on you.
+-- Degrades gracefully for screenreaders or text-only environments
+-- You can use your preferred tool for editing pages and posts.
+- Compatible
+-- just-a-blog only requires PHP5+. No databases are necessary.
+-- Can port existing HTML pages and posts directly into just-a-blog with no need to reformat. (Just remember to change the extension to .md)
+- Full customization - Since just-a-blog strives to be small and lightweight, editing it should be extremely easy.
+
+## Contact
+Send an email to just-a-blog@robertdherb.com, or try to find me on Skype (rawbherb) or Steam (abigtimeoperator)
+
+## License
+just-a-blog is currently released under the BSD 2-Clause License. See LICENSE for more details.
+
+## Credits
+just-a-blog uses [Parsedown](https://github.com/erusev/parsedown) by [Emanuil Rusev](erusev.com).
diff --git a/functions.php b/functions.php
@@ -35,4 +35,5 @@ function format_name( $name ) {
return $returnThisName;
}
+
?>
diff --git a/header.php b/header.php
@@ -1,7 +1,7 @@
<?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 .= "\t\t\t<li id=\"" . $thisPage . "\">\n\t\t\t\t<a href=\"/" . $url . $blogDir . "/pages/" . $thisPage . "\">" . format_name( $thisPage ) . "</a></li>\n";
}
$nav .= "</ul>";
$title = "Just a Blog";
diff --git a/index.php b/index.php
@@ -9,12 +9,13 @@
* (c) 2016 Robert D Herb
* All rights reserved.
*
- * For more information see LICENSE.md
+ * For more information see LICENSE
*
*/
$documentRoot = $_SERVER["DOCUMENT_ROOT"];
require_once( "functions.php" );
+require_once( "lib/parsedown/Parsedown.php" );
/* This should probably be an ini file */
$url = "http://localhost/";
@@ -45,15 +46,37 @@ if( !file_exists( "pages/home.md" ) ) {
$postDates = array();
foreach( $posts as $thisPost ) {
- $postDates[filectime( "pages/" . $thisPage)] = $thisPage;
+// $postDates[filectime( "posts/" . $thisPost)] = $thisPost;
+ $postDates[] = filectime( "posts/" . $thisPost);
}
+$posts = array_combine( $postDates, $posts );
+
sort( $pages );
-rsort( $postDates );
+krsort( $posts );
$headerHtml = "templates/header.html";
include( "header.php" );
+$parsedown = new Parsedown();
+
+if( isset( $_GET['page'] ) ) {
+ $content = file_get_contents( "pages/" . $_GET['page'] . ".md" );
+}
+else if( isset( $_GET['post'] ) ) {
+ $content = file_get_contents( "posts/" . $_GET['post'] . ".md" );
-//foreach( $pageDates as $thisDate ) {}
+}
+else {
+ print( "
+ <ul id=\"posts\">" );
+ foreach( $posts as $thisPost ) {
+ print( "
+ <li><a href=\"" . $url . $blogDir . "pages/" . $thisPost . "\">" . date( "Y-m-d", key( $posts ) ) . " - " . format_name( $thisPost ) . "</a></li>" );
+ }
+ print( "
+ </ul>" );
+
+write_html( file_get_contents( "html/footer.html" ) );
+}
?>
diff --git a/posts/alphanumeric.md b/posts/alphanumeric.md
diff --git a/posts/betanumeric.md b/posts/betanumeric.md
diff --git a/posts/test2.md b/posts/test2.md
diff --git a/posts/test_post.md b/posts/test_post.md
@@ -0,0 +1 @@
+This is a test post!