remove trailing white-spaces from app/controllers/application_controller.rb.
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@5749 e93f8b46-1217-0410-a6f0-8f06a7374b81
This commit is contained in:
parent
9121a060a5
commit
092cfc0229
|
@ -5,12 +5,12 @@
|
||||||
# modify it under the terms of the GNU General Public License
|
# modify it under the terms of the GNU General Public License
|
||||||
# as published by the Free Software Foundation; either version 2
|
# as published by the Free Software Foundation; either version 2
|
||||||
# of the License, or (at your option) any later version.
|
# of the License, or (at your option) any later version.
|
||||||
#
|
#
|
||||||
# This program is distributed in the hope that it will be useful,
|
# This program is distributed in the hope that it will be useful,
|
||||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
# GNU General Public License for more details.
|
# GNU General Public License for more details.
|
||||||
#
|
#
|
||||||
# You should have received a copy of the GNU General Public License
|
# You should have received a copy of the GNU General Public License
|
||||||
# along with this program; if not, write to the Free Software
|
# along with this program; if not, write to the Free Software
|
||||||
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||||
|
@ -23,29 +23,29 @@ class ApplicationController < ActionController::Base
|
||||||
|
|
||||||
layout 'base'
|
layout 'base'
|
||||||
exempt_from_layout 'builder', 'rsb'
|
exempt_from_layout 'builder', 'rsb'
|
||||||
|
|
||||||
# Remove broken cookie after upgrade from 0.8.x (#4292)
|
# Remove broken cookie after upgrade from 0.8.x (#4292)
|
||||||
# See https://rails.lighthouseapp.com/projects/8994/tickets/3360
|
# See https://rails.lighthouseapp.com/projects/8994/tickets/3360
|
||||||
# TODO: remove it when Rails is fixed
|
# TODO: remove it when Rails is fixed
|
||||||
before_filter :delete_broken_cookies
|
before_filter :delete_broken_cookies
|
||||||
def delete_broken_cookies
|
def delete_broken_cookies
|
||||||
if cookies['_redmine_session'] && cookies['_redmine_session'] !~ /--/
|
if cookies['_redmine_session'] && cookies['_redmine_session'] !~ /--/
|
||||||
cookies.delete '_redmine_session'
|
cookies.delete '_redmine_session'
|
||||||
redirect_to home_path
|
redirect_to home_path
|
||||||
return false
|
return false
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
before_filter :user_setup, :check_if_login_required, :set_localization
|
before_filter :user_setup, :check_if_login_required, :set_localization
|
||||||
filter_parameter_logging :password
|
filter_parameter_logging :password
|
||||||
protect_from_forgery
|
protect_from_forgery
|
||||||
|
|
||||||
rescue_from ActionController::InvalidAuthenticityToken, :with => :invalid_authenticity_token
|
rescue_from ActionController::InvalidAuthenticityToken, :with => :invalid_authenticity_token
|
||||||
|
|
||||||
include Redmine::Search::Controller
|
include Redmine::Search::Controller
|
||||||
include Redmine::MenuManager::MenuController
|
include Redmine::MenuManager::MenuController
|
||||||
helper Redmine::MenuManager::MenuHelper
|
helper Redmine::MenuManager::MenuHelper
|
||||||
|
|
||||||
Redmine::Scm::Base.all.each do |scm|
|
Redmine::Scm::Base.all.each do |scm|
|
||||||
require_dependency "repository/#{scm.underscore}"
|
require_dependency "repository/#{scm.underscore}"
|
||||||
end
|
end
|
||||||
|
@ -56,7 +56,7 @@ class ApplicationController < ActionController::Base
|
||||||
# Find the current user
|
# Find the current user
|
||||||
User.current = find_current_user
|
User.current = find_current_user
|
||||||
end
|
end
|
||||||
|
|
||||||
# Returns the current user or nil if no user is logged in
|
# Returns the current user or nil if no user is logged in
|
||||||
# and starts a session if needed
|
# and starts a session if needed
|
||||||
def find_current_user
|
def find_current_user
|
||||||
|
@ -94,14 +94,14 @@ class ApplicationController < ActionController::Base
|
||||||
User.current = User.anonymous
|
User.current = User.anonymous
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
# check if login is globally required to access the application
|
# check if login is globally required to access the application
|
||||||
def check_if_login_required
|
def check_if_login_required
|
||||||
# no check needed if user is already logged in
|
# no check needed if user is already logged in
|
||||||
return true if User.current.logged?
|
return true if User.current.logged?
|
||||||
require_login if Setting.login_required?
|
require_login if Setting.login_required?
|
||||||
end
|
end
|
||||||
|
|
||||||
def set_localization
|
def set_localization
|
||||||
lang = nil
|
lang = nil
|
||||||
if User.current.logged?
|
if User.current.logged?
|
||||||
|
@ -117,7 +117,7 @@ class ApplicationController < ActionController::Base
|
||||||
lang ||= Setting.default_language
|
lang ||= Setting.default_language
|
||||||
set_language_if_valid(lang)
|
set_language_if_valid(lang)
|
||||||
end
|
end
|
||||||
|
|
||||||
def require_login
|
def require_login
|
||||||
if !User.current.logged?
|
if !User.current.logged?
|
||||||
# Extract only the basic url parameters on non-GET requests
|
# Extract only the basic url parameters on non-GET requests
|
||||||
|
@ -146,7 +146,7 @@ class ApplicationController < ActionController::Base
|
||||||
end
|
end
|
||||||
true
|
true
|
||||||
end
|
end
|
||||||
|
|
||||||
def deny_access
|
def deny_access
|
||||||
User.current.logged? ? render_403 : require_login
|
User.current.logged? ? render_403 : require_login
|
||||||
end
|
end
|
||||||
|
@ -197,7 +197,7 @@ class ApplicationController < ActionController::Base
|
||||||
# Finds and sets @project based on @object.project
|
# Finds and sets @project based on @object.project
|
||||||
def find_project_from_association
|
def find_project_from_association
|
||||||
render_404 unless @object.present?
|
render_404 unless @object.present?
|
||||||
|
|
||||||
@project = @object.project
|
@project = @object.project
|
||||||
rescue ActiveRecord::RecordNotFound
|
rescue ActiveRecord::RecordNotFound
|
||||||
render_404
|
render_404
|
||||||
|
@ -230,7 +230,7 @@ class ApplicationController < ActionController::Base
|
||||||
rescue ActiveRecord::RecordNotFound
|
rescue ActiveRecord::RecordNotFound
|
||||||
render_404
|
render_404
|
||||||
end
|
end
|
||||||
|
|
||||||
# Check if project is unique before bulk operations
|
# Check if project is unique before bulk operations
|
||||||
def check_project_uniqueness
|
def check_project_uniqueness
|
||||||
unless @project
|
unless @project
|
||||||
|
@ -239,7 +239,7 @@ class ApplicationController < ActionController::Base
|
||||||
return false
|
return false
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
# make sure that the user is a member of the project (or admin) if project is private
|
# make sure that the user is a member of the project (or admin) if project is private
|
||||||
# used as a before_filter for actions that do not require any particular permission on the project
|
# used as a before_filter for actions that do not require any particular permission on the project
|
||||||
def check_project_privacy
|
def check_project_privacy
|
||||||
|
@ -277,26 +277,26 @@ class ApplicationController < ActionController::Base
|
||||||
redirect_to default
|
redirect_to default
|
||||||
false
|
false
|
||||||
end
|
end
|
||||||
|
|
||||||
def render_403(options={})
|
def render_403(options={})
|
||||||
@project = nil
|
@project = nil
|
||||||
render_error({:message => :notice_not_authorized, :status => 403}.merge(options))
|
render_error({:message => :notice_not_authorized, :status => 403}.merge(options))
|
||||||
return false
|
return false
|
||||||
end
|
end
|
||||||
|
|
||||||
def render_404(options={})
|
def render_404(options={})
|
||||||
render_error({:message => :notice_file_not_found, :status => 404}.merge(options))
|
render_error({:message => :notice_file_not_found, :status => 404}.merge(options))
|
||||||
return false
|
return false
|
||||||
end
|
end
|
||||||
|
|
||||||
# Renders an error response
|
# Renders an error response
|
||||||
def render_error(arg)
|
def render_error(arg)
|
||||||
arg = {:message => arg} unless arg.is_a?(Hash)
|
arg = {:message => arg} unless arg.is_a?(Hash)
|
||||||
|
|
||||||
@message = arg[:message]
|
@message = arg[:message]
|
||||||
@message = l(@message) if @message.is_a?(Symbol)
|
@message = l(@message) if @message.is_a?(Symbol)
|
||||||
@status = arg[:status] || 500
|
@status = arg[:status] || 500
|
||||||
|
|
||||||
respond_to do |format|
|
respond_to do |format|
|
||||||
format.html {
|
format.html {
|
||||||
render :template => 'common/error', :layout => use_layout, :status => @status
|
render :template => 'common/error', :layout => use_layout, :status => @status
|
||||||
|
@ -314,31 +314,31 @@ class ApplicationController < ActionController::Base
|
||||||
def use_layout
|
def use_layout
|
||||||
request.xhr? ? false : 'base'
|
request.xhr? ? false : 'base'
|
||||||
end
|
end
|
||||||
|
|
||||||
def invalid_authenticity_token
|
def invalid_authenticity_token
|
||||||
if api_request?
|
if api_request?
|
||||||
logger.error "Form authenticity token is missing or is invalid. API calls must include a proper Content-type header (text/xml or text/json)."
|
logger.error "Form authenticity token is missing or is invalid. API calls must include a proper Content-type header (text/xml or text/json)."
|
||||||
end
|
end
|
||||||
render_error "Invalid form authenticity token."
|
render_error "Invalid form authenticity token."
|
||||||
end
|
end
|
||||||
|
|
||||||
def render_feed(items, options={})
|
def render_feed(items, options={})
|
||||||
@items = items || []
|
@items = items || []
|
||||||
@items.sort! {|x,y| y.event_datetime <=> x.event_datetime }
|
@items.sort! {|x,y| y.event_datetime <=> x.event_datetime }
|
||||||
@items = @items.slice(0, Setting.feeds_limit.to_i)
|
@items = @items.slice(0, Setting.feeds_limit.to_i)
|
||||||
@title = options[:title] || Setting.app_title
|
@title = options[:title] || Setting.app_title
|
||||||
render :template => "common/feed.atom.rxml", :layout => false, :content_type => 'application/atom+xml'
|
render :template => "common/feed.atom.rxml", :layout => false, :content_type => 'application/atom+xml'
|
||||||
end
|
end
|
||||||
|
|
||||||
def self.accept_key_auth(*actions)
|
def self.accept_key_auth(*actions)
|
||||||
actions = actions.flatten.map(&:to_s)
|
actions = actions.flatten.map(&:to_s)
|
||||||
write_inheritable_attribute('accept_key_auth_actions', actions)
|
write_inheritable_attribute('accept_key_auth_actions', actions)
|
||||||
end
|
end
|
||||||
|
|
||||||
def accept_key_auth_actions
|
def accept_key_auth_actions
|
||||||
self.class.read_inheritable_attribute('accept_key_auth_actions') || []
|
self.class.read_inheritable_attribute('accept_key_auth_actions') || []
|
||||||
end
|
end
|
||||||
|
|
||||||
# Returns the number of objects that should be displayed
|
# Returns the number of objects that should be displayed
|
||||||
# on the paginated list
|
# on the paginated list
|
||||||
def per_page_option
|
def per_page_option
|
||||||
|
@ -374,10 +374,10 @@ class ApplicationController < ActionController::Base
|
||||||
offset = 0 if offset < 0
|
offset = 0 if offset < 0
|
||||||
end
|
end
|
||||||
offset ||= 0
|
offset ||= 0
|
||||||
|
|
||||||
[offset, limit]
|
[offset, limit]
|
||||||
end
|
end
|
||||||
|
|
||||||
# qvalues http header parser
|
# qvalues http header parser
|
||||||
# code taken from webrick
|
# code taken from webrick
|
||||||
def parse_qvalues(value)
|
def parse_qvalues(value)
|
||||||
|
@ -398,16 +398,16 @@ class ApplicationController < ActionController::Base
|
||||||
rescue
|
rescue
|
||||||
nil
|
nil
|
||||||
end
|
end
|
||||||
|
|
||||||
# Returns a string that can be used as filename value in Content-Disposition header
|
# Returns a string that can be used as filename value in Content-Disposition header
|
||||||
def filename_for_content_disposition(name)
|
def filename_for_content_disposition(name)
|
||||||
request.env['HTTP_USER_AGENT'] =~ %r{MSIE} ? ERB::Util.url_encode(name) : name
|
request.env['HTTP_USER_AGENT'] =~ %r{MSIE} ? ERB::Util.url_encode(name) : name
|
||||||
end
|
end
|
||||||
|
|
||||||
def api_request?
|
def api_request?
|
||||||
%w(xml json).include? params[:format]
|
%w(xml json).include? params[:format]
|
||||||
end
|
end
|
||||||
|
|
||||||
# Returns the API key present in the request
|
# Returns the API key present in the request
|
||||||
def api_key_from_request
|
def api_key_from_request
|
||||||
if params[:key].present?
|
if params[:key].present?
|
||||||
|
@ -464,7 +464,7 @@ class ApplicationController < ActionController::Base
|
||||||
)
|
)
|
||||||
render options
|
render options
|
||||||
end
|
end
|
||||||
|
|
||||||
# Overrides #default_template so that the api template
|
# Overrides #default_template so that the api template
|
||||||
# is used automatically if it exists
|
# is used automatically if it exists
|
||||||
def default_template(action_name = self.action_name)
|
def default_template(action_name = self.action_name)
|
||||||
|
@ -478,7 +478,7 @@ class ApplicationController < ActionController::Base
|
||||||
end
|
end
|
||||||
super
|
super
|
||||||
end
|
end
|
||||||
|
|
||||||
# Overrides #pick_layout so that #render with no arguments
|
# Overrides #pick_layout so that #render with no arguments
|
||||||
# doesn't use the layout for api requests
|
# doesn't use the layout for api requests
|
||||||
def pick_layout(*args)
|
def pick_layout(*args)
|
||||||
|
|
Loading…
Reference in New Issue