------------------------------------------------------------
revno: 21
committer: terri <[EMAIL PROTECTED]>
branch nick: admin
timestamp: Thu 2008-05-29 17:42:42 -0700
message:
wiki-related scripts for Mailman
added:
bin/Confluence.pm
bin/convertFAQ2wiki.pl
bin/deleteUselessWikiUsers.pl
------------------------------------------------------------
revno: 20.1.1
committer: terri <[EMAIL PROTECTED]>
branch nick: mailman-administrivia
timestamp: Thu 2008-05-29 17:38:43 -0700
message:
Assorted wiki-related scripts for mailman:
* convertFAQ2wiki.pl and Confluence.pm are used for converting wiki
entries from the old FAQ Wizard format to the wiki.
* deleteUselessWikiUsers.pl removes wiki users who have not made any
contributions to the wiki (for removing spambot accounts)
added:
bin/Confluence.pm
bin/convertFAQ2wiki.pl
bin/deleteUselessWikiUsers.pl
=== added file 'bin/Confluence.pm'
--- a/bin/Confluence.pm 1970-01-01 00:00:00 +0000
+++ b/bin/Confluence.pm 2008-05-30 00:38:43 +0000
@@ -0,0 +1,66 @@
+package HTML::WikiConverter::Confluence;
+use base 'HTML::WikiConverter';
+
+use warnings;
+use strict;
+
+=head1 NAME
+
+HTML::WikiConverter::Confluence - Convert HTML to Confluence markup
+
+=head1 SYNOPSIS
+
+ use HTML::WikiConverter;
+ my $wc = new HTML::WikiConverter( dialect => 'Confluence' );
+ print $wc->html2wiki( $html );
+
+=head1 DESCRIPTION
+
+This module contains rules for converting HTML into Confluence
+markup. See L<HTML::WikiConverter> for additional usage details.
+
+=cut
+
+sub rules { {
+ b => { start => '*', end => '*' },
+ i => { start => '_', end => '_' },
+ strong => { alias => 'b' },
+ em => { alias => 'i' },
+ hr => { replace => "\n----\n" },
+
+ h1 => { start => 'h1. ', end=>"\n", line_format=>'single' },
+ h2 => { start => 'h2. ', end=>"\n", line_format=>'single' },
+ h3 => { start => 'h3. ', end=>"\n", line_format=>'single' },
+ h4 => { start => 'h4. ', end=>"\n", line_format=>'single' },
+
+ a => { replace => \&_link },
+
+ #pre => { start=> '{{', end=>'}}', block=>1, trim=>'both' },
+ pre => { start=> '{noformat}', end=>'{noformat}', block=>1 },
+ p => { block => 1, trim => 'both', line_format => 'single' },
+
+
+} }
+
+# Taken from the HTML::WikiConverter::MediaWiki with minor alterations
+sub _link {
+ my( $self, $node, $rules ) = @_;
+ my $url = defined $node->attr('href') ? $node->attr('href') : '';
+ my $text = $self->get_elem_contents($node);
+ if (defined $node->attr('name') || $url =~ "mailto:") { return $text; }
+
+ # Handle internal links
+ if( my $title = $self->get_wiki_page( $url ) ) {
+ $title =~ s/_/ /g;
+ return "[[$title]]" if $text eq $title; # no difference between
link text and page title
+ return "[[$text]]" if $text eq lcfirst $title; # differ by 1st char.
capitalization
+ return "[[$title|$text]]"; # completely different
+ }
+
+ # Treat them as external links
+ return $url if $url eq $text;
+ return "[$url]";
+ #return "[$url $text]";
+}
+
+1;
=== added file 'bin/convertFAQ2wiki.pl'
--- a/bin/convertFAQ2wiki.pl 1970-01-01 00:00:00 +0000
+++ b/bin/convertFAQ2wiki.pl 2008-05-30 00:38:43 +0000
@@ -0,0 +1,92 @@
+#!/usr/bin/perl -w
+
+# Author: Terri Oda <terri (at) zone12.com>
+# Date: May 27, 2008
+#
+# This is the slightly hacky script I used to convert the Mailman FAQ
+# from the FAQ Wizard to the wiki. It requires Confluence.pm, the converter
+# I made for the Confluence wiki format, and a local copy of the full FAQ
+# named faqw-mm.py.html (you can convert it to use the live copy, but I
+# didn't.)
+#
+# I'm checking this in as non-executable to further discourage anyone from
+# accidentally running it, as it could make a mess of the wiki.
+
+use WWW::Mechanize;
+use HTML::WikiConverter;
+use Confluence;
+use strict;
+use Switch;
+
+my $wc = new HTML::WikiConverter( dialect => 'Confluence' );
+open FAQ_FH, "faqw-mm.py.html" or die "Cannot open file\n";
+
+# Snip off the stuff at the top of the file
+while (not <FAQ_FH> =~ /<H1>1. Introduction: What is GNU Mailman\?<\/H1>/) {
+}
+
+#log in to the Mailman Wiki
+my $login = 'yourusernamehere';
+my $password = 'yourpasswordhere';
+my $login_url = 'http://wiki.list.org/login.action';
+
+my $mech = WWW::Mechanize->new();
+ $mech->get($login_url);
+ $mech->submit_form(
+ form_number => 2,
+ fields => { os_password => $password, os_username => $login},
+ );
+die unless ($mech->success());
+
+my $section = 1;
+my $base_url =
'http://wiki.list.org/pages/createpage.action?spaceKey=DOC&fromPageId=';
+my $from_page = "4030483";
+
+
+my @entry = ();
+my $title = "";
+while (my $line = <FAQ_FH>) {
+ $line =~ s/^.*Edit this entry<\/A> \///;
+ $line =~ s/^.*Log info<\/A>//;
+ $line =~ s/^\/ (Last changed on .*)/_$1_/;
+ $line =~ s/<HR>//;
+ if ($line =~ /^<H1>/) {
+ ++$section;
+ switch ($section) {
+ case 2 { $from_page = "4030484"; }
+ case 3 { $from_page = "4030487"; }
+ case 4 { $from_page = "4030488"; }
+ case 5 { $from_page = "4030489"; }
+ case 6 { $from_page = "4030490"; }
+ }
+ }
+ if ($line =~ /^<H2>/) {
+ if (not $title eq "" and not $title =~ /DELETED/i and not
$title =~ /Moved.* see FAQ/i) {
+ print "\n\n$base_url$from_page\n";
+
+ $title =~ s/"/"/g;
+ $title =~ s/&/&/g;
+ $title =~ s/[:@\/\\|#;{}<>\[\]]/-/g;
+ print $title;
+
+ my $text = $wc->html2wiki( join("", @entry) );
+ $text .= "\n{color:darkgreen}Converted from the Mailman
FAQ Wizard{color}\n";
+ $text .= "\nThis is one of many [Frequently Asked
Questions].\n";
+ print $text;
+
+ $mech->get("$base_url$from_page");
+ my $form = $mech->form_number(2);
+ my @names = $form->param;
+ $mech->submit_form(
+ form_name => "createpageform",
+ fields => {'title' => $title, 'content' =>
$text},
+ );
+
+ }
+ @entry = ();
+ $title = $line;
+ $title =~ s/<H2><A NAME[^>]*>.*\. (.*)<\/A><\/H2>/$1/;
+ }
+
+ push @entry, $line;
+}
=== added file 'bin/deleteUselessWikiUsers.pl'
--- a/bin/deleteUselessWikiUsers.pl 1970-01-01 00:00:00 +0000
+++ b/bin/deleteUselessWikiUsers.pl 2008-05-30 00:38:43 +0000
@@ -0,0 +1,60 @@
+#!/usr/bin/perl -w
+
+# Author: Terri Oda <terri (at) zone12.com>
+# Date: May 27, 2008
+#
+# This script deletes any wiki users who have never posted any content to
+# the Mailman wiki. I used this as a heuristic for getting rid of the (very
+# many) spam accounts we had signed up. We went from over 500 users to 42.
+#
+# The downside to this is that any legit users who had signed up but never
+# posted anything also got deleted, but they can remake their accounts later.
+#
+# It relies on the fact that the Confluence wiki software shows a very
+# different page if the user has produced some content.
+#
+# It also relies on you to provide an admin account (which can see these pages)
+# and outputs a list of all the users as it finds them.
+
+use WWW::Mechanize;
+use strict;
+
+# Log in to the Mailman Wiki
+my $login = 'yourusernamehere';
+my $password = 'yourusernamehere';
+my $login_url = 'http://wiki.list.org/login.action';
+
+my $mech = WWW::Mechanize->new();
+ $mech->get($login_url);
+ $mech->submit_form(
+ form_number => 2,
+ fields => { os_password => $password, os_username => $login},
+ );
+die unless ($mech->success());
+
+# Get the list of users
+my $url =
'http://wiki.list.org/admin/users/showallusers.action?usernameTerm=*&fullnameTerm=&emailTerm=&startIndex=';
+my $startIndex = 0;
+my @users = ();
+
+while ($mech->get("$url$startIndex") and not $mech->title() =~ /Oops/) {
+ my $link = "";
+ my @links = $mech->find_all_links( url_regex => qr/viewuser\.action/ );
+ foreach $link (@links) {
+ $link = $link->url();
+ $link =~ s/viewuser\.action\?username=(.*)/$1/;
+ push @users, $link;
+ print $link . "\n";
+ }
+ $startIndex += 10;
+}
+
+# Visit the delete page for each user, and delete if the removal form
+# is showing.
+my $user = "";
+foreach $user (@users) {
+
$mech->get("http://wiki.list.org/admin/users/removeuser.action?username=$user");
+ if (defined $mech->form_name("removeuserform")) {
+ $mech->submit();
+ }
+}
--
https://code.launchpad.net/~mailman-administrivia/mailman-administrivia/admin
You are receiving this branch notification because you are subscribed to it.
_______________________________________________
Mailman-checkins mailing list
[email protected]
Unsubscribe:
http://mail.python.org/mailman/options/mailman-checkins/archive%40jab.org