diff --git a/app/controllers/application.rb b/app/controllers/application.rb
index 7f147a8..33f4328 100644
--- a/app/controllers/application.rb
+++ b/app/controllers/application.rb
@@ -1,143 +1 @@
-# his is the application's main controller. Features defined here are
-# available in all controllers.
-class ApplicationController < ActionController::Base
-
- include ApplicationHelper
- layout :get_layout
- def get_layout
- theme_option(:layout) || 'application'
- end
-
- filter_parameter_logging :password
-
- def log_processing
- super
- return unless ENV['RAILS_ENV'] == 'production'
- if logger && logger.info?
- logger.info(" HTTP Referer: #{request.referer}")
- logger.info(" User Agent: #{request.user_agent}")
- logger.info(" Accept-Language: #{request.headers['HTTP_ACCEPT_LANGUAGE']}")
- end
- end
-
- helper :document
- helper :language
-
- def boxes_editor?
- false
- end
- protected :boxes_editor?
-
- def self.no_design_blocks
- @no_design_blocks = true
- end
- def self.uses_design_blocks?
- !@no_design_blocks
- end
- def uses_design_blocks?
- !@no_design_blocks && self.class.uses_design_blocks?
- end
-
- # Be sure to include AuthenticationSystem in Application Controller instead
- include AuthenticatedSystem
- include PermissionCheck
-
- def self.require_ssl(*options)
- before_filter :check_ssl, *options
- end
- def check_ssl
- return true if (request.ssl? || ENV['RAILS_ENV'] == 'development')
- redirect_to_ssl
- end
- def redirect_to_ssl
- if environment.enable_ssl
- redirect_to(params.merge(:protocol => 'https://', :host => ssl_hostname))
- true
- else
- false
- end
- end
-
- def self.refuse_ssl(*options)
- before_filter :avoid_ssl, *options
- end
- def avoid_ssl
- if (!request.ssl? || ENV['RAILS_ENV'] == 'development')
- true
- else
- redirect_to(params.merge(:protocol => 'http://'))
- false
- end
- end
-
- before_filter :set_locale
- def set_locale
- FastGettext.available_locales = Noosfero.available_locales
- FastGettext.default_locale = Noosfero.default_locale
- FastGettext.set_locale(params[:lang] || session[:lang] || Noosfero.default_locale || request.env['HTTP_ACCEPT_LANGUAGE'] || 'en')
- if params[:lang]
- session[:lang] = params[:lang]
- end
- end
-
- include NeedsProfile
-
- before_filter :detect_stuff_by_domain
- attr_reader :environment
-
- before_filter :load_terminology
-
- # declares that the given actions cannot be accessed by other HTTP
- # method besides POST.
- def self.post_only(actions, redirect = { :action => 'index'})
- verify :method => :post, :only => actions, :redirect_to => redirect
- end
-
- protected
-
- # TODO: move this logic somewhere else (Domain class?)
- def detect_stuff_by_domain
- @domain = Domain.find_by_name(request.host)
- if @domain.nil?
- @environment = Environment.default
- else
- @environment = @domain.environment
- @profile = @domain.profile
- end
- end
-
- def load_terminology
- # cache terminology for performance
- @@terminology_cache ||= {}
- @@terminology_cache[environment.id] ||= environment.terminology
- Noosfero.terminology = @@terminology_cache[environment.id]
- end
-
- def render_not_found(path = nil)
- @no_design_blocks = true
- @path ||= request.path
- render :template => 'shared/not_found.rhtml', :status => 404
- end
-
- def render_access_denied(message = nil, title = nil)
- @no_design_blocks = true
- @message = message
- @title = title
- render :template => 'shared/access_denied.rhtml', :status => 403
- end
-
- def user
- current_user.person if logged_in?
- end
-
- def load_category
- unless params[:category_path].blank?
- path = params[:category_path].join('/')
- @category = environment.categories.find_by_path(path)
- if @category.nil?
- render_not_found(path)
- end
- end
- end
-
-end
+require 'application_controller'
diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb
new file mode 100644
index 0000000..7f147a8
--- /dev/null
+++ b/app/controllers/application_controller.rb
@@ -0,0 +1,143 @@
+# his is the application's main controller. Features defined here are
+# available in all controllers.
+class ApplicationController < ActionController::Base
+
+ include ApplicationHelper
+ layout :get_layout
+ def get_layout
+ theme_option(:layout) || 'application'
+ end
+
+ filter_parameter_logging :password
+
+ def log_processing
+ super
+ return unless ENV['RAILS_ENV'] == 'production'
+ if logger && logger.info?
+ logger.info(" HTTP Referer: #{request.referer}")
+ logger.info(" User Agent: #{request.user_agent}")
+ logger.info(" Accept-Language: #{request.headers['HTTP_ACCEPT_LANGUAGE']}")
+ end
+ end
+
+ helper :document
+ helper :language
+
+ def boxes_editor?
+ false
+ end
+ protected :boxes_editor?
+
+ def self.no_design_blocks
+ @no_design_blocks = true
+ end
+ def self.uses_design_blocks?
+ !@no_design_blocks
+ end
+ def uses_design_blocks?
+ !@no_design_blocks && self.class.uses_design_blocks?
+ end
+
+ # Be sure to include AuthenticationSystem in Application Controller instead
+ include AuthenticatedSystem
+ include PermissionCheck
+
+ def self.require_ssl(*options)
+ before_filter :check_ssl, *options
+ end
+ def check_ssl
+ return true if (request.ssl? || ENV['RAILS_ENV'] == 'development')
+ redirect_to_ssl
+ end
+ def redirect_to_ssl
+ if environment.enable_ssl
+ redirect_to(params.merge(:protocol => 'https://', :host => ssl_hostname))
+ true
+ else
+ false
+ end
+ end
+
+ def self.refuse_ssl(*options)
+ before_filter :avoid_ssl, *options
+ end
+ def avoid_ssl
+ if (!request.ssl? || ENV['RAILS_ENV'] == 'development')
+ true
+ else
+ redirect_to(params.merge(:protocol => 'http://'))
+ false
+ end
+ end
+
+ before_filter :set_locale
+ def set_locale
+ FastGettext.available_locales = Noosfero.available_locales
+ FastGettext.default_locale = Noosfero.default_locale
+ FastGettext.set_locale(params[:lang] || session[:lang] || Noosfero.default_locale || request.env['HTTP_ACCEPT_LANGUAGE'] || 'en')
+ if params[:lang]
+ session[:lang] = params[:lang]
+ end
+ end
+
+ include NeedsProfile
+
+ before_filter :detect_stuff_by_domain
+ attr_reader :environment
+
+ before_filter :load_terminology
+
+ # declares that the given actions cannot be accessed by other HTTP
+ # method besides POST.
+ def self.post_only(actions, redirect = { :action => 'index'})
+ verify :method => :post, :only => actions, :redirect_to => redirect
+ end
+
+ protected
+
+ # TODO: move this logic somewhere else (Domain class?)
+ def detect_stuff_by_domain
+ @domain = Domain.find_by_name(request.host)
+ if @domain.nil?
+ @environment = Environment.default
+ else
+ @environment = @domain.environment
+ @profile = @domain.profile
+ end
+ end
+
+ def load_terminology
+ # cache terminology for performance
+ @@terminology_cache ||= {}
+ @@terminology_cache[environment.id] ||= environment.terminology
+ Noosfero.terminology = @@terminology_cache[environment.id]
+ end
+
+ def render_not_found(path = nil)
+ @no_design_blocks = true
+ @path ||= request.path
+ render :template => 'shared/not_found.rhtml', :status => 404
+ end
+
+ def render_access_denied(message = nil, title = nil)
+ @no_design_blocks = true
+ @message = message
+ @title = title
+ render :template => 'shared/access_denied.rhtml', :status => 403
+ end
+
+ def user
+ current_user.person if logged_in?
+ end
+
+ def load_category
+ unless params[:category_path].blank?
+ path = params[:category_path].join('/')
+ @category = environment.categories.find_by_path(path)
+ if @category.nil?
+ render_not_found(path)
+ end
+ end
+ end
+
+end
diff --git a/config/environment.rb b/config/environment.rb
index 8c8f61e..97ca781 100644
--- a/config/environment.rb
+++ b/config/environment.rb
@@ -85,7 +85,7 @@ Rails::Initializer.run do |config|
end
end
extra_controller_dirs.each do |item|
- Dependencies.load_paths << item
+ (ActiveSupport.const_defined?('Dependencies') ? ActiveSupport::Dependencies : ::Dependencies).load_paths << item
end
# Add new inflection rules using the following format
diff --git a/lib/noosfero/i18n.rb b/lib/noosfero/i18n.rb
index 4a9e85c..a8aaa52 100644
--- a/lib/noosfero/i18n.rb
+++ b/lib/noosfero/i18n.rb
@@ -153,8 +153,8 @@ module ActionController::Caching::Fragments
alias_method_chain :expire_fragment, :fast_gettext
end
-FileUtils.mkdir_p(Rails.root + '/locale')
-Dir.glob(Rails.root + '/locale/*').each do |dir|
+FileUtils.mkdir_p(File.join(Rails.root, 'locale'))
+Dir.glob(File.join(Rails.root, 'locale/*')).each do |dir|
lang = File.basename(dir)
FileUtils.mkdir_p("#{Rails.root}/locale/#{lang}/LC_MESSAGES")
['iso_3166', 'rails'].each do |domain|
@@ -174,9 +174,9 @@ Dir.glob(Rails.root + '/locale/*').each do |dir|
end
repos = [
- FastGettext::TranslationRepository.build('noosfero', :type => 'mo', :path => Rails.root + '/locale'),
- FastGettext::TranslationRepository.build('iso_3166', :type => 'mo', :path => Rails.root + '/locale'),
- FastGettext::TranslationRepository.build('rails', :type => 'mo', :path => Rails.root + '/locale'),
+ FastGettext::TranslationRepository.build('noosfero', :type => 'mo', :path => File.join(Rails.root, 'locale')),
+ FastGettext::TranslationRepository.build('iso_3166', :type => 'mo', :path => File.join(Rails.root, 'locale')),
+ FastGettext::TranslationRepository.build('rails', :type => 'mo', :path => File.join(Rails.root, 'locale')),
]
FastGettext.add_text_domain 'noosferofull', :type => :chain, :chain => repos
--
libgit2 0.21.2