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.
46 lines
1.3 KiB
Ruby
46 lines
1.3 KiB
Ruby
#!/usr/bin/env ruby
|
|
$:.unshift('vendor/ruby-mediawiki/lib')
|
|
$:.unshift('vendor/htree')
|
|
require 'mediawiki/dotfile'
|
|
@wiki = MediaWiki.dotfile(nil,'entropia')
|
|
|
|
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)
|
|
fasel_title = "Benutzer:Neinomat/#{page}"
|
|
|
|
body_old = @wiki.article(fasel_title).text
|
|
body_new = category_checker(page, category).gsub(/\n*$/sm, "")
|
|
|
|
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")
|