show rss <link> header on /comments
This commit is contained in:
parent
ae2c0421e6
commit
14ed917baa
|
@ -58,4 +58,10 @@ class ApplicationController < ActionController::Base
|
|||
def user_is_spider?
|
||||
!!request.env["HTTP_USER_AGENT"].to_s.match(/Googlebot/)
|
||||
end
|
||||
|
||||
def find_user_from_rss_token
|
||||
if !@user && request[:format] == "rss" && params[:token].to_s.present?
|
||||
@user = User.find_by_rss_token(params[:token])
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -3,6 +3,9 @@ class CommentsController < ApplicationController
|
|||
|
||||
before_filter :require_logged_in_user_or_400,
|
||||
:only => [ :create, :preview, :preview_new, :upvote, :downvote, :unvote ]
|
||||
|
||||
# for rss feeds, load the user's tag filters if a token is passed
|
||||
before_filter :find_user_from_rss_token, :only => [ :index ]
|
||||
|
||||
def create
|
||||
if !(story = Story.find_by_short_id(params[:story_id])) || story.is_gone?
|
||||
|
@ -187,6 +190,10 @@ class CommentsController < ApplicationController
|
|||
end
|
||||
|
||||
def index
|
||||
@rss_link ||= "<link rel=\"alternate\" type=\"application/rss+xml\" " <<
|
||||
"title=\"RSS 2.0\" href=\"/comments.rss" <<
|
||||
(@user ? "?token=#{@user.rss_token}" : "") << "\" />"
|
||||
|
||||
@heading = @title = "Newest Comments"
|
||||
@cur_url = "/comments"
|
||||
|
||||
|
|
|
@ -187,10 +187,4 @@ private
|
|||
|
||||
[ stories, show_more ]
|
||||
end
|
||||
|
||||
def find_user_from_rss_token
|
||||
if !@user && request[:format] == "rss" && params[:token].to_s.present?
|
||||
@user = User.find_by_rss_token(params[:token])
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue