lib/feed_tools/feed_item.rb in feedtools-0.2.14 vs lib/feed_tools/feed_item.rb in feedtools-0.2.15
- old
+ new
@@ -222,10 +222,13 @@
if @title.nil?
unless root_node.nil?
repair_entities = false
title_node = XPath.first(root_node, "title")
if title_node.nil?
+ title_node = XPath.first(root_node, "atom:title")
+ end
+ if title_node.nil?
title_node = XPath.first(root_node, "dc:title")
end
if title_node.nil?
title_node = XPath.first(root_node, "TITLE")
end
@@ -248,11 +251,11 @@
repair_entities = true
end
unless @title.nil?
@title = FeedTools.sanitize_html(@title, :strip)
@title = FeedTools.unescape_entities(@title) if repair_entities
- @title = FeedTools.tidy_html(@title)
+ @title = FeedTools.tidy_html(@title) unless repair_entities
end
if @title != ""
# Some blogging tools include the number of comments in a post
# in the title... this is supremely ugly, and breaks any
# applications which expect the title to be static, so we're
@@ -260,10 +263,11 @@
#
# If for some incredibly wierd reason you need the actual
# unstripped title, just use find_node("title/text()").to_s
@title = @title.strip.gsub(/\[\d*\]$/, "").strip
end
+ @title.gsub!(/>\n</, "><")
@title.gsub!(/\n/, " ")
@title.strip!
@title = nil if @title == ""
end
return @title
@@ -279,19 +283,30 @@
if @description.nil?
unless root_node.nil?
repair_entities = false
description_node = XPath.first(root_node, "content:encoded")
if description_node.nil?
+ description_node = XPath.first(root_node, "content:encoded",
+ FEED_TOOLS_NAMESPACES)
+ end
+ if description_node.nil?
+ description_node = XPath.first(root_node, "encoded")
+ end
+ if description_node.nil?
description_node = XPath.first(root_node, "content")
end
if description_node.nil?
description_node = XPath.first(root_node, "fullitem")
end
if description_node.nil?
description_node = XPath.first(root_node, "xhtml:body")
end
if description_node.nil?
+ description_node = XPath.first(root_node, "xhtml:body",
+ FEED_TOOLS_NAMESPACES)
+ end
+ if description_node.nil?
description_node = XPath.first(root_node, "body")
end
if description_node.nil?
description_node = XPath.first(root_node, "description")
end
@@ -309,21 +324,25 @@
end
if description_node.nil?
description_node = XPath.first(root_node, "ABSTRACT")
end
if description_node.nil?
+ description_node = XPath.first(root_node, "blurb")
+ end
+ if description_node.nil?
description_node = XPath.first(root_node, "info")
- @bozo = true unless description_node.nil?
end
end
if description_node.nil?
return nil
end
unless description_node.nil?
if XPath.first(description_node, "@encoding").to_s != ""
@description =
"[Embedded data objects are not currently supported.]"
+ elsif description_node.cdatas.size > 0
+ @description = description_node.cdatas.first.value
elsif XPath.first(description_node, "@type").to_s == "xhtml" ||
XPath.first(description_node, "@mode").to_s == "xhtml" ||
XPath.first(description_node, "@type").to_s == "xml" ||
XPath.first(description_node, "@mode").to_s == "xml" ||
XPath.first(description_node, "@type").to_s ==
@@ -348,11 +367,11 @@
end
unless @description.nil?
@description = FeedTools.sanitize_html(@description, :strip)
@description = FeedTools.unescape_entities(@description) if repair_entities
- @description = FeedTools.tidy_html(@description)
+ @description = FeedTools.tidy_html(@description) unless repair_entities
end
@description = @description.strip unless @description.nil?
@description = nil if @description == ""
end
@@ -531,12 +550,9 @@
end
unless image_nodes.nil?
for image_node in image_nodes
image = FeedTools::Feed::Image.new
image.url = XPath.first(image_node, "url/text()").to_s
- if image.url != ""
- self.feed.bozo = true
- end
if image.url == ""
image.url = XPath.first(image_node, "@rdf:resource").to_s
end
if image.url == "" && (image_node.name == "logo" ||
(image_node.attributes['type'] =~ /^image/) == 0)
\ No newline at end of file