getsource: turn missing pages into a 404
Also restructure so we return early on missing pages.master
parent
3f520da78a
commit
0afcec7346
|
@ -55,24 +55,28 @@ sub cgi_getsource ($) {
|
||||||
|
|
||||||
IkiWiki::loadindex();
|
IkiWiki::loadindex();
|
||||||
|
|
||||||
if ($IkiWiki::pagesources{$page}) {
|
if (! exists $IkiWiki::pagesources{$page}) {
|
||||||
|
IkiWiki::cgi_custom_failure(
|
||||||
my $data = IkiWiki::readfile(IkiWiki::srcfile($IkiWiki::pagesources{$page}));
|
$cgi->header(-status => "404 Not Found"),
|
||||||
|
IkiWiki::misctemplate(gettext("missing page"),
|
||||||
if (! $config{getsource_mimetype}) {
|
"<p>".
|
||||||
$config{getsource_mimetype} = "text/plain; charset=utf-8";
|
sprintf(gettext("The page %s does not exist."),
|
||||||
}
|
htmllink("", "", $page)).
|
||||||
|
"</p>"));
|
||||||
print "Content-Type: $config{getsource_mimetype}\r\n";
|
exit;
|
||||||
|
|
||||||
print ("\r\n");
|
|
||||||
|
|
||||||
print $data;
|
|
||||||
|
|
||||||
exit 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
error("Unable to find page source for page: $page");
|
my $data = IkiWiki::readfile(IkiWiki::srcfile($IkiWiki::pagesources{$page}));
|
||||||
|
|
||||||
|
if (! $config{getsource_mimetype}) {
|
||||||
|
$config{getsource_mimetype} = "text/plain; charset=utf-8";
|
||||||
|
}
|
||||||
|
|
||||||
|
print "Content-Type: $config{getsource_mimetype}\r\n";
|
||||||
|
|
||||||
|
print ("\r\n");
|
||||||
|
|
||||||
|
print $data;
|
||||||
|
|
||||||
exit 0;
|
exit 0;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue