2004-01-28 06:46:13 +03:00
|
|
|
require "rss/0.9"
|
|
|
|
|
|
|
|
module RSS
|
|
|
|
|
|
|
|
class Rss
|
|
|
|
|
|
|
|
class Channel
|
|
|
|
|
|
|
|
%w(generator ttl).each do |x|
|
|
|
|
install_text_element(x)
|
2004-07-06 21:43:05 +04:00
|
|
|
install_model(x, '?')
|
2004-01-28 06:46:13 +03:00
|
|
|
end
|
|
|
|
|
|
|
|
%w(category).each do |x|
|
|
|
|
install_have_child_element(x)
|
2004-07-06 21:43:05 +04:00
|
|
|
install_model(x, '?')
|
2004-01-28 06:46:13 +03:00
|
|
|
end
|
|
|
|
|
|
|
|
[
|
|
|
|
["image", "?"],
|
2004-07-06 21:43:05 +04:00
|
|
|
["language", "?"],
|
2004-01-28 06:46:13 +03:00
|
|
|
].each do |x, occurs|
|
|
|
|
install_model(x, occurs)
|
|
|
|
end
|
|
|
|
|
2004-10-16 08:39:58 +04:00
|
|
|
def other_element(convert, indent)
|
2004-01-28 06:46:13 +03:00
|
|
|
rv = <<-EOT
|
2004-10-16 08:39:58 +04:00
|
|
|
#{category_element(convert, indent)}
|
|
|
|
#{generator_element(convert, indent)}
|
|
|
|
#{ttl_element(convert, indent)}
|
2004-01-28 06:46:13 +03:00
|
|
|
EOT
|
|
|
|
rv << super
|
|
|
|
end
|
2004-07-06 21:43:05 +04:00
|
|
|
|
|
|
|
private
|
|
|
|
alias children09 children
|
|
|
|
def children
|
|
|
|
children09 + [@category].compact
|
|
|
|
end
|
|
|
|
|
|
|
|
alias _tags09 _tags
|
|
|
|
def _tags
|
|
|
|
%w(generator ttl category).delete_if do |x|
|
|
|
|
send(x).nil?
|
|
|
|
end.collect do |elem|
|
|
|
|
[nil, elem]
|
|
|
|
end + _tags09
|
|
|
|
end
|
2004-01-28 06:46:13 +03:00
|
|
|
|
|
|
|
Category = Item::Category
|
|
|
|
|
|
|
|
class Item
|
|
|
|
|
2004-07-06 21:43:05 +04:00
|
|
|
[
|
|
|
|
["comments", "?"],
|
|
|
|
["author", "?"],
|
|
|
|
].each do |x, occurs|
|
|
|
|
install_text_element(x)
|
|
|
|
install_model(x, occurs)
|
|
|
|
end
|
2004-01-28 06:46:13 +03:00
|
|
|
|
|
|
|
[
|
|
|
|
["pubDate", '?'],
|
|
|
|
].each do |x, occurs|
|
|
|
|
install_date_element(x, 'rfc822')
|
|
|
|
install_model(x, occurs)
|
|
|
|
end
|
|
|
|
|
|
|
|
[
|
|
|
|
["guid", '?'],
|
|
|
|
].each do |x, occurs|
|
|
|
|
install_have_child_element(x)
|
|
|
|
install_model(x, occurs)
|
|
|
|
end
|
|
|
|
|
2004-10-16 08:39:58 +04:00
|
|
|
def other_element(convert, indent)
|
2004-01-28 06:46:13 +03:00
|
|
|
rv = <<-EOT
|
2004-10-16 08:39:58 +04:00
|
|
|
#{author_element(false, indent)}
|
|
|
|
#{comments_element(false, indent)}
|
|
|
|
#{pubDate_element(false, indent)}
|
|
|
|
#{guid_element(false, indent)}
|
2004-01-28 06:46:13 +03:00
|
|
|
EOT
|
|
|
|
rv << super
|
|
|
|
end
|
|
|
|
|
2004-07-06 21:43:05 +04:00
|
|
|
private
|
|
|
|
alias children09 children
|
|
|
|
def children
|
|
|
|
children09 + [@guid].compact
|
|
|
|
end
|
|
|
|
|
|
|
|
alias _tags09 _tags
|
|
|
|
def _tags
|
|
|
|
%w(comments author pubDate guid).delete_if do |x|
|
|
|
|
send(x).nil?
|
|
|
|
end.collect do |elem|
|
|
|
|
[nil, elem]
|
|
|
|
end + _tags09
|
|
|
|
end
|
|
|
|
|
2004-01-28 06:46:13 +03:00
|
|
|
class Guid < Element
|
|
|
|
|
|
|
|
include RSS09
|
|
|
|
|
|
|
|
[
|
|
|
|
["isPermaLink", nil, false]
|
|
|
|
].each do |name, uri, required|
|
|
|
|
install_get_attribute(name, uri, required)
|
|
|
|
end
|
|
|
|
|
|
|
|
content_setup
|
|
|
|
|
|
|
|
def initialize(isPermaLink=nil, content=nil)
|
|
|
|
super()
|
|
|
|
@isPermaLink = isPermaLink
|
|
|
|
@content = content
|
|
|
|
end
|
|
|
|
|
2004-10-16 08:39:58 +04:00
|
|
|
def to_s(convert=true, indent=calc_indent)
|
2004-01-28 06:46:13 +03:00
|
|
|
if @content
|
|
|
|
rv = %Q!<guid!
|
|
|
|
rv << %Q! isPermaLink="#{h @isPermaLink}"! if @isPermaLink
|
|
|
|
rv << %Q!>#{h @content}</guid>!
|
|
|
|
rv = @converter.convert(rv) if convert and @converter
|
|
|
|
rv
|
|
|
|
else
|
|
|
|
''
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
private
|
|
|
|
def _attrs
|
|
|
|
[
|
|
|
|
["isPermaLink", false]
|
|
|
|
]
|
|
|
|
end
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
end
|
|
|
|
|
2004-01-28 18:19:56 +03:00
|
|
|
RSS09::ELEMENTS.each do |x|
|
2004-02-13 14:02:03 +03:00
|
|
|
BaseListener.install_get_text_element(x, nil, "#{x}=")
|
2004-01-28 06:46:13 +03:00
|
|
|
end
|
|
|
|
|
|
|
|
end
|