diff --git a/neinomat-gpn-kategorien b/neinomat-gpn-kategorien new file mode 100755 index 0000000..328b042 --- /dev/null +++ b/neinomat-gpn-kategorien @@ -0,0 +1,33 @@ +#!/usr/bin/env ruby +$:.unshift('vendor/ruby-mediawiki/lib') +$:.unshift('vendor/htree') +require 'mediawiki/dotfile' +@wiki = MediaWiki.dotfile(nil,'entropia') + +def is_redirect?(title) + @wiki.article(title).text =~ /REDIRECT/ +end + +def check_category(title_re, category) + category_articles = @wiki.category(category).articles + missing = [] + + @wiki.allpages.delete_if { |t| t !~ title_re }.each do |title| + if !is_redirect?(title) && !category_articles.member?(title) + missing << title + end + end + + if missing.size > 0 + puts "Folgenden Artikel fehlt die Kategorie: #{category}\n" + missing.each do |t| + puts t.chomp + end + puts + end +end + +check_category(/GPN/, "GPN") +(1..5).each do |n| + check_category(/GPN#{n}/, "GPN#{n}") +end