From 384bc445c2c2026e8d95d3b2afaa2d23a27c8edf Mon Sep 17 00:00:00 2001 From: neingeist Date: Fri, 14 Oct 2005 01:17:16 +0000 Subject: [PATCH] move old and add new examples --- examples/fix-links | 16 +++++++++ examples/neinomat-gpn-kats | 36 +++++++++++++++++++ .../neinomat-twiki-killer | 0 .../stadtwiki-upcoming | 0 4 files changed, 52 insertions(+) create mode 100755 examples/fix-links create mode 100755 examples/neinomat-gpn-kats rename neinomat-twiki-killer => examples/neinomat-twiki-killer (100%) rename stadtwiki-upcoming => examples/stadtwiki-upcoming (100%) diff --git a/examples/fix-links b/examples/fix-links new file mode 100755 index 0000000..1a44924 --- /dev/null +++ b/examples/fix-links @@ -0,0 +1,16 @@ +#!/usr/bin/env ruby +require '../mediawikibot' + +if ARGV.size() != 2 + $stderr.print($0 + " \n") + exit(1) +end + +#---------------------------------------------------------------------------- + +b = MediaWikiBot::WikiBot.new("http://entropia.de/wiki/") +b.login(ARGV[0], ARGV[1]) + +old = b.get_raw("RoboRally") +new = old.gsub(/\[#reg ([^|]*?)\]/i, '[[#Gesperrte Register|\1]]') +b.edit("RoboRally", new, "Kaputte interne Links repariert") diff --git a/examples/neinomat-gpn-kats b/examples/neinomat-gpn-kats new file mode 100755 index 0000000..551a7e6 --- /dev/null +++ b/examples/neinomat-gpn-kats @@ -0,0 +1,36 @@ +#!/usr/bin/env ruby +require 'mediawikibot' + +if ARGV.size() != 2 + $stderr.print($0 + " \n") + exit(1) +end + +#------------------------------------------------------------------------------ +# Rock! + +b = MediaWikiBot::WikiBot.new("http://entropia.de/wiki/") +b.login(ARGV[0], ARGV[1]) + +b.get_allpages().delete_if { |title| title !~ /GPN/ }.each do |title| + if !b.is_redirect?(title) + puts "Processing #{title}" + + if !b.is_in_category?(title, "Kategorie:GPN") + puts "* [[#{title}]] fehlt in [[Kategorie:GPN]]" + end + + if b.get_categories(title).delete_if {|c| c !~ /Kategorie:GPN\d/} .size == 0 + # Try to fix it + if title =~ /^(GPN\d)/ + cat = "[[Kategorie:#{$1}]]" + body = b.get_raw(title) + "\n#{cat}\n" + b.edit(title, body, cat) + else + puts "* [[#{title}]] keiner GPN zugeordnet" + end + end + sleep(1) + end +end + diff --git a/neinomat-twiki-killer b/examples/neinomat-twiki-killer similarity index 100% rename from neinomat-twiki-killer rename to examples/neinomat-twiki-killer diff --git a/stadtwiki-upcoming b/examples/stadtwiki-upcoming similarity index 100% rename from stadtwiki-upcoming rename to examples/stadtwiki-upcoming