]> git.netwichtig.de Git - user/henk/code/ruby/rbot.git/commitdiff
rss plugin: try to use <content:encoded> tags in feeds when possible
authorAdam James <atj@pulsewidth.org.uk>
Tue, 4 Mar 2008 16:47:25 +0000 (16:47 +0000)
committerGiuseppe Bilotta <giuseppe.bilotta@gmail.com>
Tue, 4 Mar 2008 16:59:21 +0000 (17:59 +0100)
data/rbot/plugins/rss.rb

index d1e17593ab64c445857313769b32ef850522882d..5baf43ee60eb27af4f8ef6f9dd362cd1899ec983 100644 (file)
 \r
 require 'rss'\r
 \r
+# Try to load rss/content/2.0 so we can access the data in <content:encoded> \r
+# tags.\r
+begin\r
+  require 'rss/content/2.0'\r
+rescue LoadError\r
+end\r
+\r
 module ::RSS\r
 \r
   # Make an  'unique' ID for a given item, based on appropriate bot options\r
@@ -877,8 +884,12 @@ class RSSFeedsPlugin < Plugin
       :a_href => :link_out\r
     }\r
 \r
-    if item.respond_to? :description\r
-      desc = item.description.ircify_html(desc_opt) if item.description\r
+    # We prefer content_encoded here as it tends to provide more html formatting \r
+    # for use with ircify_html.\r
+    if item.respond_to?(:content_encoded) && item.content_encoded\r
+      desc = item.content_encoded.ircify_html(desc_opt)\r
+    elsif item.respond_to?(:description) && item.description\r
+      desc = item.description.ircify_html(desc_opt)\r
     else\r
       if item.content.type == "html"\r
         desc = item.content.content.ircify_html(desc_opt)\r