Created
July 5, 2011 13:26
-
-
Save ilja/1064829 to your computer and use it in GitHub Desktop.
Import mediawiki stuff in gollum
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'rubygems' | |
require 'nokogiri' | |
require 'gollum' | |
wiki = Gollum::Wiki.new('auxwiki') | |
name = 'Ilja Krijger' | |
email = '[email protected]' | |
f = File.open("AuxiliumWiki-20110705103347.xml") | |
doc = Nokogiri::XML(f) | |
f.close | |
doc.css('page').each do |page| | |
title = page.at_css('title').content() | |
content = page.at_css('revision text').content() | |
commit = { :message => "Import #{title} from mediawiki", :name => name, :email => email } | |
begin | |
wiki.write_page(title, :mediawiki, content, commit) | |
rescue Gollum::DuplicatePageError => e | |
p "Duplicate #{title}" | |
rescue Encoding::CompatibilityError => e | |
p "Encoding error on #{title}" | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment