app controller: clean up helpers.
* Move `show_moderation_notice?` out. * Don't need to declare `helper :pagination` manually.
This commit is contained in:
@@ -2,17 +2,15 @@ class ApplicationController < ActionController::Base
|
|||||||
class ApiLimitError < StandardError; end
|
class ApiLimitError < StandardError; end
|
||||||
|
|
||||||
skip_forgery_protection if: -> { SessionLoader.new(request).has_api_authentication? }
|
skip_forgery_protection if: -> { SessionLoader.new(request).has_api_authentication? }
|
||||||
helper :pagination
|
|
||||||
before_action :reset_current_user
|
before_action :reset_current_user
|
||||||
before_action :set_current_user
|
before_action :set_current_user
|
||||||
after_action :reset_current_user
|
|
||||||
before_action :normalize_search
|
before_action :normalize_search
|
||||||
before_action :api_check
|
before_action :api_check
|
||||||
before_action :set_variant
|
before_action :set_variant
|
||||||
before_action :track_only_param
|
before_action :track_only_param
|
||||||
layout "default"
|
|
||||||
helper_method :show_moderation_notice?
|
|
||||||
before_action :enable_cors
|
before_action :enable_cors
|
||||||
|
after_action :reset_current_user
|
||||||
|
layout "default"
|
||||||
|
|
||||||
rescue_from Exception, :with => :rescue_exception
|
rescue_from Exception, :with => :rescue_exception
|
||||||
rescue_from User::PrivilegeError, :with => :access_denied
|
rescue_from User::PrivilegeError, :with => :access_denied
|
||||||
@@ -31,10 +29,6 @@ class ApplicationController < ActionController::Base
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def show_moderation_notice?
|
|
||||||
CurrentUser.can_approve_posts? && (cookies[:moderated].blank? || Time.at(cookies[:moderated].to_i) < 20.hours.ago)
|
|
||||||
end
|
|
||||||
|
|
||||||
def enable_cors
|
def enable_cors
|
||||||
response.headers["Access-Control-Allow-Origin"] = "*"
|
response.headers["Access-Control-Allow-Origin"] = "*"
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -217,6 +217,10 @@ module ApplicationHelper
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def show_moderation_notice?
|
||||||
|
CurrentUser.can_approve_posts? && (cookies[:moderated].blank? || Time.at(cookies[:moderated].to_i) < 20.hours.ago)
|
||||||
|
end
|
||||||
|
|
||||||
protected
|
protected
|
||||||
def nav_link_match(controller, url)
|
def nav_link_match(controller, url)
|
||||||
url =~ case controller
|
url =~ case controller
|
||||||
|
|||||||
Reference in New Issue
Block a user