Initial Commit

This commit is contained in:
Brian Buller 2017-07-16 15:10:52 -05:00
commit 86235fa2ae
4 changed files with 1639 additions and 0 deletions

1
MarkdownFiles/.gitignore vendored Normal file
View File

@ -0,0 +1 @@
*.md

1548
Parsedown.php Normal file

File diff suppressed because it is too large Load Diff

7
README.md Normal file
View File

@ -0,0 +1,7 @@
StaticMD
====
StaticMD is a very simple app for building a static HTML site from files chosen out of a directory full of markdown
files. Just drop it on a server that supports PHP. Use it for whatever you want.
Enjoy!

83
manager.php Normal file
View File

@ -0,0 +1,83 @@
<?php
require_once('Parsedown.php');
define("TITLE", "Static File Generator");
define("MD_DIR", "MarkdownFiles");
$func = $_GET['f'];
switch($func) {
case 'build': // Build the worship.html page
buildStaticPage();
break;
default:
showAdminPage();
break;
}
function buildStaticPage() {
$pd = new Parsedown();
$title = !empty($_POST['title'])?$_POST['title']:TITLE;
$out = outputHTMLHeader($title, true);
$out .= '<pre>';
$out .= print_r($_POST, true);
$out .= '</pre>';
$out .= '======';
foreach($_POST['chosen_files'] as $file) {
if(file_exists($file)) {
$md = file_get_contents($file);
$out .= '<div class="afile">';
$out .= $pd->text($md);
$out .= "</div>";
}
}
$out .= outputHTMLFooter(true);
// For now, echo it.
echo $out;
}
function showAdminPage() {
outputHTMLHeader();
echo '<form action="/manager.php?f=build" method="POST">';
echo ' <div>';
echo ' <select multiple="multiple" name="chosen_files[]">';
foreach(glob(MD_DIR.'/*.md') as $file) {
echo ' <option value="'.$file.'">'.basename($file, '.md').'</option>';
echo ' <option value="'.$file.'">'.basename($file, '.md').'</option>';
echo ' <option value="'.$file.'">'.basename($file, '.md').'</option>';
echo ' <option value="'.$file.'">'.basename($file, '.md').'</option>';
echo ' <option value="'.$file.'">'.basename($file, '.md').'</option>';
}
echo ' </select>';
echo ' </div>';
echo ' <div>';
echo ' <label for="filename">Output File:</label>';
echo ' <input name="filename" value="" placeholder="File Name" />';
echo ' </div>';
echo ' <button type="submit">Build</button>';
echo '</form>';
outputHTMLFooter();
}
function outputHTMLHeader($title = TITLE, $ret = false) {
$out = '<!DOCTYPE html>'."\n"
.'<html lang="en">'."\n"
.' <head>'."\n"
.' <title>'.$title.'</title>'."\n"
.' </head>'."\n"
.' <body>'."\n";
if($ret) {
return $out;
}
echo $out;
}
function outputHTMLFooter($ret = false) {
$out = ' </body>'."\n"
.'</html>'."\n";
if($ret) {
return $out;
}
echo $out;
}
?>