move old and add new examples
This commit is contained in:
parent
9a688fc5c6
commit
384bc445c2
4 changed files with 52 additions and 0 deletions
16
examples/fix-links
Executable file
16
examples/fix-links
Executable file
|
@ -0,0 +1,16 @@
|
|||
#!/usr/bin/env ruby
|
||||
require '../mediawikibot'
|
||||
|
||||
if ARGV.size() != 2
|
||||
$stderr.print($0 + " <wiki-user> <wiki-password>\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")
|
36
examples/neinomat-gpn-kats
Executable file
36
examples/neinomat-gpn-kats
Executable file
|
@ -0,0 +1,36 @@
|
|||
#!/usr/bin/env ruby
|
||||
require 'mediawikibot'
|
||||
|
||||
if ARGV.size() != 2
|
||||
$stderr.print($0 + " <wiki-user> <wiki-password>\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
|
||||
|
38
examples/neinomat-twiki-killer
Executable file
38
examples/neinomat-twiki-killer
Executable file
|
@ -0,0 +1,38 @@
|
|||
#!/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
|
36
examples/stadtwiki-upcoming
Executable file
36
examples/stadtwiki-upcoming
Executable file
|
@ -0,0 +1,36 @@
|
|||
#!/usr/bin/env ruby
|
||||
|
||||
require 'http-access2'
|
||||
require 'mediawikibot'
|
||||
require 'vpim/icalendar'
|
||||
include Vpim
|
||||
|
||||
if ARGV.size() != 2
|
||||
$stderr.print($0 + " <wiki-user> <wiki-password>\n")
|
||||
exit(1)
|
||||
end
|
||||
|
||||
$ical_url = "webcal://upcoming.org/calendar/metro/1551"
|
||||
$web_url = "http://upcoming.org/metro/de/bawue/ka/"
|
||||
|
||||
def get_events()
|
||||
@client = HTTPAccess2::Client.new()
|
||||
ical = @client.get_content($ical_url.gsub(/^webcal:/, "http:"))
|
||||
events = []
|
||||
Icalendar.decode(ical).each do |publish|
|
||||
publish.events.each do |event|
|
||||
events.push(event)
|
||||
end
|
||||
end
|
||||
return events
|
||||
end
|
||||
|
||||
body = "Folgende Termine stammen von #{$web_url} ([#{$ical_url} iCal]):\n\n"
|
||||
get_events().each do |event|
|
||||
body += "* #{event.dtstart.mday}.#{event.dtstart.month}. #{event.summary}\n"
|
||||
end
|
||||
|
||||
b = MediaWikiBot::WikiBot.new("http://ka.stadtwiki.net/")
|
||||
b.login(ARGV[0], ARGV[1])
|
||||
|
||||
b.edit("Benutzer:Neingeist/Termine_aus_upcoming.org", body, "Import")
|
Reference in a new issue