1
0
Fork 1
You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
This repo is archived. You can view files and clone it, but cannot push or open issues/pull-requests.

33 lines
945 B
PHP

<?php
// Perform static site generation.
require_once "getenv.php";
// https://stackoverflow.com/a/17161106
function rglob($pattern, $flags = 0) {
$files = glob($pattern, $flags);
foreach (glob(dirname($pattern).'/*', GLOB_ONLYDIR|GLOB_NOSORT) as $dir) {
$files = array_merge(
[],
...[$files, rglob($dir . "/" . basename($pattern), $flags)]
);
}
return $files;
}
foreach (rglob("$TEMPLATES_ROOT/*.php") as $phppath) {
// Do not render auxilliary PHP files.
if (str_contains("$phppath", "/+") || $phppath[0] == "+")
continue;
$docpath = str_replace($TEMPLATES_ROOT, $DOCUMENT_ROOT, $phppath);
$docpath = str_replace(".php", ".html", $docpath);
// This works? Yes, yes it does.
// We do this to isolate the environment and include-once triggers,
// otherwise we could include the documents in an ob_* wrapper.
$document = `php $phppath`;
file_put_contents($docpath, $document);
}
?>