Skip to content

Instantly share code, notes, and snippets.

@ilja
Created July 5, 2011 13:26
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save ilja/1064829 to your computer and use it in GitHub Desktop.
Save ilja/1064829 to your computer and use it in GitHub Desktop.
Import mediawiki stuff in gollum
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