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
+13 -4
View File
@@ -1,6 +1,6 @@
class ListController < ApplicationController
before_filter :ensure_logged_in, except: [:index, :category]
before_filter :ensure_logged_in, except: [:index, :category, :category_feed]
skip_before_filter :check_xhr
# Create our filters
@@ -38,15 +38,24 @@ class ListController < ApplicationController
if params[:category] == Slug.for(SiteSetting.uncategorized_name) or params[:category] == SiteSetting.uncategorized_name
list = query.list_uncategorized
else
category = Category.where("slug = ? or id = ?", params[:category], params[:category].to_i).includes(:featured_users).first
guardian.ensure_can_see!(category)
list = query.list_category(category)
@category = Category.where("slug = ? or id = ?", params[:category], params[:category].to_i).includes(:featured_users).first
guardian.ensure_can_see!(@category)
list = query.list_category(@category)
end
list.more_topics_url = url_for(category_path(params[:category], page: next_page, format: "json"))
respond(list)
end
def category_feed
raise Discourse::InvalidParameters.new('Category RSS of "uncategorized"') if params[:category] == Slug.for(SiteSetting.uncategorized_name) || params[:category] == SiteSetting.uncategorized_name
@category = Category.where("slug = ?", params[:category]).includes(:featured_users).first
guardian.ensure_can_see!(@category)
@topic_list = TopicQuery.new.list_new_in_category(@category)
render 'list', formats: [:rss]
end
protected