summaryrefslogtreecommitdiff
path: root/IkiWiki/Plugin
diff options
context:
space:
mode:
authorSimon McVittie <smcv@ http://smcv.pseudorandom.co.uk/>2009-07-26 16:45:01 +0100
committerSimon McVittie <smcv@ http://smcv.pseudorandom.co.uk/>2009-07-26 17:04:30 +0100
commit0afcec734622811b8910d3df5d102df58d429a51 (patch)
treea63c71019b445f7f8a4839ddefd9ff79b92cd983 /IkiWiki/Plugin
parent3f520da78aeda38e47b43b28023b52f321f71291 (diff)
getsource: turn missing pages into a 404
Also restructure so we return early on missing pages.
Diffstat (limited to 'IkiWiki/Plugin')
-rw-r--r--IkiWiki/Plugin/getsource.pm38
1 files changed, 21 insertions, 17 deletions
diff --git a/IkiWiki/Plugin/getsource.pm b/IkiWiki/Plugin/getsource.pm
index 08d9d110c..6a208f1e7 100644
--- a/IkiWiki/Plugin/getsource.pm
+++ b/IkiWiki/Plugin/getsource.pm
@@ -55,25 +55,29 @@ sub cgi_getsource ($) {
IkiWiki::loadindex();
- if ($IkiWiki::pagesources{$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;
+ 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}));
+
+ if (! $config{getsource_mimetype}) {
+ $config{getsource_mimetype} = "text/plain; charset=utf-8";
}
-
- error("Unable to find page source for page: $page");
+ print "Content-Type: $config{getsource_mimetype}\r\n";
+
+ print ("\r\n");
+
+ print $data;
+
exit 0;
}