ugly
parent
6d05f8ef2d
commit
263f8093e6
@ -1,25 +1,45 @@
|
||||
#!/usr/bin/env ruby
|
||||
require 'mediawikibotchecker'
|
||||
$:.unshift('vendor/ruby-mediawiki/lib')
|
||||
$:.unshift('vendor/htree')
|
||||
require 'mediawiki/dotfile'
|
||||
@wiki = MediaWiki.dotfile(nil,'entropia')
|
||||
|
||||
if ARGV.size() != 2
|
||||
$stderr.print($0 + " <wiki-user> <wiki-password>\n")
|
||||
exit(1)
|
||||
def category_checker (page, category)
|
||||
body = "== #{page} ==\n\n"
|
||||
body += "[[Category:FIXME]]\n\n"
|
||||
body += "Unter [[#{page}]] fehlen folgende Artikel aus [[:#{category}]]:\n\n"
|
||||
|
||||
count = 0
|
||||
page_html = @wiki.article(page).xhtml.to_s
|
||||
@wiki.category(category).articles.each do |title|
|
||||
re = Regexp.new(Regexp.escape("title='" + CGI.escapeHTML(title)))
|
||||
if ! re.match(page_html) && title != page
|
||||
body += "* [[" + title + "]]\n"
|
||||
count += 1
|
||||
end
|
||||
end
|
||||
|
||||
body += "\n#{count} Artikel.\n"
|
||||
return body
|
||||
end
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
|
||||
def fasel (page, category)
|
||||
b = WikiChecker.new("http://entropia.de/wiki/")
|
||||
b.login(ARGV[0], ARGV[1])
|
||||
|
||||
fasel_title = "Benutzer:Neinomat/#{page}"
|
||||
|
||||
body_old = b.get_raw(fasel_title)
|
||||
body_new = b.category_checker(page, category).gsub(/\n*$/sm, "")
|
||||
body_old = @wiki.article(fasel_title).text
|
||||
body_new = category_checker(page, category).gsub(/\n*$/sm, "")
|
||||
|
||||
b.edit(fasel_title, body_new, "wiki ex machina") unless body_old == body_new
|
||||
if body_old != body_new
|
||||
a = @wiki.article(fasel_title)
|
||||
a.text = body_new
|
||||
a.submit("wiki ex machina")
|
||||
end
|
||||
end
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
|
||||
fasel("Übersicht über Vorträge", "Kategorie:Vorträge")
|
||||
fasel("Übersicht über Projekte", "Kategorie:Projekte")
|
||||
fasel("Entropia:FIXME", "Kategorie:FIXME")
|
||||
|
Reference in New Issue