Merge branch 'master' of git://github.com/SustainableWebsites/refinerycms-wordpress-import

This commit is contained in:
Marc Remolt 2011-06-03 10:36:53 +02:00
commit e367498ef0
2 changed files with 31 additions and 14 deletions

View File

@ -1,9 +1,11 @@
= Refinerycms-wordpress-import = Refinerycms-wordpress-import
This project ist an importer for WordPress XML dumps into refinerycms(-blog). This project is an importer for WordPress XML dumps into refinerycms(-blog).
So far, only blog-relevant data gets imported, I'm working on the cms pages part. So far, only blog-relevant data gets imported, I'm working on the cms pages part.
Draft posts and posts with duplicate post titles are ignored (for now)
== Installation == Installation
As there is no official release out yet, just add this repos to your projects Gemfile: As there is no official release out yet, just add this repos to your projects Gemfile:

View File

@ -35,20 +35,35 @@ module Refinery
raise "Referenced User doesn't exist! Make sure the authors are imported first." \ raise "Referenced User doesn't exist! Make sure the authors are imported first." \
unless user unless user
post = ::BlogPost.create! :title => title, :body => content_formatted, :draft => draft?, begin
:published_at => post_date, :created_at => post_date, :author => user, is_draft = draft? ? "true" : "false"
:tag_list => tag_list if !draft?
p "creating post " + title + " Draft status: " + is_draft
post = ::BlogPost.create! :title => title,
:body => content_formatted,
:draft => draft?,
:published_at => post_date,
:created_at => post_date,
:author => user,
:tag_list => tag_list
::BlogPost.transaction do
categories.each do |category|
post.categories << category.to_refinery
end
::BlogPost.transaction do comments.each do |comment|
categories.each do |category| comment = comment.to_refinery
post.categories << category.to_refinery comment.post = post
end comment.save
end
end
comments.each do |comment| else
comment = comment.to_refinery p "Skipping draft post"
comment.post = post
comment.save
end end
rescue Exception => e
# TODO if it's not an activerecord validation error about duplicate title then raise e
p e
end end
post post