neingeist
/
neinomaten
Archived
1
0
Fork 0
You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
This repo is archived. You can view files and clone it, but cannot push or open issues/pull-requests.

64 lines
1.5 KiB
Plaintext

18 years ago
#!/usr/bin/env ruby
$:.unshift('../vendor/ruby-mediawiki/lib')
require 'mediawiki/dotfile'
@wiki = MediaWiki.dotfile(nil,'camp')
def parse_template(title, template)
template_re = Regexp.new("\\\{\\\{" + template + "(.*?)\\\}\\\}", Regexp::MULTILINE)
info = []
if (scanned = @wiki.article(title).text.scan(template_re)) != []
scanned.each do |m|
fields = {}
fields_string = m[0]
inlink = 0
field = ""
fields_string += "|" unless fields_string.match(/\|$/)
fields_string.split(//).each do |c|
if c == "|" && inlink == 0
(key, value) = field.split(/=/)
value.chomp! if value
fields[key] = value
field = ""
else
inlink += 1 if c == "["
inlink -= 1 if c == "]"
field += c
end
end
info << fields
end
else
18 years ago
$stderr.print "Template #{template} not found in #{title}!\n"
18 years ago
end
info
end
list = ""
@wiki.category("Workshop").articles.each do |article|
18 years ago
if article != "Template:Workshop" && article != "List of workshops" && article != "ExampleVille"
18 years ago
workshops = parse_template(article, "Workshop")
workshops.each do |workshop|
list += "* [[#{article}|#{workshop["what"]}]] "
18 years ago
if workshop["day"] != ""
list += "Day " + workshop["day"] + "/" + workshop["start"]
end
18 years ago
list += "\n"
end
end
end
list += "\n[[Category:Workshop]]\n"
puts list
18 years ago
a = @wiki.article("List of workshops")
a.text = list
a.submit("wiki ex machina")
18 years ago
a.protect("Automatically generated article")