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.

48 lines
1.4 KiB
Ruby

#!/usr/bin/env ruby
$:.unshift('vendor/ruby-mediawiki/lib')
require 'mediawiki/dotfile'
@wiki = MediaWiki.dotfile(nil,'entropia')
@putwhere = "Benutzer:Neinomat/"
def link_to (title)
if /^(Category|Kategorie):/.match(title)
link = "[[:" + title + "]]"
else
link = "[[" + title + "]]"
end
link
end
def check_page_against_category (page, category)
body = "== #{page} ==\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|
# mjaammm...
re = Regexp.new("(" + Regexp.escape("title=") + "(\"|')" +
Regexp.escape(CGI.escapeHTML(title)) + "(\"|')" +
"|>" + Regexp.escape(title) + "<)")
if ! re.match(page_html) && title != page && title.to_s !~ /#{@putwhere}/
body += "* " + link_to(title) + "\n"
count += 1
end
end
body += "\n#{count} Artikel.\n"
if count > 0
body += "[[Category:FIXME]]\n\n"
end
a = @wiki.article(@putwhere + page)
a.text = body
a.submit("wiki ex machina")
end
#----------------------------------------------------------------------------
check_page_against_category("Übersicht über Vorträge", "Kategorie:Vorträge")
check_page_against_category("Übersicht über Projekte", "Kategorie:Projekte")
check_page_against_category("Entropia:FIXME", "Kategorie:FIXME")