Added samuel johnson dictionary to finbrook and "prehp" capabilities
This commit is contained in:
parent
06de890360
commit
506d2605ba
40
router.php
40
router.php
|
@ -79,38 +79,32 @@ function uri_from_file($file) {
|
|||
return substr($file, 0, strrpos($file, '.'));
|
||||
}
|
||||
|
||||
function try_file($uri, $ext) {
|
||||
|
||||
$tryf = "$uri/index";
|
||||
$tryuri = ltrim($tryf, '/');
|
||||
|
||||
if (is_file("$tryf.$ext")) return "$tryf.$ext";
|
||||
else if (is_file("$uri.$ext")) return "$uri.$ext";
|
||||
}
|
||||
|
||||
|
||||
function load_page($tryuri) {
|
||||
global $site;
|
||||
|
||||
$mainphp = "";
|
||||
$prehp = "";
|
||||
$jsonf = "";
|
||||
$parsef = "";
|
||||
|
||||
/* Looking for 3 things: a base, a content, and a template */
|
||||
|
||||
$tryf = "$tryuri/index";
|
||||
$tryf = ltrim($tryf, '/');
|
||||
$jsonf = try_file($tryuri, "json");
|
||||
$mainphp = try_file($tryuri, "php");
|
||||
$parsef = try_file($tryuri, "md");
|
||||
$prehp = try_file($tryuri, "prehp");
|
||||
|
||||
if (is_file("$tryf.json")) {
|
||||
$jsonf = "$tryf.json";
|
||||
} else if (is_file("$tryuri.json")) {
|
||||
$jsonf = "$tryuri.json";
|
||||
}
|
||||
|
||||
if (is_file("$tryf.php")) {
|
||||
$mainphp = "$tryf.php";
|
||||
}
|
||||
else if (is_file("$tryuri.php")) {
|
||||
$mainphp = "$tryuri.php";
|
||||
}
|
||||
|
||||
if (is_file("$tryf.md")) {
|
||||
$parsef = "$tryf.md";
|
||||
} else if (is_file("$tryuri.md")) {
|
||||
$parsef = "$tryuri.md";
|
||||
}
|
||||
|
||||
if (empty($mainphp) && empty($jsonf) && empty($parsef)) {
|
||||
if (empty($mainphp) && empty($jsonf) && empty($parsef) && empty($prehp)) {
|
||||
load_page("404");
|
||||
return;
|
||||
}
|
||||
|
@ -154,6 +148,8 @@ if (!empty($parsef)) {
|
|||
$page['title'] = $obj->title ?? $site['title'];
|
||||
$page['desc'] = $obj->desc ?? $site['desc'];
|
||||
|
||||
if (!empty($prehp)) include $prehp;
|
||||
|
||||
include "base.php";
|
||||
|
||||
$tt = microtime(true) - $_SERVER['REQUEST_TIME_FLOAT'];
|
||||
|
|
Loading…
Reference in a new issue