summaryrefslogtreecommitdiff
path: root/app/controllers
diff options
context:
space:
mode:
Diffstat (limited to 'app/controllers')
-rw-r--r--app/controllers/rss_controller.rb34
1 files changed, 14 insertions, 20 deletions
diff --git a/app/controllers/rss_controller.rb b/app/controllers/rss_controller.rb
index 655ccba4..c2149d90 100644
--- a/app/controllers/rss_controller.rb
+++ b/app/controllers/rss_controller.rb
@@ -1,19 +1,12 @@
1class RssController < ApplicationController 1class RssController < ApplicationController
2 2
3 before_action :get_host 3 before_action :get_host
4 4
5 def updates 5 def updates
6 expires_in 31.minutes, :public => true 6 expires_in 31.minutes, :public => true
7
8 I18n.locale = I18n.default_locale 7 I18n.locale = I18n.default_locale
9 8
10 @items = Page.heads 9 @items = feed_items("update")
11 .joins("JOIN taggings ON taggings.taggable_id = pages.id
12 AND taggings.taggable_type = 'Page'
13 AND taggings.context = 'tags'")
14 .joins("JOIN tags ON tags.id = taggings.tag_id")
15 .where("LOWER(tags.name) = ?", "update")
16 .order("published_at DESC").limit(20)
17 10
18 respond_to do |format| 11 respond_to do |format|
19 format.xml {} 12 format.xml {}
@@ -23,16 +16,10 @@ class RssController < ApplicationController
23 16
24 def tag_updates 17 def tag_updates
25 expires_in 31.minutes, :public => true 18 expires_in 31.minutes, :public => true
26
27 I18n.locale = I18n.default_locale 19 I18n.locale = I18n.default_locale
28 @tag = params[:tag] 20
29 @items = Page.heads 21 @tag = params[:tag]
30 .joins("JOIN taggings ON taggings.taggable_id = pages.id 22 @items = feed_items(@tag)
31 AND taggings.taggable_type = 'Page'
32 AND taggings.context = 'tags'")
33 .joins("JOIN tags ON tags.id = taggings.tag_id")
34 .where("LOWER(tags.name) = ?", @tag.downcase)
35 .order("published_at DESC").limit(20)
36 23
37 respond_to do |format| 24 respond_to do |format|
38 format.xml {} 25 format.xml {}
@@ -40,7 +27,14 @@ class RssController < ApplicationController
40 end 27 end
41 28
42 protected 29 protected
43 30
31 def feed_items tag
32 Page.aggregate(:tags => tag.to_s.downcase,
33 :limit => 20,
34 :order_by => "published_at",
35 :order_direction => "DESC")
36 end
37
44 def get_host 38 def get_host
45 @host = request.protocol + request.host_with_port 39 @host = request.protocol + request.host_with_port
46 end 40 end