Skip to content

Instantly share code, notes, and snippets.

Created March 10, 2011 02:41
  • Star 11 You must be signed in to star a gist
  • Fork 5 You must be signed in to fork a gist
Star You must be signed in to star a gist
What would you like to do?
Imports a MediaWiki XML export into a Gollum wiki
#!/usr/bin/env ruby
require 'rubygems'
require 'hpricot'
require 'gollum'
wiki ='')
file ="OpenAustralia-20110309232515.xml", "r")
doc = Hpricot(file)'/mediawiki/page').each do |el|
title ='title').inner_text
content ='text').inner_text
commit = { :message => "Import MediaWiki page #{title} into Gollum",
:name => 'Henare Degan',
:email => '' }
puts "Writing page #{title}"
wiki.write_page(title, :mediawiki, content, commit)
rescue Gollum::DuplicatePageError => e
p "Duplicate #{title}"
Copy link

Wonderful. Quick details how to import that into github, once you have xml export:

sudo gem install hpricot gollum

git init
cd ..
ruby mw-to-gollum.rb

Copy link

Very nice! I had to add require 'gollum-lib'

Copy link

Thanks a lot, this was a big help! Like @schmunk42, I had to require 'gollum-lib.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment