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
|
# File 'app/blogical/atom.rb', line 3
def self.included(app)
app.get '/blog/atom.xml' do
feed = ::Atom::Feed.new do |f|
f.title = self.class.feed_title
f.links << ::Atom::Link.new(:href => self.class.url)
f.updated = options.repository.latest.posted.to_s(:iso8601)
f.authors << ::Atom::Person.new(:name => self.class.full_name)
f.id = 'tag:'+self.class.domain+',2010:blogical/blog'
options.repository.recent(15).each do |post|
entry = ::Atom::Entry.new do |e|
e.title = post.title
e.links << ::Atom::Link.new(:href => post.url)
e.id = UUIDTools::UUID.sha1_create(UUIDTools::UUID_URL_NAMESPACE, post.url).to_uri.to_s
e.updated = post.posted.to_s(:iso8601)
e.content = ::Atom::Content::Html.new(markup(File.read(post.content)))
end
f.entries << entry
end
end
feed.to_xml
end
end
|