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?
|
def user_is_spider?
|
||||||
!!request.env["HTTP_USER_AGENT"].to_s.match(/Googlebot/)
|
!!request.env["HTTP_USER_AGENT"].to_s.match(/Googlebot/)
|
||||||
end
|
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
|
end
|
||||||
|
|
|
@ -3,6 +3,9 @@ class CommentsController < ApplicationController
|
||||||
|
|
||||||
before_filter :require_logged_in_user_or_400,
|
before_filter :require_logged_in_user_or_400,
|
||||||
:only => [ :create, :preview, :preview_new, :upvote, :downvote, :unvote ]
|
: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
|
def create
|
||||||
if !(story = Story.find_by_short_id(params[:story_id])) || story.is_gone?
|
if !(story = Story.find_by_short_id(params[:story_id])) || story.is_gone?
|
||||||
|
@ -187,6 +190,10 @@ class CommentsController < ApplicationController
|
||||||
end
|
end
|
||||||
|
|
||||||
def index
|
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"
|
@heading = @title = "Newest Comments"
|
||||||
@cur_url = "/comments"
|
@cur_url = "/comments"
|
||||||
|
|
||||||
|
|
|
@ -187,10 +187,4 @@ private
|
||||||
|
|
||||||
[ stories, show_more ]
|
[ stories, show_more ]
|
||||||
end
|
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
|
end
|
||||||
|
|
Loading…
Reference in a new issue