neingeist
/
neinomaten
Archived
1
0
Fork 0
master
neingeist 19 years ago
parent e64bebbd8b
commit 9b2e91cb8d

@ -1,4 +1,4 @@
#!/bin/sh #!/bin/sh
./neinomat-uebersichten $* ./neinomat-uebersichten
./neinomat-radio-chaotica $* ./neinomat-radio-chaotica
./neinomat-termine $* ./neinomat-termine

@ -1,9 +1,38 @@
#!/usr/bin/env ruby #!/usr/bin/env ruby
require 'mediawikibot' $:.unshift('vendor/ruby-mediawiki/lib')
$:.unshift('vendor/htree')
require 'mediawiki/dotfile'
@wiki = MediaWiki.dotfile(nil,'entropia')
require 'date' require 'date'
#---------------------------------------------------------------------------- #----------------------------------------------------------------------------
def parse_template(title, template)
template_re = Regexp.new("\\\{\\\{" + template + "(.*?)\\\}\\\}")
fields = {}
fields_string = @wiki.article(title).text.scan(template_re)[0][0]
inlink = 0
field = ""
fields_string += "|" unless fields_string.match(/\|$/)
fields_string.split(//).each do |c|
if c == "|" && inlink == 0
(key, value) = field.split(/=/)
fields[key] = value
field = ""
else
inlink += 1 if c == "["
inlink -= 1 if c == "]"
field += c
end
end
fields
end
def datum2isodate(datum) def datum2isodate(datum)
return datum[6..9] + "-" + datum[3..4] + "-" + datum[0..1] return datum[6..9] + "-" + datum[3..4] + "-" + datum[0..1]
end end
@ -23,23 +52,12 @@ def table_termine (t)
return body return body
end end
#----------------------------------------------------------------------------
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])
#---------------------------------------------------------------------------- #----------------------------------------------------------------------------
termine = [] termine = []
template = "Vorlage:Radio Chaotica-Sendung" template = "Vorlage:Radio Chaotica-Sendung"
b.get_what_uses_template(template).each do |page| @wiki.article(template).what_links_here.each do |page|
if erste_sendung = b.parse_template(page, template)["erste_sendung"] if erste_sendung = parse_template(page, template)["erste_sendung"]
termin = {} termin = {}
termin["datum"] = erste_sendung.gsub(/\s*um\s*\d+:\d+$/,"") termin["datum"] = erste_sendung.gsub(/\s*um\s*\d+:\d+$/,"")
termin["uhrzeit"] = "16:00" termin["uhrzeit"] = "16:00"
@ -54,9 +72,9 @@ end
#---------------------------------------------------------------------------- #----------------------------------------------------------------------------
template = "Vorlage:Termin" template = "Vorlage:Termin"
b.get_what_uses_template(template).each do |page| @wiki.article(template).what_links_here.each do |page|
termin = b.parse_template(page, template) termin = parse_template(page, template)
termine.push(termin) termine.push(termin)
end end
#---------------------------------------------------------------------------- #----------------------------------------------------------------------------
@ -79,4 +97,6 @@ body += table_termine(vergangene_termine)
body += "\n== Kommende Termine ==\n" body += "\n== Kommende Termine ==\n"
body += table_termine(kommende_termine) body += table_termine(kommende_termine)
b.edit("Benutzer:Neingeist/Termine", body, "Test") a = @wiki.article("Benutzer:Neingeist/Termine")
a.text = body
a.submit("wiki ex machina")