2005-11-23 04:24:17 -05:00
|
|
|
require 'rss/taxonomy'
|
|
|
|
require 'rss/maker/1.0'
|
|
|
|
require 'rss/maker/dublincore'
|
|
|
|
|
|
|
|
module RSS
|
|
|
|
module Maker
|
2005-11-23 04:32:22 -05:00
|
|
|
module TaxonomyTopicsModel
|
2005-11-23 04:24:17 -05:00
|
|
|
def self.append_features(klass)
|
|
|
|
super
|
|
|
|
|
2007-08-04 23:03:05 -04:00
|
|
|
klass.def_classed_element("#{RSS::TAXO_PREFIX}_topics",
|
|
|
|
"TaxonomyTopics")
|
2005-11-23 04:24:17 -05:00
|
|
|
end
|
|
|
|
|
|
|
|
def self.install_taxo_topics(klass)
|
2007-03-17 06:13:25 -04:00
|
|
|
klass.module_eval(<<-EOC, __FILE__, __LINE__ + 1)
|
2005-11-23 04:32:22 -05:00
|
|
|
class TaxonomyTopics < TaxonomyTopicsBase
|
2007-03-17 06:13:25 -04:00
|
|
|
def to_feed(feed, current)
|
2005-11-23 04:24:17 -05:00
|
|
|
if current.respond_to?(:taxo_topics)
|
2005-11-23 04:32:22 -05:00
|
|
|
topics = current.class::TaxonomyTopics.new
|
2005-11-23 04:24:17 -05:00
|
|
|
bag = topics.Bag
|
|
|
|
@resources.each do |resource|
|
|
|
|
bag.lis << RDF::Bag::Li.new(resource)
|
|
|
|
end
|
|
|
|
current.taxo_topics = topics
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
EOC
|
|
|
|
end
|
|
|
|
|
2007-08-04 23:03:05 -04:00
|
|
|
class TaxonomyTopicsBase < Base
|
2005-11-23 04:24:17 -05:00
|
|
|
attr_reader :resources
|
2007-03-17 06:13:25 -04:00
|
|
|
def_array_element("resource")
|
|
|
|
remove_method :new_resource
|
2005-11-23 04:24:17 -05:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2005-11-23 04:32:22 -05:00
|
|
|
module TaxonomyTopicModel
|
2005-11-23 04:24:17 -05:00
|
|
|
def self.append_features(klass)
|
|
|
|
super
|
|
|
|
|
2007-08-04 23:03:05 -04:00
|
|
|
class_name = "TaxonomyTopics"
|
|
|
|
klass.def_classed_elements("#{TAXO_PREFIX}_topic", "value", class_name)
|
2005-11-23 04:24:17 -05:00
|
|
|
end
|
2007-08-04 23:03:05 -04:00
|
|
|
|
2005-11-23 04:24:17 -05:00
|
|
|
def self.install_taxo_topic(klass)
|
2007-03-17 06:13:25 -04:00
|
|
|
klass.module_eval(<<-EOC, __FILE__, __LINE__ + 1)
|
2005-11-23 04:32:22 -05:00
|
|
|
class TaxonomyTopics < TaxonomyTopicsBase
|
|
|
|
class TaxonomyTopic < TaxonomyTopicBase
|
2005-11-23 04:24:17 -05:00
|
|
|
DublinCoreModel.install_dublin_core(self)
|
2005-11-23 04:32:22 -05:00
|
|
|
TaxonomyTopicsModel.install_taxo_topics(self)
|
2005-11-23 04:24:17 -05:00
|
|
|
|
2007-03-17 06:13:25 -04:00
|
|
|
def to_feed(feed, current)
|
2005-11-23 04:24:17 -05:00
|
|
|
if current.respond_to?(:taxo_topics)
|
2005-11-23 04:32:22 -05:00
|
|
|
topic = current.class::TaxonomyTopic.new(value)
|
2005-11-23 04:24:17 -05:00
|
|
|
topic.taxo_link = value
|
2007-03-17 06:13:25 -04:00
|
|
|
taxo_topics.to_feed(feed, topic) if taxo_topics
|
2005-11-23 04:24:17 -05:00
|
|
|
current.taxo_topics << topic
|
2007-03-17 06:13:25 -04:00
|
|
|
setup_other_elements(feed, topic)
|
2005-11-23 04:24:17 -05:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
EOC
|
|
|
|
end
|
|
|
|
|
2007-08-04 23:03:05 -04:00
|
|
|
class TaxonomyTopicsBase < Base
|
2007-12-02 01:45:53 -05:00
|
|
|
def_array_element("topic", nil, "TaxonomyTopic")
|
|
|
|
alias_method(:new_taxo_topic, :new_topic) # For backward compatibility
|
2005-11-23 04:24:17 -05:00
|
|
|
|
2007-08-04 23:03:05 -04:00
|
|
|
class TaxonomyTopicBase < Base
|
2005-11-23 04:24:17 -05:00
|
|
|
include DublinCoreModel
|
2005-11-23 04:32:22 -05:00
|
|
|
include TaxonomyTopicsModel
|
2009-03-05 22:56:38 -05:00
|
|
|
|
2005-11-23 04:24:17 -05:00
|
|
|
attr_accessor :value
|
|
|
|
add_need_initialize_variable("value")
|
|
|
|
alias_method(:taxo_link, :value)
|
|
|
|
alias_method(:taxo_link=, :value=)
|
2009-03-05 22:56:38 -05:00
|
|
|
|
2005-11-23 04:24:17 -05:00
|
|
|
def have_required_values?
|
|
|
|
@value
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
class RSSBase
|
2005-11-23 04:32:22 -05:00
|
|
|
include TaxonomyTopicModel
|
2005-11-23 04:24:17 -05:00
|
|
|
end
|
2009-03-05 22:56:38 -05:00
|
|
|
|
2005-11-23 04:24:17 -05:00
|
|
|
class ChannelBase
|
2005-11-23 04:32:22 -05:00
|
|
|
include TaxonomyTopicsModel
|
2005-11-23 04:24:17 -05:00
|
|
|
end
|
2009-03-05 22:56:38 -05:00
|
|
|
|
2005-11-23 04:24:17 -05:00
|
|
|
class ItemsBase
|
|
|
|
class ItemBase
|
2005-11-23 04:32:22 -05:00
|
|
|
include TaxonomyTopicsModel
|
2005-11-23 04:24:17 -05:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2007-03-17 06:13:25 -04:00
|
|
|
makers.each do |maker|
|
|
|
|
maker.module_eval(<<-EOC, __FILE__, __LINE__ + 1)
|
|
|
|
TaxonomyTopicModel.install_taxo_topic(self)
|
2005-11-23 04:24:17 -05:00
|
|
|
|
2007-03-17 06:13:25 -04:00
|
|
|
class Channel
|
2005-11-23 04:32:22 -05:00
|
|
|
TaxonomyTopicsModel.install_taxo_topics(self)
|
2005-11-23 04:24:17 -05:00
|
|
|
end
|
|
|
|
|
2007-03-17 06:13:25 -04:00
|
|
|
class Items
|
|
|
|
class Item
|
|
|
|
TaxonomyTopicsModel.install_taxo_topics(self)
|
|
|
|
end
|
2005-11-23 04:24:17 -05:00
|
|
|
end
|
2007-03-17 06:13:25 -04:00
|
|
|
EOC
|
2005-11-23 04:24:17 -05:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|