Merge branch 'master' of git://github.com/SustainableWebsites/refinerycms-wordpress-import
This commit is contained in:
commit
e367498ef0
|
@ -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:
|
||||||
|
|
|
@ -34,21 +34,36 @@ module Refinery
|
||||||
user = ::User.find_by_username(creator) || ::User.first
|
user = ::User.find_by_username(creator) || ::User.first
|
||||||
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
|
||||||
|
|
||||||
|
begin
|
||||||
|
is_draft = draft? ? "true" : "false"
|
||||||
|
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
|
||||||
|
|
||||||
post = ::BlogPost.create! :title => title, :body => content_formatted, :draft => draft?,
|
comments.each do |comment|
|
||||||
:published_at => post_date, :created_at => post_date, :author => user,
|
comment = comment.to_refinery
|
||||||
:tag_list => tag_list
|
comment.post = post
|
||||||
|
comment.save
|
||||||
::BlogPost.transaction do
|
end
|
||||||
categories.each do |category|
|
end
|
||||||
post.categories << category.to_refinery
|
|
||||||
end
|
else
|
||||||
|
p "Skipping draft post"
|
||||||
comments.each do |comment|
|
|
||||||
comment = comment.to_refinery
|
|
||||||
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
|
||||||
|
|
Loading…
Reference in New Issue
Block a user