From 01e1bb53f1adfdf14abd624ee3d93d9d8cd471b8 Mon Sep 17 00:00:00 2001 From: Arpit Jalan <arpit@techapj.com> Date: Mon, 29 Feb 2016 23:28:51 +0530 Subject: [PATCH] FEATURE: add RSS feed for top topics --- app/controllers/list_controller.rb | 13 +++++++++++++ config/locales/server.en.yml | 1 + 2 files changed, 14 insertions(+) diff --git a/app/controllers/list_controller.rb b/app/controllers/list_controller.rb index a5aa226c0..0d96f5dbe 100644 --- a/app/controllers/list_controller.rb +++ b/app/controllers/list_controller.rb @@ -129,6 +129,18 @@ class ListController < ApplicationController render 'list', formats: [:rss] end + def top_feed + discourse_expires_in 1.minute + + @title = "#{SiteSetting.title} - #{I18n.t("rss_description.top")}" + @link = "#{Discourse.base_url}/top" + @atom_link = "#{Discourse.base_url}/top.rss" + @description = I18n.t("rss_description.top") + @topic_list = TopicQuery.new(nil).list_top_for("monthly") + + render 'list', formats: [:rss] + end + def category_feed guardian.ensure_can_see!(@category) discourse_expires_in 1.minute @@ -175,6 +187,7 @@ class ListController < ApplicationController list.for_period = period list.more_topics_url = construct_url_with(:next, top_options) list.prev_topics_url = construct_url_with(:prev, top_options) + @rss = "top" if use_crawler_layout? @title = I18n.t("js.filters.top.#{period}.title") diff --git a/config/locales/server.en.yml b/config/locales/server.en.yml index db5287e78..1a4fa4ec2 100644 --- a/config/locales/server.en.yml +++ b/config/locales/server.en.yml @@ -201,6 +201,7 @@ en: rss_description: latest: "Latest topics" hot: "Hot topics" + top: "Top topics" posts: "Latest posts" too_late_to_edit: "That post was created too long ago. It can no longer be edited or deleted."