rss_feed.rb
1.42 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
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
class RssFeed < Article
# store setting in body
serialize Hash, :body
def body
self[:body] ||= {}
end
alias :settings :body
# TODO
def to_html
end
# RSS feeds have type =text/xml=.
def mime_type
'text/xml'
end
# FIXME feed real data into the RSS feed
def data
articles =
if (self.settings[:include] == :parent_and_children) && self.parent
self.parent.map_traversal
else
profile.recent_documents(self.settings[:limit] || 10)
end
result = ""
xml = Builder::XmlMarkup.new(:target => result)
xml.instruct! :xml, :version=>"1.0"
xml.rss(:version=>"2.0") do
xml.channel do
xml.title(_("%s's RSS feed") % (self.profile.name))
xml.link("http://www.yourDomain.com")
xml.description('Description here')
xml.language("pt_BR")
for article in articles
unless self == article
xml.item do
xml.title(article.name)
if self.settings[:description] == :body
xml.description(article.body)
else
xml.description(article.abstract)
end
# rfc822
xml.pubDate(article.created_on.rfc2822)
xml.link("http://www.yourDomain.com/linkToYourPost")
xml.guid("http://www.yourDomain.com/linkToYourPost")
end
end
end
end
end
result
end
end