RSS for topics in a category

Creates a new route for category RSS
This commit is contained in:
Alexander
2013-02-27 19:36:12 -08:00
parent 0c8c41b131
commit fd240c1967
11 changed files with 85 additions and 12 deletions

View File

@@ -8,4 +8,10 @@
<p><a href="<%= @list.more_topics_url.sub('.json?','?') %>"><%= t 'next_page'%></a></p>
<% end %>
<p><%= t 'powered_by' %></p>
<p><%= t 'powered_by' %></p>
<% if @category %>
<% content_for :head do %>
<%= auto_discovery_link_tag(@category, {action: :category_feed, format: :rss}, title: t('rss_topics_in_category', category: @category.name), type: 'application/rss+xml') %>
<% end %>
<% end %>

View File

@@ -0,0 +1,23 @@
<?xml version="1.0" encoding="UTF-8" ?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
<channel>
<title><%= @category.name %></title>
<link><%= Discourse.base_url %>/category/<%= @category.slug %>.rss</link>
<description><%= t 'topics_in_category', category: @category.name %><%= @category.description %></description>
<atom:link href="<%= Discourse.base_url %>/category/<%= @category.slug %>.rss" rel="self" type="application/rss+xml" />
<% @topic_list.topics.each do |topic| %>
<item>
<title><%= topic.title %></title>
<description><![CDATA[
<p><%= pluralize(topic.posts_count, 'post') %></p>
<p><%= t 'author_wrote', author: topic.posts.first.author_readable %></p>
<%= topic.posts.first.cooked.html_safe %>
]]></description>
<link><%= Discourse.base_url %><%= topic.relative_url %></link>
<pubDate><%= topic.created_at.rfc2822 %></pubDate>
<guid><%= Discourse.base_url %><%= topic.relative_url %></guid>
<source url="<%= Discourse.base_url %><%= topic.relative_url %>.rss"><%= topic.title %></source>
</item>
<% end %>
</channel>
</rss>