+#-- vim:sw=2:et\r
+#++\r
+#\r
+# :title: RSS feed plugin for rbot\r
+#\r
+# Author:: Stanislav Karchebny <berkus@madfire.net>\r
+# Author:: Ian Monroe <ian@monroe.nu>\r
+# Author:: Mark Kretschmann <markey@web.de>\r
+# Author:: Giuseppe Bilotta <giuseppe.bilotta@gmail.com>\r
+#\r
+# Copyright:: (C) 2004 Stanislav Karchebny\r
+# Copyright:: (C) 2005 Ian Monroe, Mark Kretschmann\r
+# Copyright:: (C) 2006-2007 Giuseppe Bilotta\r
+#\r
+# License:: MIT license\r
+\r
+require 'rss'\r
+\r
+module ::RSS\r
+\r
+ # Make an 'unique' ID for a given item, based on appropriate bot options\r
+ # Currently only suppored is bot.config['rss.show_updated']: when true, the\r
+ # description is included in the uid hashing, otherwise it's not\r
+ #\r
+ def RSS.item_uid_for_bot(item, opts={})\r
+ options = { :show_updated => true}.merge(opts)\r
+ desc = options[:show_updated] ? item.description : nil\r
+ [item.title, item.link, desc].hash\r
+ end\r
+\r
+ # Add support for Slashdot namespace in RDF. The code is just an adaptation\r
+ # of the DublinCore code.\r
+ unless defined?(SLASH_PREFIX)\r
+ SLASH_PREFIX = 'slash'\r
+ SLASH_URI = "http://purl.org/rss/1.0/modules/slash/"\r
+\r
+ RDF.install_ns(SLASH_PREFIX, SLASH_URI)\r
+\r
+ module BaseSlashModel\r
+ def append_features(klass)\r
+ super\r
+\r
+ return if klass.instance_of?(Module)\r
+ SlashModel::ELEMENT_NAME_INFOS.each do |name, plural_name|\r
+ plural = plural_name || "#{name}s"\r
+ full_name = "#{SLASH_PREFIX}_#{name}"\r
+ full_plural_name = "#{SLASH_PREFIX}_#{plural}"\r
+ klass_name = "Slash#{Utils.to_class_name(name)}"\r
+\r
+ # This will fail with older version of the Ruby RSS module\r
+ begin\r
+ klass.install_have_children_element(name, SLASH_URI, "*",\r
+ full_name, full_plural_name)\r
+ klass.install_must_call_validator(SLASH_PREFIX, SLASH_URI)\r
+ rescue ArgumentError\r
+ klass.module_eval("install_have_children_element(#{full_name.dump}, #{full_plural_name.dump})")\r
+ end\r