From 5f80ac3202e61440d3a0fbcc486e13c16309d5ad Mon Sep 17 00:00:00 2001 From: "http://smcv.pseudorandom.co.uk/" Date: Sun, 18 Jan 2009 09:52:51 -0500 Subject: underlay plugin, a command-line interface for add_underlay() --- doc/plugins/contrib/underlay.mdwn | 55 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 55 insertions(+) create mode 100644 doc/plugins/contrib/underlay.mdwn (limited to 'doc/plugins') diff --git a/doc/plugins/contrib/underlay.mdwn b/doc/plugins/contrib/underlay.mdwn new file mode 100644 index 000000000..94651f1d3 --- /dev/null +++ b/doc/plugins/contrib/underlay.mdwn @@ -0,0 +1,55 @@ +[[!template id=plugin name=underlay author="[[Simon_McVittie|smcv]]"]] +[[!tag type/useful]] + +This plugin adds an `add_underlays` option to the `.setup` file. +Its value is a list of underlay directories whose content is added to the wiki. + +Multiple underlays are normally set up automatically by other plugins (for +instance, the smiley images used by [[plugins/smileys]]), but they can also be +used as a way to pull in external files that you don't want in revision control, +like photos or software releases. + +Directories in `add_underlays` should usually be absolute. If relative, they're +interpreted as relative to the parent directory of the basewiki underlay, which +is probably not particularly useful in this context. + + #!/usr/bin/perl + package IkiWiki::Plugin::underlay; + # Copyright © 2008 Simon McVittie + # Licensed under the GNU GPL, version 2, or any later version published by the + # Free Software Foundation + + use warnings; + use strict; + use IkiWiki 2.00; + + sub import { + hook(type => "getsetup", id => "underlay", call => \&getsetup); + hook(type => "checkconfig", id => "underlay", call => \&checkconfig); + } + + sub getsetup () { + return + plugin => { + safe => 0, + rebuild => undef, + }, + add_underlays => { + type => "string", + default => [], + description => "extra underlay directories to add", + advanced => 1, + safe => 0, + rebuild => 1, + }, + } + + sub checkconfig () { + return unless exists $config{add_underlays}; + + foreach my $dir (@{$config{add_underlays}}) { + add_underlay($dir); + } + } + + 1; -- cgit v1.2.3 From e98f1b246a91f499d332f2d6e42d45a88d368681 Mon Sep 17 00:00:00 2001 From: "http://smcv.pseudorandom.co.uk/" Date: Sun, 18 Jan 2009 11:40:57 -0500 Subject: fix typo, mention git branch --- doc/plugins/contrib/underlay.mdwn | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'doc/plugins') diff --git a/doc/plugins/contrib/underlay.mdwn b/doc/plugins/contrib/underlay.mdwn index 94651f1d3..72893c992 100644 --- a/doc/plugins/contrib/underlay.mdwn +++ b/doc/plugins/contrib/underlay.mdwn @@ -5,7 +5,7 @@ This plugin adds an `add_underlays` option to the `.setup` file. Its value is a list of underlay directories whose content is added to the wiki. Multiple underlays are normally set up automatically by other plugins (for -instance, the smiley images used by [[plugins/smileys]]), but they can also be +instance, the images used by the [[plugins/smiley]] plugin), but they can also be used as a way to pull in external files that you don't want in revision control, like photos or software releases. @@ -13,6 +13,9 @@ Directories in `add_underlays` should usually be absolute. If relative, they're interpreted as relative to the parent directory of the basewiki underlay, which is probably not particularly useful in this context. +Please feel free to add this plugin to ikiwiki if it seems like a good +thing to have. See the 'underlay' branch in my git repository. + #!/usr/bin/perl package IkiWiki::Plugin::underlay; # Copyright © 2008 Simon McVittie -- cgit v1.2.3 From daaf4885384568822c9a134f28cee667b6940d66 Mon Sep 17 00:00:00 2001 From: intrigeri Date: Tue, 20 Jan 2009 00:53:46 +0100 Subject: po: let's walk the last steps needed before merge! Signed-off-by: intrigeri --- doc/plugins/contrib/po.mdwn | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) (limited to 'doc/plugins') diff --git a/doc/plugins/contrib/po.mdwn b/doc/plugins/contrib/po.mdwn index edd665185..af748a8d3 100644 --- a/doc/plugins/contrib/po.mdwn +++ b/doc/plugins/contrib/po.mdwn @@ -171,3 +171,30 @@ Any thoughts on this? I've set this plugin development aside for a while. I will be back and finish it at some point in the first quarter of 2009. --[[intrigeri]] + +> Abstract: Joey, please have a look at my po and meta branches. +> +> Detailed progress report: +> +> * it seems the po branch in your repository has not been tracking my +> own po branch for two months. any config issue? +> * all the plugin's todo items have been completed, robustness tests +> done +> * I've finished the detailed security audit, and the fix for po4a +> bugs has entered upstream CVS last week +> * I've merged your new `checkcontent` hook with the `cansave` hook +> I previously introduced in my own branch; blogspam plugin updated +> accordingly +> * the rename hook changes we discussed elsewhere are also part of my +> branch +> * I've introduced two new hooks (`canremove` and `canrename`), not +> a big deal; IMHO, they extend quite logically the plugin interface +> * as highlighted on [[bugs/pagetitle_function_does_not_respect_meta_titles]], +> my `meta` branch contains a new feature that is really useful in a +> translatable wiki +> +> As a conclusion, I'm feeling that my branches are ready to be +> merged; only thing missing, I guess, are a bit of discussion and +> subsequent adjustments. +> +> --[[intrigeri]] -- cgit v1.2.3 From c154fa5d6cd1620be7b139b08040740a1bdfafbc Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Sun, 25 Jan 2009 15:42:13 -0500 Subject: comments: If comment content checks fail, store the comment (in .ikiwiki/comments_pending) for moderator review. --- IkiWiki/Plugin/comments.pm | 43 +++++++++++++++++++++++++++++++------------ IkiWiki/Plugin/editpage.pm | 5 +++-- debian/changelog | 2 ++ doc/plugins/comments.mdwn | 7 +++++++ 4 files changed, 43 insertions(+), 14 deletions(-) (limited to 'doc/plugins') diff --git a/IkiWiki/Plugin/comments.pm b/IkiWiki/Plugin/comments.pm index 6d0e45a97..4d225b90a 100644 --- a/IkiWiki/Plugin/comments.pm +++ b/IkiWiki/Plugin/comments.pm @@ -380,14 +380,7 @@ sub sessioncgi ($$) { IkiWiki::check_canedit($page, $cgi, $session); $postcomment=0; - # FIXME: rather a simplistic way to make the comments... - my $i = 0; - my $file; - my $location; - do { - $i++; - $location = "$page/$config{comments_pagename}$i"; - } while (-e "$config{srcdir}/$location._comment"); + my $location=unique_comment_location($page, $config{srcdir}); my $content = "[[!_comment format=$type\n"; @@ -470,21 +463,33 @@ sub sessioncgi ($$) { IkiWiki::checksessionexpiry($cgi, $session); $postcomment=1; - IkiWiki::check_content(content => $form->field('editcontent'), + my $ok=IkiWiki::check_content(content => $form->field('editcontent'), subject => $form->field('subject'), $config{comments_allowauthor} ? ( author => $form->field('author'), url => $form->field('url'), ) : (), page => $location, - cgi => $cgi, session => $session + cgi => $cgi, + session => $session, + nonfatal => 1, ); $postcomment=0; - - my $file = "$location._comment"; + + if (! $ok) { + my $penddir=$config{wikistatedir}."/comments_pending"; + $location=unique_comment_location($page, $penddir); + writefile("$location._comment", $penddir, $content); + print IkiWiki::misctemplate(gettext(gettext("comment stored for moderation")), + "

