|
|
@ -1,5 +1,29 @@
|
|
|
|
#!/usr/bin/env ruby
|
|
|
|
#!/usr/bin/env ruby
|
|
|
|
require 'mediawikibot'
|
|
|
|
require 'mediawikibot'
|
|
|
|
|
|
|
|
require 'date'
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#----------------------------------------------------------------------------
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def datum2isodate(datum)
|
|
|
|
|
|
|
|
return datum[6..9] + "-" + datum[3..4] + "-" + datum[0..1]
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def table_termine (t)
|
|
|
|
|
|
|
|
body = '{| border=1 cellspacing="0" cellpadding="5" style="border-collapse:collapse;"'
|
|
|
|
|
|
|
|
body += "\n"
|
|
|
|
|
|
|
|
body += "| Datum \n| Uhrzeit \n| Ort \n| Beschreibung \n|-\n"
|
|
|
|
|
|
|
|
t.each do |termin|
|
|
|
|
|
|
|
|
body += "| " + termin["datum"].to_s + "\n"
|
|
|
|
|
|
|
|
body += "| " + termin["uhrzeit"].to_s + "\n"
|
|
|
|
|
|
|
|
body += "| " + termin["ort"].to_s + "\n"
|
|
|
|
|
|
|
|
body += "| " + termin["beschreibung"].to_s + "\n"
|
|
|
|
|
|
|
|
body += "|-\n"
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
body += "|}"
|
|
|
|
|
|
|
|
return body
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#----------------------------------------------------------------------------
|
|
|
|
|
|
|
|
|
|
|
|
if ARGV.size() != 2
|
|
|
|
if ARGV.size() != 2
|
|
|
|
$stderr.print($0 + " <wiki-user> <wiki-password>\n")
|
|
|
|
$stderr.print($0 + " <wiki-user> <wiki-password>\n")
|
|
|
@ -9,9 +33,9 @@ end
|
|
|
|
b = MediaWikiBot::WikiBot.new("http://entropia.de/wiki/")
|
|
|
|
b = MediaWikiBot::WikiBot.new("http://entropia.de/wiki/")
|
|
|
|
b.login(ARGV[0], ARGV[1])
|
|
|
|
b.login(ARGV[0], ARGV[1])
|
|
|
|
|
|
|
|
|
|
|
|
termine = []
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#----------------------------------------------------------------------------
|
|
|
|
#----------------------------------------------------------------------------
|
|
|
|
|
|
|
|
termine = []
|
|
|
|
|
|
|
|
|
|
|
|
template = "Vorlage:Radio Chaotica-Sendung"
|
|
|
|
template = "Vorlage:Radio Chaotica-Sendung"
|
|
|
|
b.get_what_uses_template(template).each do |page|
|
|
|
|
b.get_what_uses_template(template).each do |page|
|
|
|
@ -37,22 +61,22 @@ end
|
|
|
|
|
|
|
|
|
|
|
|
#----------------------------------------------------------------------------
|
|
|
|
#----------------------------------------------------------------------------
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# Get a real date
|
|
|
|
|
|
|
|
termine.each do |termin|
|
|
|
|
|
|
|
|
termin["date"] = Date.parse(datum2isodate(termin["datum"]))
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
termine = termine.sort do |x,y|
|
|
|
|
termine = termine.sort do |x,y|
|
|
|
|
def datum2isodate(datum)
|
|
|
|
x["date"] <=> y["date"]
|
|
|
|
return datum[6..9] + "-" + datum[3..4] + "-" + datum[0..1]
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
datum2isodate(x["datum"]) <=> datum2isodate(y["datum"])
|
|
|
|
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
body = '{| border=1 cellspacing="0" cellpadding="5" style="border-collapse:collapse;"'
|
|
|
|
vergangene_termine = termine.clone.delete_if { |t| t["date"] >= Date.today() }
|
|
|
|
body += "\n"
|
|
|
|
kommende_termine = termine.clone.delete_if { |t| t["date"] < Date.today() }
|
|
|
|
termine.each do |termin|
|
|
|
|
|
|
|
|
body += "| " + termin["datum"] + "\n"
|
|
|
|
body = "== Vergangene Termine ==\n"
|
|
|
|
body += "| " + termin["beschreibung"] + "\n"
|
|
|
|
body += table_termine(vergangene_termine)
|
|
|
|
body += "|-\n"
|
|
|
|
|
|
|
|
end
|
|
|
|
body += "\n== Kommende Termine ==\n"
|
|
|
|
body += "|}"
|
|
|
|
body += table_termine(kommende_termine)
|
|
|
|
|
|
|
|
|
|
|
|
#puts body
|
|
|
|
|
|
|
|
b.edit("Benutzer:Neingeist/Termine", body, "Test")
|
|
|
|
b.edit("Benutzer:Neingeist/Termine", body, "Test")
|
|
|
|