Skip to content

Instantly share code, notes, and snippets.

@andrew
Created April 15, 2009 15:20
Show Gist options
  • Save andrew/95838 to your computer and use it in GitHub Desktop.
Save andrew/95838 to your computer and use it in GitHub Desktop.
# import content from an exported folder of html files from jumpchart.com
# TODO login and download the zip direct from jumpchart
require 'find'
require 'hpricot'
namespace :jumpchart do
desc 'Import pages from jumpchart'
task :import => :environment do
count = 0
Find.find('/users/www/hhic/') do |f|
if File.file?(f)
h = Hpricot(open(f))
inner = h.search("//div[@id='content']")
heading = (inner/'h1').inner_html
inner.search("h1").remove
puts "Importing '#{heading}'"
Page.create(:title => heading,
:body => inner.inner_html,
:author => 'Rawnet',
:parent_id => 482630035,
:created_by_id => 4,
:updated_by_id => 4)
count += 1
end
end
puts "Finished importing #{count} pages"
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment