neingeist
/
neinomaten
Archived
1
0
Fork 0
You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
This repo is archived. You can view files and clone it, but cannot push or open issues/pull-requests.

39 lines
1.0 KiB
Ruby

#!/usr/bin/env ruby
require 'mediawikibot'
if ARGV.size() != 2
$stderr.print($0 + " <wiki-user> <wiki-password>\n")
exit(1)
end
#------------------------------------------------------------------------------
# TWiki stuff: specific things for our dirty wiki
$twiki_re = /^(Main|Termine|Wir) /
def is_twiki_link? (title)
return title =~ $twiki_re
end
#------------------------------------------------------------------------------
# Rock!
b = MediaWikiBot::WikiBot.new("http://www.entropia.de/wiki/")
b.login(ARGV[0], ARGV[1])
allpages = b.get_allpages()
allpages.each do |title|
$stderr.print("Processing '", title, "'\n")
if is_twiki_link?(title) && b.is_redirect?(title)
if b.is_not_linked?(title)
b.delete(title,
"Old TWiki topic redirect and not linked anywhere in this wiki.")
else
b.get_what_links_here(title).each do |replace_where|
b.replace(replace_where, title, get_redirect(title),
"Old TWiki topic redirect, now fixed.")
end
end
end
end