implement /comments.rss

This commit is contained in:
joshua stein 2012-08-11 20:06:54 -05:00
parent f6b252e456
commit 776bf89dea
2 changed files with 27 additions and 0 deletions

View file

@ -272,6 +272,10 @@ class Comment < ActiveRecord::Base
end
end
def short_id_url
self.story.short_id_url + "/_/comments/#{self.short_id}"
end
def url
self.story.comments_url + "/comments/#{self.short_id}"
end

View file

@ -0,0 +1,23 @@
<?xml version="1.0" encoding="UTF-8" ?>
<% coder = HTMLEntities.new %>
<rss version="2.0">
<channel>
<title>lobste.rs<%= @title.present? ? ": " + h(@title) : "" %></title>
<description><%= @title %></description>
<link><%= root_url %>comments</link>
<% @comments.each do |comment| %>
<item>
<title>on <%= raw coder.encode(comment.story.title, :decimal) %></title>
<link><%= comment.url %></link>
<guid><%= comment.short_id_url %></guid>
<author><%= comment.user.username %></author>
<pubDate><%= comment.created_at.rfc2822 %></pubDate>
<comments><%= comment.url %></comments>
<description><%= raw coder.encode(comment.markeddown_comment,
:decimal) %></description>
</item>
<% end %>
</channel>
</rss>