This is the historical archive of the now-inactive 'grubstreet' list.
Discussion on OpenGuides development
has now moved to OpenGuides-Dev.
Discussion on The Open Guide to
London now takes place on OpenGuides-London.
[grubstreet] Wiki hoover script
[prev] [thread] [next] [lurker] [Date index for 2003/1/1]
From: Ivor Williams
Subject: [grubstreet] Wiki hoover script
Date: 20:42 on 01 Jan 2003
Subject: [grubstreet] Wiki hoover script
Date: 20:42 on 01 Jan 2003
------=_NextPart_000_0011_01C2B1D6.4F73C4E0 Content-Type: multipart/alternative; boundary="----=_NextPart_001_0012_01C2B1D6.4F7B6600" ------=_NextPart_001_0012_01C2B1D6.4F7B6600 Content-Type: text/plain; charset="Windows-1252" Content-Transfer-Encoding: quoted-printable For those who are interested ------=_NextPart_001_0012_01C2B1D6.4F7B6600 Content-Type: text/html; charset="Windows-1252" Content-Transfer-Encoding: quoted-printable <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> <HTML><HEAD> <META http-equiv=3DContent-Type content=3D"text/html; = charset=3Dwindows-1252"> <META content=3D"MSHTML 6.00.2800.1106" name=3DGENERATOR> <STYLE></STYLE> </HEAD> <BODY bgColor=3D#ffffff> <DIV><FONT size=3D2>For those who are interested</FONT></DIV> <DIV><FONT size=3D2></FONT> </DIV> <DIV> </DIV></BODY></HTML> ------=_NextPart_001_0012_01C2B1D6.4F7B6600-- ------=_NextPart_000_0011_01C2B1D6.4F73C4E0 Content-Type: text/plain; name="wikihoover.pl" Content-Transfer-Encoding: quoted-printable Content-Disposition: attachment; filename="wikihoover.pl" #!perl=0A= =0A= use strict;=0A= use warnings;=0A= =0A= our $VERSION;=0A= =0A= my ($progname) =3D ($0 =3D~ /(\w+)(\.\w*)?$/);=0A= =0A= my $revision =3D '1.0';=0A= $VERSION =3D sprintf("%d.%02d", ($revision =3D~ /(\d+)\.(\d+)/));=0A= =0A= use LWP::UserAgent;=0A= use HTML::TokeParser;=0A= use HTTP::Request::Common qw(POST);=0A= =0A= # Simple arg list for now. May move to Getopt::Long if need to=0A= =0A= &usage if @ARGV !=3D 2;=0A= =0A= my ($wiki_from,$wiki_to) =3D @ARGV;=0A= =0A= # Set up user agent=0A= =0A= my $ua =3D new LWP::UserAgent;=0A= $ua->agent("$progname/$VERSION " . $ua->agent);=0A= $ua->env_proxy;=0A= =0A= # Set up GET request=0A= =0A= my $req =3D HTTP::Request->new('GET');=0A= $req->header('Accept' =3D> 'text/html');=0A= =0A= # Get the Wiki index page=0A= =0A= $req->url("$wiki_from?action=3Dindex");=0A= my $res =3D $ua->request($req);=0A= =0A= die "Error on index: " . $res->status_line . "\n" =0A= unless $res->is_success;=0A= =0A= # Get all the links off this page.=0A= # Ignore RecentChanges and all ?action=3Dfoo type links=0A= # Deduplicate list via hash %tocopy=0A= =0A= my $index =3D $res->content;=0A= my $indexp =3D HTML::TokeParser->new(\$index) or die "Index: bad HTML";=0A= my %tocopy;=0A= while (my $link =3D $indexp->get_tag('a')) {=0A= my ($atag,$aatt) =3D @$link;=0A= next unless $aatt->{href} =3D~ /\?([^&=3D]+)$/;=0A= my $qs =3D $1;=0A= $tocopy{$qs}++ unless $qs eq 'RecentChanges';=0A= }=0A= =0A= # Hoover each page=0A= =0A= for (keys %tocopy) {=0A= =0A= # Bring up page on source Wiki in edit mode=0A= $req->url("$wiki_from?action=3Dedit&id=3D$_");=0A= my $srcpage =3D $ua->request($req);=0A= next unless $srcpage->is_success;=0A= =0A= # Parse out the page text=0A= my $srcpc =3D $srcpage->content;=0A= my $srcp =3D HTML::TokeParser->new(\$srcpc) or (print "Problems with = $_\n"),next;=0A= my $field =3D $srcp->get_tag('textarea');=0A= my $text =3D $srcp->get_text('/textarea');=0A= =0A= # Bring up edit mode on destination Wiki to get remaining fields=0A= $req->url("$wiki_to?action=3Dedit&id=3D$_");=0A= my $edpage =3D $ua->request($req);=0A= next unless $edpage->is_success;=0A= my $edpc =3D $edpage->content;=0A= =0A= # Parse out form to get the remaining fields=0A= my $edp =3D HTML::TokeParser->new(\$edpc) or (print "Problems with = $_\n"),next;=0A= my @form;=0A= while (my $field =3D $edp->get_tag('input','textarea')) {=0A= my ($tag,$attr) =3D @$field;=0A= if ($tag eq 'textarea') {=0A= # my $text =3D $edp->get_text('/textarea');=0A= push @form,$attr->{name},$text;=0A= next;=0A= }=0A= if ($attr->{type} eq 'hidden') {=0A= push @form,$attr->{name},$attr->{value};=0A= }=0A= }=0A= =0A= # additional field values=0A= push @form,=0A= 'summary' =3D> 'Bulk Populate',=0A= 'Save' =3D> 'Save';=0A= =0A= # Do the post =0A= my $ureq =3D POST("$wiki_to",\@form);=0A= my $upd =3D $ua->request($ureq);=0A= print "Copied: $_\n";=0A= }=0A= =0A= sub usage {=0A= =0A= print STDERR <<EOF;=0A= =0A= Usage: wikihoover.pl fromsite tosite=0A= =0A= EOF=0A= =0A= exit 1;=0A= =0A= }=0A= =0A= =3Dhead1 NAME=0A= =0A= wikihoover.pl - copy a Usemod Wiki to another site=0A= =0A= =3Dhead1 SYNOPSIS=0A= =0A= wikihoover.pl fromsite tosite=0A= =0A= ------=_NextPart_000_0011_01C2B1D6.4F73C4E0-- -- grubstreet mailing list http://london.openguides.org/old-list-archives/
-
[grubstreet] Wiki hoover script
Ivor Williams 20:42 on 01 Jan 2003
Content-Type: multipart/alternative;-
Re: [grubstreet] Wiki hoover script
Kate L Pugh 17:10 on 02 Jan 2003
Good work fella!
-
Re: [grubstreet] Wiki hoover script
Kate L Pugh 17:10 on 02 Jan 2003