34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
|
# File 'lib/hobix/out/rss.rb', line 34
def load( file_name, vars )
= REXML::Document.new( <<EOXML )
<rss version="2.0"
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
xmlns:admin="http://webns.net/mvcb/"
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#">
<channel>
<title></title>
<link></link>
<description></description>
<dc:language>en-us</dc:language>
<dc:creator></dc:creator>
<dc:date></dc:date>
<admin:generatorAgent rdf:resource="http://hobix.com/?v=#{ Hobix::VERSION }" />
<sy:updatePeriod>hourly</sy:updatePeriod>
<sy:updateFrequency>1</sy:updateFrequency>
<sy:updateBase>2000-01-01T12:00+00:00</sy:updateBase>
</channel>
</rss>
EOXML
<< REXML::XMLDecl.new
.elements['/rss/channel/title'].text = ( vars[:weblog].title )
.elements['/rss/channel/link'].text = vars[:weblog].link.to_s
.elements['/rss/channel/description'].text = vars[:weblog].tagline
.elements['/rss/channel/dc:date'].text = Time.now.utc.strftime( "%Y-%m-%dT%H:%M:%S+00:00" )
@extra_ns.each do |k, v|
.elements['/rss'].attributes["xmlns:" + k.to_s] = v.to_s
end if @extra_ns
@extra_els.each do |k, v|
= REXML::Element.new k.to_s
.text = v.to_s
.elements['/rss/channel'].add
end if @extra_els
( vars[:entries] || [vars[:entry]] ).each do |e|
ele = REXML::Element.new 'item'
ele_title = REXML::Element.new 'title'
ele_title.text = ( e.title )
ele << ele_title
ele_link = REXML::Element.new 'link'
link = e.link.gsub(/'/,"%27")
ele_link.text = "#{ link }"
ele << ele_link
if @comment_aname
= REXML::Element.new 'comments'
.text = "#{ link }##@comment_aname"
ele <<
end
ele_guid = REXML::Element.new 'guid'
ele_guid.attributes['isPermaLink'] = 'false'
ele_guid.text = "#{ e.id }@#{ vars[:weblog].link }"
ele << ele_guid
ele_subject = REXML::Element.new 'dc:subject'
ele_subject.text = e.section_id
ele << ele_subject
e.tags.each do |t|
ele_subject = REXML::Element.new 'dc:subject'
ele_subject.text = t
ele << ele_subject
end
ele_creator = REXML::Element.new 'dc:creator'
ele_creator.text = vars[:weblog].authors[e.author]['name']
ele << ele_creator
ele_pubDate = REXML::Element.new 'dc:date'
ele_pubDate.text = ( e.modified || e.created ).dup.utc.strftime( "%Y-%m-%dT%H:%M:%S+00:00" )
ele << ele_pubDate
ele_desc = REXML::Element.new 'description'
ele_desc.attributes['xml:space'] = "preserve"
text =
if @summaries && e.summary
e.summary.to_html + (@more_link ? %{<p><a href="#{e.link}">#@more_link</a></p>} : "")
else
e.content.to_html
end.gsub( /(src|href)="\//, "\\1=\"#{ vars[:weblog].link.rooturi }/" )
REXML::Text.new ::ERB::Util.h( text ), true, ele_desc, true
ele << ele_desc
.elements['/rss/channel'].add ele
end
.to_s
end
|