|
|
@ -23,9 +23,9 @@
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|
* Generate HTML from PHP files in the templates directory.
|
|
|
|
* Generate files from PHP templates in the templates directory.
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
function generate_html() {
|
|
|
|
function generate_files() {
|
|
|
|
global $LOGGING_VERBOSITY, $TEMPLATES_ROOT, $DOCUMENT_ROOT;
|
|
|
|
global $LOGGING_VERBOSITY, $TEMPLATES_ROOT, $DOCUMENT_ROOT;
|
|
|
|
|
|
|
|
|
|
|
|
$flags = LoggingVerbosity::getVerbosityFlags($LOGGING_VERBOSITY)[1];
|
|
|
|
$flags = LoggingVerbosity::getVerbosityFlags($LOGGING_VERBOSITY)[1];
|
|
|
@ -35,14 +35,21 @@
|
|
|
|
if (str_contains("$phppath", "/+") || $phppath[0] == "+")
|
|
|
|
if (str_contains("$phppath", "/+") || $phppath[0] == "+")
|
|
|
|
continue;
|
|
|
|
continue;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$filename = basename($phppath);
|
|
|
|
$docpath = str_replace($TEMPLATES_ROOT, $DOCUMENT_ROOT, $phppath);
|
|
|
|
$docpath = str_replace($TEMPLATES_ROOT, $DOCUMENT_ROOT, $phppath);
|
|
|
|
$relpath = str_replace($TEMPLATES_ROOT, "", $phppath);
|
|
|
|
$relpath = str_replace($TEMPLATES_ROOT, "", $phppath);
|
|
|
|
$docpath = str_replace(".php", ".html", $docpath);
|
|
|
|
$dirname = dirname($relpath);
|
|
|
|
|
|
|
|
if (preg_match("/[^.]+\\.\w+\\.php$/", $filename) == 1) {
|
|
|
|
|
|
|
|
$docpath = str_replace(".php", "", $docpath);
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
$docpath = str_replace(".php", ".html", $docpath);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// We do this to isolate the environment and include-once triggers,
|
|
|
|
// We do this to isolate the environment and include-once triggers,
|
|
|
|
// otherwise we could include the documents in an ob_* wrapper.
|
|
|
|
// otherwise we could include the documents in an ob_* wrapper.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
mkdir("$DOCUMENT_ROOT/$dirname", recursive: true);
|
|
|
|
|
|
|
|
|
|
|
|
log_info("Generating output for $relpath.");
|
|
|
|
log_info("Generating output for $relpath.");
|
|
|
|
$output = [];
|
|
|
|
$output = [];
|
|
|
|
|
|
|
|
|
|
|
@ -51,7 +58,7 @@
|
|
|
|
exec("cd '$TEMPLATES_ROOT'; php '$phppath' $flags", $output, $exit_code);
|
|
|
|
exec("cd '$TEMPLATES_ROOT'; php '$phppath' $flags", $output, $exit_code);
|
|
|
|
|
|
|
|
|
|
|
|
if ($exit_code != 0 || empty($output)) {
|
|
|
|
if ($exit_code != 0 || empty($output)) {
|
|
|
|
log_error("HTML generation failed.");
|
|
|
|
log_error("Site generation failed.");
|
|
|
|
exit(255);
|
|
|
|
exit(255);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -60,8 +67,8 @@
|
|
|
|
file_put_contents($docpath, join("\n", $output));
|
|
|
|
file_put_contents($docpath, join("\n", $output));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
log_info("Done generating HTML.");
|
|
|
|
log_info("Done generating site.");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
generate_html();
|
|
|
|
generate_files();
|
|
|
|
?>
|
|
|
|
?>
|
|
|
|