diff --git a/tracks/app/controllers/feed_controller.rb b/tracks/app/controllers/feed_controller.rb index 9a5eae75..badce178 100644 --- a/tracks/app/controllers/feed_controller.rb +++ b/tracks/app/controllers/feed_controller.rb @@ -10,6 +10,7 @@ class FeedController < ApplicationController skip_before_filter :login_required before_filter :check_token_against_user_word before_filter :prepare_for_feed, :only => [:rss, :text, :ical] + before_filter :identify_contexts, :only => [:text, :ical] # Build an RSS feed def rss @@ -25,11 +26,6 @@ class FeedController < ApplicationController # curl [url from "TXT" link on todo/list] # def text - if params.key?('context') - @contexts = [ @user.contexts.find_by_params(params) ] - else - @contexts = @user.contexts.find_all_by_hide(false, "position ASC") - end headers["Content-Type"] = "text/plain; charset=utf-8" end @@ -38,11 +34,6 @@ class FeedController < ApplicationController # Due dates are supported, and notes are included. # def ical - if params.key?('context') - @contexts = [ @user.contexts.find_by_params(params) ] - else - @contexts = @user.contexts.find_all_by_hide(false, "position ASC") - end headers["Content-Type"] = "text/calendar" end @@ -56,6 +47,14 @@ protected return false end end + + def identify_contexts + if params.key?('context') + @contexts = [ @user.contexts.find_by_params(params) ] + else + @contexts = @user.contexts.find_all_by_hide(false, "position ASC") + end + end def prepare_for_feed condition_builder = FindConditionBuilder.new