make checkcontent compatible with hooks that need the full content
authorintrigeri <intrigeri@boum.org>
Mon, 19 Jan 2009 18:44:39 +0000 (19:44 +0100)
committerintrigeri <intrigeri@boum.org>
Mon, 19 Jan 2009 18:44:39 +0000 (19:44 +0100)
Always pass the full (modified) content in `content` named parameter. When the
user edits an existing wiki page, also pass a `diff` named parameter, which
includes only the lines that they added to the page, or modified.

Signed-off-by: intrigeri <intrigeri@boum.org>
IkiWiki/Plugin/blogspam.pm
IkiWiki/Plugin/editpage.pm
doc/plugins/write.mdwn

index cc6e840f0ec6c8aa31f15e80312c472165a82165..d4b5b36d51e4417f497c234ced17f56482851091 100644 (file)
@@ -85,7 +85,7 @@ sub checkcontent (@) {
 
        my $res = $client->send_request('testComment', {
                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} : "",
index 658d664af38d76b330ae9c27b74e77e5f28172a6..4540b55d058624743d7c6a31be6b31612211f47c 100644 (file)
@@ -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;
index ef14f18dbb13fe81b0f85d1fcb2e85fd6fa63db1..7ba01ae53f1d796bf31677183492a82d485849a0 100644 (file)
@@ -368,8 +368,9 @@ the content the user has entered is a comment, it may also be passed some
 additional parameters: `author`, `url`, and `subject`. The `subject`
 parameter may also be filled with the user's comment about the change.
 
-Note: When the user edits an existing wiki page, the passed `content` will
-include only the lines that they added to the page, or modified.
+Note: When the user edits an existing wiki page, this hook is also
+passed a `diff` named parameter, which will include only the lines
+that they added to the page, or modified.
 
 The hook should return `undef` on success. If the content is disallowed, it
 should return a message stating what the problem is, or a function