diff --git a/lib/wordpress/page.rb b/lib/wordpress/page.rb index e4ff4d9..a1898fb 100644 --- a/lib/wordpress/page.rb +++ b/lib/wordpress/page.rb @@ -24,10 +24,10 @@ module Refinery def content_formatted # WordPress doesn't export
-Tags, so let's run a simple_format over - # the content - formatted = simple_format(content) + # the content. As we trust ourselves, no sanatize. + formatted = simple_format(content, {}, { :sanitize => false }) - # Support for SyntaxHighlighter: + # Support for SyntaxHighlighter (http://alexgorbatchev.com/SyntaxHighlighter/): # In WordPress you can (via a plugin) enclose code in [lang][/lang] # blocks, which are converted to a
-tag with a class corresponding
# to the language.
diff --git a/lib/wordpress/post.rb b/lib/wordpress/post.rb
index f21b7a2..51d5bef 100644
--- a/lib/wordpress/post.rb
+++ b/lib/wordpress/post.rb
@@ -2,7 +2,14 @@ module Refinery
module WordPress
class Post < Page
def tags
- node.xpath("category[@domain='post_tag']").collect do |tag_node|
+ # xml dump has "post_tag" for wordpress 3.1 and "tag" for 3.0
+ path = if node.xpath("category[@domain='post_tag']").count > 0
+ "category[@domain='post_tag']"
+ else
+ "category[@domain='tag']"
+ end
+
+ node.xpath(path).collect do |tag_node|
Tag.new(tag_node.text)
end
end
@@ -24,13 +31,10 @@ module Refinery
end
def to_refinery
- user = ::User.find_by_username creator
+ user = ::User.find_by_username(creator) || ::User.first
raise "Referenced User doesn't exist! Make sure the authors are imported first." \
unless user
- post = BlogPost.new
-
-
post = ::BlogPost.create! :title => title, :body => content_formatted, :draft => draft?,
:published_at => post_date, :created_at => post_date, :author => user,
:tag_list => tag_list
diff --git a/spec/lib/wordpress/dump_spec.rb b/spec/lib/wordpress/dump_spec.rb
index 371b4e9..3c11766 100644
--- a/spec/lib/wordpress/dump_spec.rb
+++ b/spec/lib/wordpress/dump_spec.rb
@@ -235,9 +235,9 @@ describe Refinery::WordPress::Dump, :type => :model do
it { BlogPost.should have(1).record }
- it "should copy the attributes from Refinery::WordPress::Page" do
+ it "should copy the attributes from Refinery::WordPress::Post" do
@post.title.should == post.title
- @post.body.should == post.content
+ @post.body.should == post.content_formatted
@post.draft.should == post.draft?
@post.published_at.should == post.post_date
@post.created_at.should == post.post_date