Compatibility with Wordpress 3.0
* Tags are now imported from a 3.0 dump * Authors are not imported from 3.0, as they are not part of the dump * simple_format now doesn't sanitize the content anymore
This commit is contained in:
parent
afb35f58ad
commit
4e3905fcb9
|
@ -24,10 +24,10 @@ module Refinery
|
|||
|
||||
def content_formatted
|
||||
# WordPress doesn't export <p>-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 <pre>-tag with a class corresponding
|
||||
# to the language.
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue
Block a user