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
|
|
|
|
|
|
|
|
klass.add_need_initialize_variable("taxo_topics", "make_taxo_topics")
|
|
|
|
klass.add_other_element("taxo_topics")
|
|
|
|
klass.module_eval(<<-EOC, __FILE__, __LINE__ + 1)
|
|
|
|
attr_reader :taxo_topics
|
|
|
|
def make_taxo_topics
|
2005-11-23 04:32:22 -05:00
|
|
|
self.class::TaxonomyTopics.new(@maker)
|
2005-11-23 04:24:17 -05:00
|
|
|
end
|
|
|
|
|
|
|
|
def setup_taxo_topics(rss, current)
|
|
|
|
@taxo_topics.to_rss(rss, current)
|
|
|
|
end
|
|
|
|
EOC
|
|
|
|
end
|
|
|
|
|
|
|
|
def self.install_taxo_topics(klass)
|
|
|
|
klass.module_eval(<<-EOC, *Utils.get_file_and_line_from_caller(1))
|
2005-11-23 04:32:22 -05:00
|
|
|
class TaxonomyTopics < TaxonomyTopicsBase
|
2005-11-23 04:24:17 -05:00
|
|
|
def to_rss(rss, current)
|
|
|
|
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
|
|
|
|
|
2005-11-23 04:32:22 -05:00
|
|
|
class TaxonomyTopicsBase
|
2005-11-23 04:24:17 -05:00
|
|
|
include Base
|
|
|
|
|
|
|
|
attr_reader :resources
|
|
|
|
def_array_element("resources")
|
|
|
|
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
|
|
|
|
|
|
|
|
klass.add_need_initialize_variable("taxo_topics", "make_taxo_topics")
|
|
|
|
klass.add_other_element("taxo_topics")
|
|
|
|
klass.module_eval(<<-EOC, __FILE__, __LINE__ + 1)
|
|
|
|
attr_reader :taxo_topics
|
|
|
|
def make_taxo_topics
|
2005-11-23 04:32:22 -05:00
|
|
|
self.class::TaxonomyTopics.new(@maker)
|
2005-11-23 04:24:17 -05:00
|
|
|
end
|
|
|
|
|
|
|
|
def setup_taxo_topics(rss, current)
|
|
|
|
@taxo_topics.to_rss(rss, current)
|
|
|
|
end
|
|
|
|
|
|
|
|
def taxo_topic
|
|
|
|
@taxo_topics[0] and @taxo_topics[0].value
|
|
|
|
end
|
|
|
|
|
|
|
|
def taxo_topic=(new_value)
|
2005-11-23 04:32:22 -05:00
|
|
|
@taxo_topic[0] = self.class::TaxonomyTopic.new(self)
|
2005-11-23 04:24:17 -05:00
|
|
|
@taxo_topic[0].value = new_value
|
|
|
|
end
|
|
|
|
EOC
|
|
|
|
end
|
|
|
|
|
|
|
|
def self.install_taxo_topic(klass)
|
|
|
|
klass.module_eval(<<-EOC, *Utils.get_file_and_line_from_caller(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
|
|
|
|
|
|
|
def to_rss(rss, current)
|
|
|
|
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
|
|
|
|
taxo_topics.to_rss(rss, topic) if taxo_topics
|
|
|
|
current.taxo_topics << topic
|
|
|
|
setup_other_elements(rss)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
def current_element(rss)
|
|
|
|
super.taxo_topics.last
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
EOC
|
|
|
|
end
|
|
|
|
|
2005-11-23 04:32:22 -05:00
|
|
|
class TaxonomyTopicsBase
|
2005-11-23 04:24:17 -05:00
|
|
|
include Base
|
|
|
|
|
|
|
|
def_array_element("taxo_topics")
|
|
|
|
|
|
|
|
def new_taxo_topic
|
2005-11-23 04:32:22 -05:00
|
|
|
taxo_topic = self.class::TaxonomyTopic.new(self)
|
2005-11-23 04:24:17 -05:00
|
|
|
@taxo_topics << taxo_topic
|
|
|
|
taxo_topic
|
|
|
|
end
|
|
|
|
|
|
|
|
def to_rss(rss, current)
|
|
|
|
@taxo_topics.each do |taxo_topic|
|
|
|
|
taxo_topic.to_rss(rss, current)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2005-11-23 04:32:22 -05:00
|
|
|
class TaxonomyTopicBase
|
2005-11-23 04:24:17 -05:00
|
|
|
include Base
|
|
|
|
include DublinCoreModel
|
2005-11-23 04:32:22 -05:00
|
|
|
include TaxonomyTopicsModel
|
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=)
|
|
|
|
|
|
|
|
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
|
|
|
|
|
|
|
|
class ChannelBase
|
2005-11-23 04:32:22 -05:00
|
|
|
include TaxonomyTopicsModel
|
2005-11-23 04:24:17 -05:00
|
|
|
end
|
|
|
|
|
|
|
|
class ItemsBase
|
|
|
|
class ItemBase
|
2005-11-23 04:32:22 -05:00
|
|
|
include TaxonomyTopicsModel
|
2005-11-23 04:24:17 -05:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
class RSS10
|
2005-11-23 04:32:22 -05:00
|
|
|
TaxonomyTopicModel.install_taxo_topic(self)
|
2005-11-23 04:24:17 -05: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
|
|
|
|
|
|
|
|
class Items
|
|
|
|
class Item
|
2005-11-23 04:32:22 -05:00
|
|
|
TaxonomyTopicsModel.install_taxo_topics(self)
|
2005-11-23 04:24:17 -05:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
class RSS09
|
2005-11-23 04:32:22 -05:00
|
|
|
TaxonomyTopicModel.install_taxo_topic(self)
|
2005-11-23 04:24:17 -05: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
|
|
|
|
|
|
|
|
class Items
|
|
|
|
class Item
|
2005-11-23 04:32:22 -05:00
|
|
|
TaxonomyTopicsModel.install_taxo_topics(self)
|
2005-11-23 04:24:17 -05:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|