From: Joey Hess Date: Mon, 26 Jan 2009 18:05:38 +0000 (-0500) Subject: Merge branch 'master' into po X-Git-Tag: 3.15~242 X-Git-Url: http://git.vanrenterghem.biz/git.ikiwiki.info.git/commitdiff_plain/12eb056b33e1f01a63c4fcee408c9ac0d96c6b5e?hp=-c Merge branch 'master' into po --- 12eb056b33e1f01a63c4fcee408c9ac0d96c6b5e diff --combined IkiWiki.pm index 08017635f,66fea4369..5df115104 --- a/IkiWiki.pm +++ b/IkiWiki.pm @@@ -21,7 -21,7 +21,7 @@@ our @EXPORT = qw(hook debug error templ bestlink htmllink readfile writefile pagetype srcfile pagename displaytime will_render gettext urlto targetpage add_underlay pagetitle titlepage linkpage newpagefile - inject + inject warning %config %links %pagestate %wikistate %renderedfiles %pagesources %destsources); our $VERSION = 3.00; # plugin interface version, next is ikiwiki version @@@ -174,7 -174,7 +174,7 @@@ sub getsetup () verbose => { type => "boolean", example => 1, - description => "display verbose messages when building?", + description => "display verbose messages?", safe => 1, rebuild => 0, }, @@@ -579,10 -579,6 +579,10 @@@ sub error ($;$) die $message."\n"; } +sub warning ($) { + return log_message(warning => @_); +} + sub debug ($) { return unless $config{verbose}; return log_message(debug => @_); @@@ -1733,7 -1729,7 +1733,7 @@@ sub pagespec_translate ($) $code.="IkiWiki::PageSpec::match_$1(\$page, ".safequote($2).", \@_)"; } else { - $code.=' 0'; + $code.="IkiWiki::FailReason->new(".safequote(qq{unknown function in pagespec "$word"}).")"; } } else { @@@ -1742,7 -1738,7 +1742,7 @@@ } if (! length $code) { - $code=0; + $code="IkiWiki::FailReason->new('empty pagespec')"; } no warnings; diff --combined IkiWiki/Plugin/blogspam.pm index d4b5b36d5,cbd9859a5..58303418f --- a/IkiWiki/Plugin/blogspam.pm +++ b/IkiWiki/Plugin/blogspam.pm @@@ -62,11 -62,11 +62,11 @@@ sub checkcontent (@) } my $url=$defaulturl; - $url = $params{blogspam_server} if exists $params{blogspam_server}; + $url = $config{blogspam_server} if exists $config{blogspam_server}; my $client = RPC::XML::Client->new($url); - my @options = split(",", $params{blogspam_options}) - if exists $params{blogspam_options}; + my @options = split(",", $config{blogspam_options}) + if exists $config{blogspam_options}; # Allow short comments and whitespace-only edits, unless the user # has overridden min-words themselves. @@@ -83,26 -83,29 +83,29 @@@ # and "buy". push @options, "exclude=stopwords"; - my $res = $client->send_request('testComment', { + my %req=( ip => $ENV{REMOTE_ADDR}, - comment => $params{content}, + comment => defined $params{diff} ? $params{diff} : $params{content}, subject => defined $params{subject} ? $params{subject} : "", name => defined $params{author} ? $params{author} : "", link => exists $params{url} ? $params{url} : "", options => join(",", @options), site => $config{url}, version => "ikiwiki ".$IkiWiki::version, - }); + ); + my $res = $client->send_request('testComment', \%req); if (! ref $res || ! defined $res->value) { debug("failed to get response from blogspam server ($url)"); return undef; } elsif ($res->value =~ /^SPAM:(.*)/) { + eval q{use Data::Dumper}; + debug("blogspam server reports ".$res->value.": ".Dumper(\%req)); return gettext("Sorry, but that looks like spam to blogspam: ").$1; } elsif ($res->value ne 'OK') { - debug(gettext("blogspam server failure: ").$res->value); + debug("blogspam server failure: ".$res->value); return undef; } else { diff --combined IkiWiki/Plugin/editpage.pm index cfed51afd,c206d96a4..480e82804 --- a/IkiWiki/Plugin/editpage.pm +++ b/IkiWiki/Plugin/editpage.pm @@@ -93,7 -93,7 +93,7 @@@ sub check_content (@) foreach my $line (split("\n", $params{content})) { push @diff, $line if ! exists $old{$_}; } - $params{content}=join("\n", @diff); + $params{diff}=join("\n", @diff); } my $ok; @@@ -105,11 -105,12 +105,12 @@@ $ok=1; } elsif (ref $ret eq 'CODE') { - $ret->(); + $ret->() unless $params{nonfatal}; $ok=0; } elsif (defined $ret) { - error($ret); + error($ret) unless $params{nonfatal}; + $ok=0; } } diff --combined IkiWiki/Plugin/remove.pm index 2e3614cca,ee5784f20..f62bfb1d7 --- a/IkiWiki/Plugin/remove.pm +++ b/IkiWiki/Plugin/remove.pm @@@ -54,26 -54,6 +54,26 @@@ sub check_canremove ($$$) error("renaming of attachments is not allowed"); } } + + my $canremove; + IkiWiki::run_hooks(canremove => sub { + return if defined $canremove; + my $ret=shift->($page, $q, $session); + if (defined $ret) { + if ($ret eq "") { + $canremove=1; + } + elsif (ref $ret eq 'CODE') { + $ret->(); + $canremove=0; + } + elsif (defined $ret) { + error($ret); + $canremove=0; + } + } + }); + return $canremove; } sub formbuilder_setup (@) { @@@ -238,7 -218,7 +238,7 @@@ sub sessioncgi ($$) } } else { - IkiWiki::showform($form, $buttons, $session, $q); + removal_confirm($q, $session, 0, $q->param("page")); } exit 0;