getsource: turn missing pages into a 404

Also restructure so we return early on missing pages.
master
Simon McVittie 2009-07-26 16:45:01 +01:00
parent 3f520da78a
commit 0afcec7346
1 changed files with 21 additions and 17 deletions

View File

@ -55,7 +55,16 @@ sub cgi_getsource ($) {
IkiWiki::loadindex(); IkiWiki::loadindex();
if ($IkiWiki::pagesources{$page}) { if (! exists $IkiWiki::pagesources{$page}) {
IkiWiki::cgi_custom_failure(
$cgi->header(-status => "404 Not Found"),
IkiWiki::misctemplate(gettext("missing page"),
"<p>".
sprintf(gettext("The page %s does not exist."),
htmllink("", "", $page)).
"</p>"));
exit;
}
my $data = IkiWiki::readfile(IkiWiki::srcfile($IkiWiki::pagesources{$page})); my $data = IkiWiki::readfile(IkiWiki::srcfile($IkiWiki::pagesources{$page}));
@ -69,11 +78,6 @@ sub cgi_getsource ($) {
print $data; print $data;
exit 0;
}
error("Unable to find page source for page: $page");
exit 0; exit 0;
} }