". + gettext("Your comment will be posted after moderator review"), + "

"); + exit; + } # FIXME: could probably do some sort of graceful retry # on error? Would require significant unwinding though + my $file = "$location._comment"; writefile($file, $config{srcdir}, $content); my $conflict; @@ -654,6 +659,20 @@ sub pagetemplate (@) { } } +sub unique_comment_location ($) { + my $page=shift; + my $dir=shift; + + my $location; + my $i = 0; + do { + $i++; + $location = "$page/$config{comments_pagename}$i"; + } while (-e "$dir/$location._comment"); + + return $location; +} + package IkiWiki::PageSpec; sub match_postcomment ($$;@) { diff --git a/IkiWiki/Plugin/editpage.pm b/IkiWiki/Plugin/editpage.pm index bba52e4fd..c206d96a4 100644 --- a/IkiWiki/Plugin/editpage.pm +++ b/IkiWiki/Plugin/editpage.pm @@ -105,11 +105,12 @@ sub check_content (@) { $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 --git a/debian/changelog b/debian/changelog index 96089c101..002ae12c1 100644 --- a/debian/changelog +++ b/debian/changelog @@ -6,6 +6,8 @@ ikiwiki (3.03) UNRELEASED; urgency=low * Remove nonstandard css. Closes: #512378 * blogspam: Fix use of blogspam_options and blogspam_server config settings. + * comments: If comment content checks fail, store the comment + (in .ikiwiki/comments_pending) for moderator review. -- Joey Hess Sun, 18 Jan 2009 14:50:57 -0500 diff --git a/doc/plugins/comments.mdwn b/doc/plugins/comments.mdwn index 72b11af64..4cee3b9ad 100644 --- a/doc/plugins/comments.mdwn +++ b/doc/plugins/comments.mdwn @@ -41,3 +41,10 @@ There are some global options for the setup file: specify a name for themselves, and the \[[!meta author]] and \[[!meta authorurl]] directives will not be overridden by the comments plugin + +## comment moderation + +If you enable the [[blogspam]] plugin, comments that appear spammy will be +held for moderation. These comments are stored in +`.ikiwiki/comments_pending/`, and can be deleted, or moved into the +wiki's srcdir to be posted. -- cgit v1.2.3 From 7a7e28c55f1ffa64eedbaf36ee1729c6bbd27762 Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Sun, 25 Jan 2009 19:04:45 -0500 Subject: add a button to prefs page for comment moderation --- IkiWiki/Plugin/comments.pm | 13 +++++++++++++ doc/plugins/comments.mdwn | 8 +++++--- doc/wikitemplates.mdwn | 2 ++ 3 files changed, 20 insertions(+), 3 deletions(-) (limited to 'doc/plugins') diff --git a/IkiWiki/Plugin/comments.pm b/IkiWiki/Plugin/comments.pm index ad5395a82..c95f77a42 100644 --- a/IkiWiki/Plugin/comments.pm +++ b/IkiWiki/Plugin/comments.pm @@ -26,6 +26,7 @@ sub import { hook(type => "htmlize", id => "_comment", call => \&htmlize); hook(type => "pagetemplate", id => "comments", call => \&pagetemplate); hook(type => "cgi", id => "comments", call => \&linkcgi); + hook(type => "formbuilder_setup", id => "comments", call => \&formbuilder_setup); IkiWiki::loadplugin("inline"); } @@ -618,6 +619,18 @@ sub commentmoderation ($$) { exit; } +sub formbuilder_setup (@) { + my %params=@_; + + my $form=$params{form}; + if ($form->title eq "preferences") { + push @{$params{buttons}}, "Comment Moderation"; + if ($form->submitted && $form->submitted eq "Comment Moderation") { + commentmoderation($params{cgi}, $params{session}); + } + } +} + sub comments_pending () { my $dir="$config{wikistatedir}/comments_pending/"; return unless -d $dir; diff --git a/doc/plugins/comments.mdwn b/doc/plugins/comments.mdwn index 4cee3b9ad..c13a6daa6 100644 --- a/doc/plugins/comments.mdwn +++ b/doc/plugins/comments.mdwn @@ -45,6 +45,8 @@ There are some global options for the setup file: ## comment moderation If you enable the [[blogspam]] plugin, comments that appear spammy will be -held for moderation. These comments are stored in -`.ikiwiki/comments_pending/`, and can be deleted, or moved into the -wiki's srcdir to be posted. +held for moderation. Wiki admins can access the comment moderation queue +via a button on their Preferences page. + +The comments are stored in `.ikiwiki/comments_pending/`, and can be +deleted, or moved into the wiki's srcdir to be posted. diff --git a/doc/wikitemplates.mdwn b/doc/wikitemplates.mdwn index dc217cd30..fc5893677 100644 --- a/doc/wikitemplates.mdwn +++ b/doc/wikitemplates.mdwn @@ -33,6 +33,8 @@ located in /usr/share/ikiwiki/templates by default. by the [[plugins/comments]] plugin. * `editcomment.tmpl` - This template is the comment post form for the [[plugins/comments]] plugin. +* `commentmoderation.tmpl` - This template is used to produce the comment + moderation form. The [[plugins/pagetemplate]] plugin can allow individual pages to use a different template than `page.tmpl`. -- cgit v1.2.3 From ff9a61b48100c66d2a212270017d7b5cae0386ac Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Sun, 25 Jan 2009 22:59:20 -0500 Subject: update --- doc/plugins/blogspam.mdwn | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'doc/plugins') diff --git a/doc/plugins/blogspam.mdwn b/doc/plugins/blogspam.mdwn index a090f9c60..28d0432b3 100644 --- a/doc/plugins/blogspam.mdwn +++ b/doc/plugins/blogspam.mdwn @@ -3,8 +3,7 @@ This plugin adds antispam support to ikiwiki, using the [blogspam.net](http://blogspam.net/) API. Both page edits and -[[comment|comments]] postings can be checked for spam. Currently, -detected spam is not saved for human review, it is just rejected. +[[comment|comments]] postings can be checked for spam. The plugin requires the [[!cpan RPC::XML]] perl module. -- cgit v1.2.3 From 51cd34afff17f27cdcdf45a1e9c4ce047a2eef80 Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Sun, 25 Jan 2009 23:02:11 -0500 Subject: update --- doc/plugins/blogspam.mdwn | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'doc/plugins') diff --git a/doc/plugins/blogspam.mdwn b/doc/plugins/blogspam.mdwn index 28d0432b3..1d152faac 100644 --- a/doc/plugins/blogspam.mdwn +++ b/doc/plugins/blogspam.mdwn @@ -3,7 +3,9 @@ This plugin adds antispam support to ikiwiki, using the [blogspam.net](http://blogspam.net/) API. Both page edits and -[[comment|comments]] postings can be checked for spam. +[[comment|comments]] postings can be checked for spam. Page edits that +appear to contain spam will be rejected; comments that look spammy will be +stored in a queue for moderation by an admin. The plugin requires the [[!cpan RPC::XML]] perl module. -- cgit v1.2.3