Switching Systems
This commit is contained in:
parent
3f4485154e
commit
8cdb006208
@ -2,4 +2,3 @@
|
||||
define("TITLE", "Static File Generator");
|
||||
define("MD_DIR", "MarkdownFiles");
|
||||
define("DEFAULT_FILE", "out.html");
|
||||
?>
|
||||
|
59
manager.php
59
manager.php
@ -38,54 +38,73 @@ function buildStaticPage() {
|
||||
}
|
||||
|
||||
function showAdminPage() {
|
||||
outputHTMLHeader();
|
||||
$out = '<form action="/manager.php?f=build" method="POST">'."\n"
|
||||
.' <div>'."\n"
|
||||
$out = getHTMLHeader(TITLE)
|
||||
.'<form class="pure-form" action="/manager.php?f=build" method="POST">'."\n"
|
||||
.' <fieldset>'."\n"
|
||||
.' <div class="margin10">'."\n"
|
||||
.' <label for="filename">Output File:</label>'."\n"
|
||||
.' <input name="filename" value="worship.html" placeholder="File Name" />'."\n"
|
||||
.' <button class="pure-button pure-button-primary" type="submit">Build</button>'."\n"
|
||||
.' </div>'."\n"
|
||||
.' <div>'."\n"
|
||||
.' <div class="margin10">'."\n"
|
||||
.' <label for="filter">Filter</label>'."\n"
|
||||
.' <input name="filter" value="" placeholder="Filter Files" />'."\n"
|
||||
.' <input onkeyup="updateFilter(this.value);" 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) {
|
||||
$out.=' <tr>'."\n"
|
||||
.' <td>'.basename($file, '.md').'</td><td><button onclick="addSong('.$filename.');">Add</button></td>'."\n"
|
||||
$base = basename($file, '.md');
|
||||
$out.=' <tr data-file="'.$base.'">'."\n"
|
||||
.' <td>'.$base.'</td>'
|
||||
.'<td><button class="pure-button pure-button-secondary" onclick="addSong('.$filename.');">Add</button></td>'."\n"
|
||||
.' </tr>'."\n";
|
||||
}
|
||||
$out.= ' </tbody>'."\n"
|
||||
$out.=' </tbody>'."\n"
|
||||
.' </table>'."\n"
|
||||
.' </div>'."\n"
|
||||
.' <button type="submit">Build</button>'."\n"
|
||||
.' </fieldset>'."\n"
|
||||
.'</form>'."\n"
|
||||
.'<script>'."\n"
|
||||
.'</script>'."\n";
|
||||
outputHTMLFooter();
|
||||
.'var tablerows = document.getElementsByTagName("tr");'."\n"
|
||||
.'function updateFilter(flt) {'."\n"
|
||||
.' flt = flt.toLowerCase();'."\n"
|
||||
.' for(var i = 0; i < tablerows.length; i++) {'."\n"
|
||||
.' if(tablerows[i].dataset.file.toLowerCase().startsWith(flt)) {'."\n"
|
||||
.' tablerows[i].classList.remove("hidden");'."\n"
|
||||
.' } else {'."\n"
|
||||
.' tablerows[i].classList.add("hidden");'."\n"
|
||||
.' }'."\n"
|
||||
.' }'."\n"
|
||||
.'}'."\n"
|
||||
.'</script>'."\n"
|
||||
.getHTMLFooter();
|
||||
echo $out;
|
||||
}
|
||||
|
||||
function outputHTMLHeader($title = TITLE, $ret = false) {
|
||||
function getHTMLHeader($title = TITLE) {
|
||||
$out = '<!DOCTYPE html>'."\n"
|
||||
.'<html lang="en">'."\n"
|
||||
.' <head>'."\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"
|
||||
.' <style type="text/css">'."\n"
|
||||
.' body { margin: 20px; }'."\n"
|
||||
.' td {'."\n"
|
||||
.' padding-top: 2px;'."\n"
|
||||
.' padding-bottom: 3px;'."\n"
|
||||
.' }'."\n"
|
||||
.' .margin10 {'."\n"
|
||||
.' margin: 10px;'."\n"
|
||||
.' }'."\n"
|
||||
.' </style>'."\n"
|
||||
.' </head>'."\n"
|
||||
.' <body>'."\n";
|
||||
if($ret) {
|
||||
return $out;
|
||||
}
|
||||
echo $out;
|
||||
}
|
||||
|
||||
function outputHTMLFooter($ret = false) {
|
||||
function getHTMLFooter() {
|
||||
$out = ' </body>'."\n"
|
||||
.'</html>'."\n";
|
||||
if($ret) {
|
||||
return $out;
|
||||
}
|
||||
echo $out;
|
||||
}
|
||||
|
||||
?>
|
||||
|
Loading…
Reference in New Issue
Block a user