Created
April 15, 2009 15:20
-
-
Save andrew/95838 to your computer and use it in GitHub Desktop.
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
# 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