soviel neue funktionen!!
This commit is contained in:
parent
dc3a040d2a
commit
70e56b824b
3 changed files with 53 additions and 0 deletions
|
@ -179,5 +179,21 @@ class WikiBot
|
|||
|
||||
return fields
|
||||
end
|
||||
|
||||
def get_category_articles(category)
|
||||
# FIXME: There seems to be no MediaWiki API? Let's scrape it up from
|
||||
# HTML for now.
|
||||
|
||||
articles = []
|
||||
|
||||
category_page = @client.get_content(@wiki + category)
|
||||
category_page.scan(/<li><a href=".*?" title="(.*?)"/) do |m|
|
||||
title = m[0]
|
||||
articles.push(title)
|
||||
end
|
||||
|
||||
return articles
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
|
|
19
mediawikibotchecker.rb
Normal file
19
mediawikibotchecker.rb
Normal file
|
@ -0,0 +1,19 @@
|
|||
require 'mediawikibot'
|
||||
|
||||
class WikiChecker < MediaWikiBot::WikiBot
|
||||
def category_checker (page, category)
|
||||
body = "== #{page} ==\n\n"
|
||||
body += "[[Category:FIXME]]\n\n"
|
||||
body += "Unter [[#{page}]] fehlen folgende Artikel aus [[:#{category}]]:\n\n"
|
||||
|
||||
projekte = get_raw(page)
|
||||
get_category_articles(category).each do |title|
|
||||
re = Regexp.new("\\\[\\\[" + title)
|
||||
if ! re.match(projekte) && title != page
|
||||
body += "* [[" + title + "]]\n"
|
||||
end
|
||||
end
|
||||
return body
|
||||
end
|
||||
end
|
||||
|
18
neinomat-projekte
Executable file
18
neinomat-projekte
Executable file
|
@ -0,0 +1,18 @@
|
|||
#!/usr/bin/env ruby
|
||||
require 'mediawikibotchecker'
|
||||
|
||||
if ARGV.size() != 2
|
||||
$stderr.print($0 + " <wiki-user> <wiki-password>\n")
|
||||
exit(1)
|
||||
end
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
|
||||
b = WikiChecker.new("http://www.entropia.de/wiki/")
|
||||
b.login(ARGV[0], ARGV[1])
|
||||
|
||||
page = "Projekte"
|
||||
category = "Category:Projekte"
|
||||
body = b.category_checker(page, category)
|
||||
|
||||
b.edit("Benutzer:Neinomat/#{page}", body, "wiki ex machina")
|
Reference in a new issue