kwiki fury! and some mailman list moderation fun...

statico on 2004-06-24T13:59:23

Wizzow!

Yesterday was Kwiki fury on CPAN. The new Kwiki has been released, and If you've installed it, you know that the Kwiki only provides a very mininmal, bare-bones wiki. Everything is a plugin, and between Brian and I there are fourteen plugins on CPAN -- with more to come. Luckily, by now most of the Kwiki core stuff has propagated:

  • Kwiki (version 0.3x)
  • Kwiki::UserName
  • Kwiki::RecentChanges
  • Kwiki::Archive::Rcs
  • Kwiki::NewPage
  • Kwiki::Icons::Gnome
  • Kwiki::UserPreferences
  • Kwiki::Revisions
  • Kwiki::Search


Kwiki::Weather, Kwiki::Autoformat and Kwiki::VimMode are also up, Kwiki::PerlMode and Kwiki::PodMode are on the way from Brian.

I am also planning on marking Text::KwikiFormatish, which uses the old (<= 0.18) CGI::Kwiki formatter, as deprecated. I shall release Text::KwikiFormat to replace it.

On the TODO list are Kwiki::RecentChanges::RSS as well as figuring out a user database system. Currently all information is stored in browser cookies. This makes it difficult for tasks like "find me all pages that have expired and notify their maintainers." (Something I'm planning on implementing...)

Anyway, I usually paste some sort of handy code, so here it is. I hate having to open up a browser to delete spam sent to our moderated Mailman mailing list. That, combined with the prowess of Andy Lester and his WWW::Mechanize module, gives me this:

#!/arch/unix/bin/perl
use strict;
use warnings;
#
# listmod - fast alternative to mailman list interface
#
# usage: listmod crew XXXXXXXX
# 

die "usage: $0 \n" unless @ARGV == 2; my ($listname, $password) = @ARGV;

use CGI qw(unescape);

use WWW::Mechanize; my $m = WWW::Mechanize->new();

use Term::ReadLine; my $term = Term::ReadLine->new($0);

# submit the form, get the cookie, go to the list admin page $m->get("https://lists.ccs.neu.edu/bin/admindb/$listname"); $m->set_visible( $password ); $m->click;

# exit if nothing to do print "There are no pending requests.\n" and exit if $m->content =~ /There are no pending requests/;

# select the first form and examine its contents $m->form_number(1); my $f = $m->current_form or die "Couldn't get first form!\n";

# get me the base form element for each email item my @items = map {m/^.+?-(.+)/} grep {m/senderbanp/} $f->param or die "Couldn't get items in first form!\n";

# iterate through items, prompt user, commit actions foreach my $item (@items) {

# show item info my $sender = unescape($item); my ($subject) = [$f->find_input("senderbanp-$item")->value_names]->[1] =~ /Subject:\s+(.+?)\s+Size:/g;

# prompt user my $choice = ''; while ( $choice !~ /^[DAX]$/ ) { print "$sender\: '$subject'\n"; $choice = uc $term->readline("Action: defer/accept/discard [dax]: "); print "\n\n"; }

# set button $m->field("senderaction-$item" => {D=>0,A=>1,X=>3}->{$choice}); }

# submit actions $m->click;



Mech check

petdance on 2004-06-24T19:25:48

If you're going to not check for errors yourself, may I suggest you add an autocheck => 1 to your Mech constructor, so it does the checking for you and dies on error?

Re:Mech check

statico on 2004-06-24T19:32:07

Sure, thanks!