From 08a815fbc319813138d8cec362298249c4ce8407 Mon Sep 17 00:00:00 2001 From: neingeist Date: Mon, 17 Apr 2006 22:34:09 +0000 Subject: [PATCH] new lib --- examples/fix-links | 14 ----------- examples/neinomat-fixme-zur-vorlage | 33 ------------------------- examples/neinomat-gpn-kats | 36 --------------------------- examples/neinomat-twiki-killer | 38 ----------------------------- 4 files changed, 121 deletions(-) delete mode 100755 examples/fix-links delete mode 100755 examples/neinomat-fixme-zur-vorlage delete mode 100755 examples/neinomat-gpn-kats delete mode 100755 examples/neinomat-twiki-killer diff --git a/examples/fix-links b/examples/fix-links deleted file mode 100755 index 8b04926..0000000 --- a/examples/fix-links +++ /dev/null @@ -1,14 +0,0 @@ -#!/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-fixme-zur-vorlage b/examples/neinomat-fixme-zur-vorlage deleted file mode 100755 index 6465ed1..0000000 --- a/examples/neinomat-fixme-zur-vorlage +++ /dev/null @@ -1,33 +0,0 @@ -#!/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_category_articles("Kategorie:FIXME").each do |title| - - # Diese Artikel ignorieren - next if title.match(/Benutzer:Neinomat/) - next if title == "Entropia:FIXME" - next if title == "Vorlage:FIXME" - - # Diese Artikel ändern - r = b.get_raw(title) - if r.match(/\[\[Kategorie:FIXME\]\]/) - r = "{{FIXME}}\n" + r.gsub(/\[\[Kategorie:FIXME\]\]\n?/, "") - b.edit(title, r, "s/Kategorie/Vorlage") - end - - # Diese Artikel enthalten FIXME, aber nicht nur als Vorlage - if r.match(/[^{]FIXME/) - puts "* [[#{title}]]\n" - end -end diff --git a/examples/neinomat-gpn-kats b/examples/neinomat-gpn-kats deleted file mode 100755 index 551a7e6..0000000 --- a/examples/neinomat-gpn-kats +++ /dev/null @@ -1,36 +0,0 @@ -#!/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/examples/neinomat-twiki-killer b/examples/neinomat-twiki-killer deleted file mode 100755 index 0c37223..0000000 --- a/examples/neinomat-twiki-killer +++ /dev/null @@ -1,38 +0,0 @@ -#!/usr/bin/env ruby -require 'mediawikibot' - -if ARGV.size() != 2 - $stderr.print($0 + " \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://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