From 263f8093e62a45c6baf787a81766395337f3b04e Mon Sep 17 00:00:00 2001 From: neingeist Date: Mon, 17 Apr 2006 14:59:44 +0000 Subject: [PATCH] ugly --- neinomat-uebersichten | 40 ++++++++++++++++++++++++++++++---------- 1 file changed, 30 insertions(+), 10 deletions(-) diff --git a/neinomat-uebersichten b/neinomat-uebersichten index f15aab5..9de02b2 100755 --- a/neinomat-uebersichten +++ b/neinomat-uebersichten @@ -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 + " \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")