controllers: standardize request format checks.
This commit is contained in:
@@ -7,9 +7,9 @@ class CommentsController < ApplicationController
|
|||||||
def index
|
def index
|
||||||
params[:group_by] ||= "comment" if params[:search].present?
|
params[:group_by] ||= "comment" if params[:search].present?
|
||||||
|
|
||||||
if params[:group_by] == "comment" || request.format == Mime::Type.lookup("application/atom+xml")
|
if params[:group_by] == "comment" || request.format.atom?
|
||||||
index_by_comment
|
index_by_comment
|
||||||
elsif request.format == Mime::Type.lookup("text/javascript")
|
elsif request.format.js?
|
||||||
index_for_post
|
index_for_post
|
||||||
else
|
else
|
||||||
index_by_post
|
index_by_post
|
||||||
|
|||||||
@@ -20,7 +20,7 @@ class ForumTopicsController < ApplicationController
|
|||||||
|
|
||||||
def index
|
def index
|
||||||
params[:search] ||= {}
|
params[:search] ||= {}
|
||||||
params[:search][:order] ||= "sticky" if request.format == Mime::Type.lookup("text/html")
|
params[:search][:order] ||= "sticky" if request.format.html?
|
||||||
params[:limit] ||= 40
|
params[:limit] ||= 40
|
||||||
|
|
||||||
@forum_topics = ForumTopic.paginated_search(params).includes(model_includes(params))
|
@forum_topics = ForumTopic.paginated_search(params).includes(model_includes(params))
|
||||||
@@ -29,7 +29,7 @@ class ForumTopicsController < ApplicationController
|
|||||||
end
|
end
|
||||||
|
|
||||||
def show
|
def show
|
||||||
if request.format == Mime::Type.lookup("text/html")
|
if request.format.html?
|
||||||
@forum_topic.mark_as_read!(CurrentUser.user)
|
@forum_topic.mark_as_read!(CurrentUser.user)
|
||||||
end
|
end
|
||||||
@forum_posts = ForumPost.search(:topic_id => @forum_topic.id).reorder("forum_posts.id").paginate(params[:page])
|
@forum_posts = ForumPost.search(:topic_id => @forum_topic.id).reorder("forum_posts.id").paginate(params[:page])
|
||||||
|
|||||||
@@ -21,7 +21,7 @@ class PostsController < ApplicationController
|
|||||||
def show
|
def show
|
||||||
@post = Post.find(params[:id])
|
@post = Post.find(params[:id])
|
||||||
|
|
||||||
if request.format == Mime::Type.lookup("text/html")
|
if request.format.html?
|
||||||
@comments = @post.comments
|
@comments = @post.comments
|
||||||
@comments = @comments.includes(:creator)
|
@comments = @comments.includes(:creator)
|
||||||
@comments = @comments.includes(:votes) if CurrentUser.is_member?
|
@comments = @comments.includes(:votes) if CurrentUser.is_member?
|
||||||
|
|||||||
Reference in New Issue
Block a user