add RequestStore gem, support universal only param for api endpoints (fixes #4068)
This commit is contained in:
@@ -10,6 +10,7 @@ class ApplicationController < ActionController::Base
|
||||
before_action :api_check
|
||||
before_action :set_safe_mode
|
||||
before_action :set_variant
|
||||
before_action :track_only_param
|
||||
# before_action :secure_cookies_check
|
||||
layout "default"
|
||||
helper_method :show_moderation_notice?
|
||||
@@ -48,6 +49,12 @@ class ApplicationController < ActionController::Base
|
||||
end
|
||||
end
|
||||
|
||||
def track_only_param
|
||||
if params[:only]
|
||||
RequestStore[:only_param] = params[:only].split(/,/)
|
||||
end
|
||||
end
|
||||
|
||||
def api_check
|
||||
if !CurrentUser.is_anonymous? && !request.get? && !request.head?
|
||||
if CurrentUser.user.token_bucket.nil?
|
||||
|
||||
@@ -7,7 +7,7 @@ class PostVersionsController < ApplicationController
|
||||
@post_versions = PostArchive.includes(:updater, post: [:versions]).search(search_params).paginate(params[:page], :limit => params[:limit], :search_count => params[:search])
|
||||
respond_with(@post_versions) do |format|
|
||||
format.xml do
|
||||
render :xml => @post_versions.to_xml(:root => "post-versions")
|
||||
render xml: @post_versions.to_xml(root: "post-versions")
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -14,7 +14,7 @@ class PostsController < ApplicationController
|
||||
respond_with(@posts) do |format|
|
||||
format.atom
|
||||
format.xml do
|
||||
render :xml => @posts.to_xml(:root => "posts")
|
||||
render xml: @posts.to_xml(root: "posts")
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user