Another Commit

This commit is contained in:
Brian Buller 2017-07-16 18:13:10 -05:00
parent 86235fa2ae
commit 3f4485154e
3 changed files with 35 additions and 21 deletions

1
.gitignore vendored Normal file
View File

@ -0,0 +1 @@
config.php

5
config.example.php Normal file
View File

@ -0,0 +1,5 @@
<?php
define("TITLE", "Static File Generator");
define("MD_DIR", "MarkdownFiles");
define("DEFAULT_FILE", "out.html");
?>

View File

@ -1,8 +1,10 @@
<?php <?php
require_once('Parsedown.php'); require_once('Parsedown.php');
if(file_exists('config.php')) {
define("TITLE", "Static File Generator"); require_once('config.php');
define("MD_DIR", "MarkdownFiles"); } else {
require_once('config.example.php');
}
$func = $_GET['f']; $func = $_GET['f'];
switch($func) { switch($func) {
@ -31,30 +33,35 @@ function buildStaticPage() {
} }
} }
$out .= outputHTMLFooter(true); $out .= outputHTMLFooter(true);
// For now, echo it. $outfile = !empty($_POST['outfile'])?$_POST['outfile']:DEFAULT_FILE;
echo $out; file_put_contents($outfile, $out);
} }
function showAdminPage() { function showAdminPage() {
outputHTMLHeader(); outputHTMLHeader();
echo '<form action="/manager.php?f=build" method="POST">'; $out = '<form action="/manager.php?f=build" method="POST">'."\n"
echo ' <div>'; .' <div>'."\n"
echo ' <select multiple="multiple" name="chosen_files[]">'; .' <label for="filename">Output File:</label>'."\n"
.' <input name="filename" value="worship.html" placeholder="File Name" />'."\n"
.' </div>'."\n"
.' <div>'."\n"
.' <label for="filter">Filter</label>'."\n"
.' <input name="filter" value="" placeholder="Filter Files" />'."\n"
.' <table>'."\n"
.' <thead><th>File</th><th></th></thead>'."\n"
.' <tbody>'."\n";
foreach(glob(MD_DIR.'/*.md') as $file) { foreach(glob(MD_DIR.'/*.md') as $file) {
echo ' <option value="'.$file.'">'.basename($file, '.md').'</option>'; $out.=' <tr>'."\n"
echo ' <option value="'.$file.'">'.basename($file, '.md').'</option>'; .' <td>'.basename($file, '.md').'</td><td><button onclick="addSong('.$filename.');">Add</button></td>'."\n"
echo ' <option value="'.$file.'">'.basename($file, '.md').'</option>'; .' </tr>'."\n";
echo ' <option value="'.$file.'">'.basename($file, '.md').'</option>';
echo ' <option value="'.$file.'">'.basename($file, '.md').'</option>';
} }
echo ' </select>'; $out.= ' </tbody>'."\n"
echo ' </div>'; .' </table>'."\n"
echo ' <div>'; .' </div>'."\n"
echo ' <label for="filename">Output File:</label>'; .' <button type="submit">Build</button>'."\n"
echo ' <input name="filename" value="" placeholder="File Name" />'; .'</form>'."\n"
echo ' </div>'; .'<script>'."\n"
echo ' <button type="submit">Build</button>'; .'</script>'."\n";
echo '</form>';
outputHTMLFooter(); outputHTMLFooter();
} }
@ -63,6 +70,7 @@ function outputHTMLHeader($title = TITLE, $ret = false) {
.'<html lang="en">'."\n" .'<html lang="en">'."\n"
.' <head>'."\n" .' <head>'."\n"
.' <title>'.$title.'</title>'."\n" .' <title>'.$title.'</title>'."\n"
.' <link rel="stylesheet" href="https://unpkg.com/purecss@1.0.0/build/pure-min.css" integrity="sha384-nn4HPE8lTHyVtfCBi5yW9d20FjT8BJwUXyWZT9InLYax14RDjBj46LmSztkmNP9w" crossorigin="anonymous">'."\n"
.' </head>'."\n" .' </head>'."\n"
.' <body>'."\n"; .' <body>'."\n";
if($ret) { if($ret) {