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
 | 
			
		||||
 | 
			
		||||
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. 
 | 
			
		||||
 | 
			
		||||
Draft posts and posts with duplicate post titles are ignored (for now)
 | 
			
		||||
 | 
			
		||||
== Installation
 | 
			
		||||
 | 
			
		||||
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
 | 
			
		||||
        raise "Referenced User doesn't exist! Make sure the authors are imported first." \
 | 
			
		||||
          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?, 
 | 
			
		||||
          :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
 | 
			
		||||
          
 | 
			
		||||
          comments.each do |comment|
 | 
			
		||||
            comment = comment.to_refinery
 | 
			
		||||
            comment.post = post
 | 
			
		||||
            comment.save
 | 
			
		||||
              comments.each do |comment|
 | 
			
		||||
                comment = comment.to_refinery
 | 
			
		||||
                comment.post = post
 | 
			
		||||
                comment.save
 | 
			
		||||
              end
 | 
			
		||||
            end
 | 
			
		||||
            
 | 
			
		||||
          else
 | 
			
		||||
            p "Skipping draft post"
 | 
			
		||||
          end
 | 
			
		||||
        rescue Exception => e
 | 
			
		||||
          # TODO if it's not an activerecord validation error about duplicate title then raise e
 | 
			
		||||
          p e
 | 
			
		||||
        end
 | 
			
		||||
 | 
			
		||||
        post
 | 
			
		||||
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user