forked from github/kensanata.oddmuse
61 lines
1.9 KiB
Perl
Executable File
61 lines
1.9 KiB
Perl
Executable File
#!/usr/bin/perl -w
|
|
# merge-list -- merge BannedContent from two wikis
|
|
# Copyright (C) 2004 Alex Schroeder <alex@emacswiki.org>
|
|
#
|
|
# This program is free software; you can redistribute it and/or modify
|
|
# it under the terms of the GNU General Public License as published by
|
|
# the Free Software Foundation; either version 2 of the License, or
|
|
# (at your option) any later version.
|
|
#
|
|
# This program is distributed in the hope that it will be useful,
|
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
# GNU General Public License for more details.
|
|
#
|
|
# You should have received a copy of the GNU General Public License
|
|
# along with this program; if not, write to the
|
|
# Free Software Foundation, Inc.
|
|
# 59 Temple Place, Suite 330
|
|
# Boston, MA 02111-1307 USA
|
|
|
|
# $Id: merge-list,v 1.2 2004/07/09 06:40:56 as Exp $</p>'
|
|
|
|
use strict;
|
|
use LWP::UserAgent;
|
|
|
|
sub GetRaw {
|
|
my $uri = shift;
|
|
my $ua = LWP::UserAgent->new;
|
|
my $request = HTTP::Request->new('GET', $uri);
|
|
my $response = $ua->request($request);
|
|
return $response->content;
|
|
}
|
|
|
|
sub Main {
|
|
my ($source, $target, $forgiven) = map {GetRaw($_)} @ARGV;
|
|
my (%source, %target);
|
|
map {$source{$_} = 1} grep(/^[ \t]/, split(/\n/, $source));
|
|
map {$target{$_} = 1} grep(/^[ \t]/, split(/\n/, $target));
|
|
# remove all the links that are forgiven...
|
|
foreach $_ (grep(/^[ \t]/, split(/\n/, $forgiven))) {
|
|
delete $source{$_};
|
|
delete $target{$_};
|
|
}
|
|
# merge the source lines to the target lines
|
|
foreach $_ (keys %source) {
|
|
$target{$_} = 1;
|
|
}
|
|
# now produce an updated pages from all the normal lines plus the
|
|
# new target lines.
|
|
my @page = grep(/^[^ \t]|$/, split(/\n/, $target));
|
|
push(@page, "") unless $page[$#page] eq ''; # add empty line if required
|
|
push(@page, sort(keys %target));
|
|
print join("\n", @page);
|
|
}
|
|
|
|
if ($#ARGV != 2) {
|
|
die "Usage: $0 source-url target-url forgiven-url\n";
|
|
}
|
|
|
|
Main();
|