Skip to content

Instantly share code, notes, and snippets.

@veganstraightedge
Forked from ilja/convert.rb
Created May 9, 2013 19:14
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save veganstraightedge/5549789 to your computer and use it in GitHub Desktop.
Save veganstraightedge/5549789 to your computer and use it in GitHub Desktop.
require 'rubygems'
require 'nokogiri'
require 'gollum'
wiki = Gollum::Wiki.new('auxwiki')
name = 'Ilja Krijger'
email = 'ilja@quittheprogram.org'
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