feat: properly utilise 404 page again

This commit is contained in:
David Bailey 2023-12-18 16:00:28 +01:00
parent d47c4e2072
commit f2f8a235c8

View file

@ -34,9 +34,7 @@ $twig->addRuntimeLoader(new class implements RuntimeLoaderInterface {
$SURI = $_SERVER['REQUEST_URI'];
if($SURI == '/') {
echo $twig->render('root.html');
} elseif(preg_match('/^\/api\/admin/', $SURI)) {
if(preg_match('/^\/api\/admin/', $SURI)) {
header('Content-Type: application/json');
$user_api_key = '';
@ -82,6 +80,18 @@ if($SURI == '/') {
} elseif(true) {
$post = $adapter->get_post_by_path($SURI);
if(!$post['found']) {
echo $twig->render('post_types/rrror.html',[
"error_code" => '404 Hoard not found!',
"error_description" => "Well, we searched
far and wide for `" . $SURI . "` but
somehow it must have gotten lost... Sorry!",
"post" => $post
]);
exit(0);
}
if($post['post_metadata']['type'] == 'directory') {
if(preg_match('/^(.*[^\/])((?:#.*)?)$/', $SURI, $match)) {
header('Location: ' . $match[1] . '/' . $match[2]);