2008年11月12日 星期三

atom_feed,rss

http://railscasts.com/episodes/87-generating-rss-feeds
http://svn.rubyonrails.org/rails/plugins/atom_feed_helper/README
http://api.rubyonrails.com/classes/ActionView/Helpers/AtomFeedHelper.html#M001208
http://hideto.javaeye.com/blog/84463
http://snippets.dzone.com/tags/ruby/blinksale
http://railspikes.com/2008/10/1/publishing-non-activerecord-objects-in-an-atom-feed-with-rails


atom_feed do |feed|
feed.title("All User Books!")
feed.updated((@users.first.created_at))

for user in @users
feed.entry(user) do |entry|
entry.title(user.name)
entry.content(user.name, :type => 'html')

entry.books do |books| <= 幹 這個地方不用再傳東西, entry.book(fuck)
for b in user.books
books.title(b.name)
end
end
end
end
end

<?xml version="1.0" encoding="UTF-8"?>
<feed xml:lang="en-US" xmlns="http://www.w3.org/2005/Atom">
<id>tag:localhost,2005:/people</id>
<link type="text/html" rel="alternate" href="http://localhost:25001"/>
<link type="application/atom+xml" rel="self" href="http://localhost:25001/people.atom"/>
<title>My great blog!</title>
<updated>2008-11-04T00:31:17Z</updated>
<entry>
<id>tag:localhost,2005:User/1</id>
<published>2008-11-04T00:31:17Z</published>
<updated>2008-11-04T00:31:17Z</updated>
<link type="text/html" rel="alternate" href="http://localhost:25001/people/1"/>
<title>ilake</title>
<content type="html">ilake</content>
<books>
<title>book123</title>
<title>bbbb</title>
</books>
</entry>
<entry>
<id>tag:localhost,2005:User/2</id>
<published>2008-11-09T16:39:09Z</published>
<updated>2008-11-09T16:39:09Z</updated>
<link type="text/html" rel="alternate" href="http://localhost:25001/people/2"/>
<title>lake2</title>
<content type="html">lake2</content>
<books>
<title>[lake2]lake 2 book</title>
</books>
</entry>
</feed>

沒有留言: