2004-01-28 06:46:13 +03:00
|
|
|
require "rss/1.0"
|
2005-11-17 11:56:03 +03:00
|
|
|
require "rss/dublincore"
|
2004-01-28 06:46:13 +03:00
|
|
|
|
|
|
|
module RSS
|
|
|
|
|
2004-10-16 08:51:15 +04:00
|
|
|
TAXO_PREFIX = "taxo"
|
2005-11-17 11:56:03 +03:00
|
|
|
TAXO_URI = "http://purl.org/rss/1.0/modules/taxonomy/"
|
2004-01-28 06:46:13 +03:00
|
|
|
|
2005-11-17 11:56:03 +03:00
|
|
|
RDF.install_ns(TAXO_PREFIX, TAXO_URI)
|
2004-01-28 06:46:13 +03:00
|
|
|
|
2004-10-16 08:51:15 +04:00
|
|
|
TAXO_ELEMENTS = []
|
2004-01-28 06:46:13 +03:00
|
|
|
|
2005-04-05 11:03:43 +04:00
|
|
|
%w(link).each do |name|
|
|
|
|
full_name = "#{TAXO_PREFIX}_#{name}"
|
2007-03-17 13:13:25 +03:00
|
|
|
BaseListener.install_get_text_element(TAXO_URI, name, full_name)
|
2005-11-17 11:56:03 +03:00
|
|
|
TAXO_ELEMENTS << "#{TAXO_PREFIX}_#{name}"
|
|
|
|
end
|
|
|
|
|
|
|
|
%w(topic topics).each do |name|
|
|
|
|
class_name = Utils.to_class_name(name)
|
2005-11-23 12:32:22 +03:00
|
|
|
BaseListener.install_class_name(TAXO_URI, name, "Taxonomy#{class_name}")
|
2005-04-05 11:03:43 +04:00
|
|
|
TAXO_ELEMENTS << "#{TAXO_PREFIX}_#{name}"
|
2004-10-16 08:51:15 +04:00
|
|
|
end
|
2005-11-17 11:56:03 +03:00
|
|
|
|
2005-11-23 12:32:22 +03:00
|
|
|
module TaxonomyTopicsModel
|
2005-11-17 11:56:03 +03:00
|
|
|
extend BaseModel
|
2009-03-06 06:56:38 +03:00
|
|
|
|
2005-11-17 11:56:03 +03:00
|
|
|
def self.append_features(klass)
|
|
|
|
super
|
|
|
|
|
2007-03-17 13:13:25 +03:00
|
|
|
klass.install_must_call_validator(TAXO_PREFIX, TAXO_URI)
|
|
|
|
%w(topics).each do |name|
|
|
|
|
klass.install_have_child_element(name, TAXO_URI, "?",
|
|
|
|
"#{TAXO_PREFIX}_#{name}")
|
2005-11-17 11:56:03 +03:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2005-11-23 12:32:22 +03:00
|
|
|
class TaxonomyTopics < Element
|
2005-11-17 11:56:03 +03:00
|
|
|
include RSS10
|
2009-03-06 06:56:38 +03:00
|
|
|
|
2005-11-17 11:56:03 +03:00
|
|
|
Bag = ::RSS::RDF::Bag
|
|
|
|
|
|
|
|
class << self
|
|
|
|
def required_prefix
|
|
|
|
TAXO_PREFIX
|
|
|
|
end
|
2009-03-06 06:56:38 +03:00
|
|
|
|
2005-11-17 11:56:03 +03:00
|
|
|
def required_uri
|
|
|
|
TAXO_URI
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
@tag_name = "topics"
|
2009-03-06 06:56:38 +03:00
|
|
|
|
2007-03-17 13:13:25 +03:00
|
|
|
install_have_child_element("Bag", RDF::URI, nil)
|
|
|
|
install_must_call_validator('rdf', RDF::URI)
|
2005-11-17 11:56:03 +03:00
|
|
|
|
2007-03-17 13:13:25 +03:00
|
|
|
def initialize(*args)
|
|
|
|
if Utils.element_initialize_arguments?(args)
|
|
|
|
super
|
|
|
|
else
|
|
|
|
super()
|
|
|
|
self.Bag = args[0]
|
|
|
|
end
|
|
|
|
self.Bag ||= Bag.new
|
2005-11-17 11:56:03 +03:00
|
|
|
end
|
|
|
|
|
|
|
|
def full_name
|
|
|
|
tag_name_with_prefix(TAXO_PREFIX)
|
|
|
|
end
|
2005-11-23 12:24:17 +03:00
|
|
|
|
|
|
|
def maker_target(target)
|
|
|
|
target.taxo_topics
|
|
|
|
end
|
2005-11-17 11:56:03 +03:00
|
|
|
|
2005-11-17 12:01:22 +03:00
|
|
|
def resources
|
|
|
|
if @Bag
|
|
|
|
@Bag.lis.collect do |li|
|
|
|
|
li.resource
|
|
|
|
end
|
|
|
|
else
|
|
|
|
[]
|
|
|
|
end
|
|
|
|
end
|
2005-11-17 11:56:03 +03:00
|
|
|
end
|
2004-10-16 08:51:15 +04:00
|
|
|
end
|
2009-03-06 06:56:38 +03:00
|
|
|
|
2005-11-23 12:32:22 +03:00
|
|
|
module TaxonomyTopicModel
|
2005-11-17 11:56:03 +03:00
|
|
|
extend BaseModel
|
2009-03-06 06:56:38 +03:00
|
|
|
|
2005-11-17 11:56:03 +03:00
|
|
|
def self.append_features(klass)
|
|
|
|
super
|
|
|
|
var_name = "#{TAXO_PREFIX}_topic"
|
2007-03-17 13:13:25 +03:00
|
|
|
klass.install_have_children_element("topic", TAXO_URI, "*", var_name)
|
2005-11-17 11:56:03 +03:00
|
|
|
end
|
|
|
|
|
2005-11-23 12:32:22 +03:00
|
|
|
class TaxonomyTopic < Element
|
2005-11-17 11:56:03 +03:00
|
|
|
include RSS10
|
|
|
|
|
|
|
|
include DublinCoreModel
|
2005-11-23 12:32:22 +03:00
|
|
|
include TaxonomyTopicsModel
|
2009-03-06 06:56:38 +03:00
|
|
|
|
2005-11-17 11:56:03 +03:00
|
|
|
class << self
|
|
|
|
def required_prefix
|
|
|
|
TAXO_PREFIX
|
|
|
|
end
|
2009-03-06 06:56:38 +03:00
|
|
|
|
2005-11-17 11:56:03 +03:00
|
|
|
def required_uri
|
|
|
|
TAXO_URI
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
@tag_name = "topic"
|
|
|
|
|
2007-03-17 13:13:25 +03:00
|
|
|
install_get_attribute("about", ::RSS::RDF::URI, true, nil, nil,
|
|
|
|
"#{RDF::PREFIX}:about")
|
|
|
|
install_text_element("link", TAXO_URI, "?", "#{TAXO_PREFIX}_link")
|
2009-03-06 06:56:38 +03:00
|
|
|
|
2007-03-17 13:13:25 +03:00
|
|
|
def initialize(*args)
|
|
|
|
if Utils.element_initialize_arguments?(args)
|
|
|
|
super
|
|
|
|
else
|
|
|
|
super()
|
|
|
|
self.about = args[0]
|
|
|
|
end
|
2005-11-17 11:56:03 +03:00
|
|
|
end
|
|
|
|
|
|
|
|
def full_name
|
|
|
|
tag_name_with_prefix(TAXO_PREFIX)
|
|
|
|
end
|
|
|
|
|
2005-11-23 12:24:17 +03:00
|
|
|
def maker_target(target)
|
|
|
|
target.new_taxo_topic
|
|
|
|
end
|
2005-11-17 11:56:03 +03:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
class RDF
|
2005-11-23 12:32:22 +03:00
|
|
|
include TaxonomyTopicModel
|
2005-11-17 11:56:03 +03:00
|
|
|
class Channel
|
2005-11-23 12:32:22 +03:00
|
|
|
include TaxonomyTopicsModel
|
2005-11-17 11:56:03 +03:00
|
|
|
end
|
2005-11-23 12:32:22 +03:00
|
|
|
class Item; include TaxonomyTopicsModel; end
|
2005-11-17 11:56:03 +03:00
|
|
|
end
|
2004-01-28 06:46:13 +03:00
|
|
|
end
|