diff options
author | Joey Hess <joey@kodama.kitenet.net> | 2008-07-12 23:23:25 -0400 |
---|---|---|
committer | Joey Hess <joey@kodama.kitenet.net> | 2008-07-12 23:23:25 -0400 |
commit | e3c0e4977449de2eec36e254a7e131693ba2f822 (patch) | |
tree | 09fd42fb4d3328a36dd3622a47cb449b68f35149 | |
parent | e4e3d7e2d4195bcd22c467522719c9c6dd39216b (diff) |
only htmlize errors when cgi is actually running
-rw-r--r-- | IkiWiki.pm | 5 | ||||
-rw-r--r-- | IkiWiki/CGI.pm | 10 | ||||
-rw-r--r-- | doc/bugs/html_errors.mdwn | 3 | ||||
-rwxr-xr-x | ikiwiki.in | 7 | ||||
-rw-r--r-- | po/ikiwiki.pot | 50 |
5 files changed, 47 insertions, 28 deletions
diff --git a/IkiWiki.pm b/IkiWiki.pm index f1a5f8058..d4e19c388 100644 --- a/IkiWiki.pm +++ b/IkiWiki.pm @@ -189,11 +189,6 @@ sub loadplugin ($) { #{{{ sub error ($;$) { #{{{ my $message=shift; my $cleaner=shift; - if ($config{cgi}) { - print "Content-type: text/html\n\n"; - print misctemplate(gettext("Error"), - "<p>".gettext("Error").": $message</p>"); - } log_message('err' => $message) if $config{syslog}; if (defined $cleaner) { $cleaner->(); diff --git a/IkiWiki/CGI.pm b/IkiWiki/CGI.pm index 6770f6feb..d805506aa 100644 --- a/IkiWiki/CGI.pm +++ b/IkiWiki/CGI.pm @@ -750,4 +750,14 @@ sub cgi (;$$) { #{{{ } } #}}} +# Does not need tobe called directly; all errors will go through here. +sub cgierror ($) { #{{{ + my $message=shift; + + print "Content-type: text/html\n\n"; + print misctemplate(gettext("Error"), + "<p class=\"error\">".gettext("Error").": $message</p>"); + die $@; +} #}}} + 1 diff --git a/doc/bugs/html_errors.mdwn b/doc/bugs/html_errors.mdwn index 5a60e0449..aef2f7f71 100644 --- a/doc/bugs/html_errors.mdwn +++ b/doc/bugs/html_errors.mdwn @@ -1,2 +1,5 @@ ikiwiki will generate html formatted error messages to the command line if --cgi is set, even if it's not yet running as a cgi + +> [[done]], at last. Oldest open bug.. just thought of an elegant fix! +> --[[Joey]] diff --git a/ikiwiki.in b/ikiwiki.in index e0a591824..cc3f210b5 100755 --- a/ikiwiki.in +++ b/ikiwiki.in @@ -100,7 +100,7 @@ sub getconfig () { #{{{ else { # wrapper passes a full config structure in the environment # variable - eval possibly_foolish_untaint($ENV{WRAPPED_OPTIONS}); + eval {possibly_foolish_untaint($ENV{WRAPPED_OPTIONS})}; if ($@) { error("WRAPPED_OPTIONS: $@"); } @@ -123,7 +123,10 @@ sub main () { #{{{ } elsif ($config{cgi}) { require IkiWiki::CGI; - cgi(); + eval {cgi()}; + if ($@) { + cgierror($@); + } } elsif ($config{render}) { require IkiWiki::Render; diff --git a/po/ikiwiki.pot b/po/ikiwiki.pot index 8aef6cc1a..f94f5bdd3 100644 --- a/po/ikiwiki.pot +++ b/po/ikiwiki.pot @@ -8,7 +8,7 @@ msgid "" msgstr "" "Project-Id-Version: PACKAGE VERSION\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2008-07-11 06:04-0400\n" +"POT-Creation-Date: 2008-07-12 23:07-0400\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n" "Language-Team: LANGUAGE <LL@li.org>\n" @@ -50,7 +50,7 @@ msgid "%s is not an editable page" msgstr "" #: ../IkiWiki/CGI.pm:438 ../IkiWiki/Plugin/brokenlinks.pm:24 -#: ../IkiWiki/Plugin/inline.pm:266 ../IkiWiki/Plugin/opendiscussion.pm:17 +#: ../IkiWiki/Plugin/inline.pm:261 ../IkiWiki/Plugin/opendiscussion.pm:17 #: ../IkiWiki/Plugin/orphans.pm:28 ../IkiWiki/Render.pm:95 #: ../IkiWiki/Render.pm:162 msgid "discussion" @@ -71,6 +71,10 @@ msgstr "" msgid "You are banned." msgstr "" +#: ../IkiWiki/CGI.pm:758 ../IkiWiki/CGI.pm:759 +msgid "Error" +msgstr "" + #: ../IkiWiki/Plugin/aggregate.pm:53 msgid "Aggregation triggered via web." msgstr "" @@ -148,7 +152,7 @@ msgstr "" msgid "deleting bucket.." msgstr "" -#: ../IkiWiki/Plugin/amazon_s3.pm:37 ../IkiWiki/Setup.pm:115 +#: ../IkiWiki/Plugin/amazon_s3.pm:37 ../IkiWiki/Setup.pm:117 msgid "done" msgstr "" @@ -228,6 +232,10 @@ msgstr "" msgid "prog not a valid graphviz program" msgstr "" +#: ../IkiWiki/Plugin/img.pm:49 +msgid "Image::Magick not installed" +msgstr "" + #: ../IkiWiki/Plugin/img.pm:56 #, perl-format msgid "bad size \"%s\"" @@ -253,29 +261,29 @@ msgstr "" msgid "Must specify url to wiki with --url when using --rss or --atom" msgstr "" -#: ../IkiWiki/Plugin/inline.pm:106 +#: ../IkiWiki/Plugin/inline.pm:101 msgid "missing pages parameter" msgstr "" -#: ../IkiWiki/Plugin/inline.pm:154 +#: ../IkiWiki/Plugin/inline.pm:149 #, perl-format msgid "unknown sort type %s" msgstr "" -#: ../IkiWiki/Plugin/inline.pm:225 +#: ../IkiWiki/Plugin/inline.pm:220 msgid "Add a new post titled:" msgstr "" -#: ../IkiWiki/Plugin/inline.pm:241 +#: ../IkiWiki/Plugin/inline.pm:236 #, perl-format msgid "nonexistant template %s" msgstr "" -#: ../IkiWiki/Plugin/inline.pm:274 ../IkiWiki/Render.pm:99 +#: ../IkiWiki/Plugin/inline.pm:269 ../IkiWiki/Render.pm:99 msgid "Discussion" msgstr "" -#: ../IkiWiki/Plugin/inline.pm:504 +#: ../IkiWiki/Plugin/inline.pm:506 msgid "RPC::XML::Client not found, not pinging" msgstr "" @@ -297,15 +305,15 @@ msgstr "" msgid "failed to load Markdown.pm perl module (%s) or /usr/bin/markdown (%s)" msgstr "" -#: ../IkiWiki/Plugin/meta.pm:137 +#: ../IkiWiki/Plugin/meta.pm:141 msgid "stylesheet not found" msgstr "" -#: ../IkiWiki/Plugin/meta.pm:171 +#: ../IkiWiki/Plugin/meta.pm:175 msgid "redir page not found" msgstr "" -#: ../IkiWiki/Plugin/meta.pm:184 +#: ../IkiWiki/Plugin/meta.pm:188 msgid "redir cycle is not allowed" msgstr "" @@ -387,11 +395,11 @@ msgstr "" msgid "LWP not found, not pinging" msgstr "" -#: ../IkiWiki/Plugin/poll.pm:65 +#: ../IkiWiki/Plugin/poll.pm:60 msgid "vote" msgstr "" -#: ../IkiWiki/Plugin/poll.pm:73 +#: ../IkiWiki/Plugin/poll.pm:68 msgid "Total votes:" msgstr "" @@ -660,11 +668,11 @@ msgstr "" msgid "generating wrappers.." msgstr "" -#: ../IkiWiki/Setup.pm:105 +#: ../IkiWiki/Setup.pm:107 msgid "rebuilding wiki.." msgstr "" -#: ../IkiWiki/Setup.pm:108 +#: ../IkiWiki/Setup.pm:110 msgid "refreshing wiki.." msgstr "" @@ -712,15 +720,15 @@ msgstr "" msgid "Must specify url to wiki with --url when using --cgi" msgstr "" -#: ../IkiWiki.pm:194 ../IkiWiki.pm:195 -msgid "Error" -msgstr "" - #. translators: The first parameter is a #. translators: preprocessor directive name, #. translators: the second a page name, the #. translators: third a number. -#: ../IkiWiki.pm:770 +#: ../IkiWiki.pm:765 #, perl-format msgid "%s preprocessing loop detected on %s at depth %i" msgstr "" + +#: ../IkiWiki.pm:1203 +msgid "yes" +msgstr "" |