summaryrefslogtreecommitdiff
path: root/app
diff options
context:
space:
mode:
authorelijah <elijah@riseup.net>2013-02-12 23:46:35 -0800
committerelijah <elijah@riseup.net>2013-02-12 23:46:35 -0800
commitea5f89e55c7afde4bf2d6719b0afa8a878082fb5 (patch)
treeb1c974ca423c52a03724f39035fa2a49775acd5c /app
parente29134d17854d88b4a81456987c28db93f5ec97c (diff)
misc fixes to get working in production mode using Thin.
Diffstat (limited to 'app')
-rw-r--r--app/controllers/application_controller.rb22
-rw-r--r--app/helpers/navigation_helper.rb3
2 files changed, 14 insertions, 11 deletions
diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb
index b2c5762..b73a463 100644
--- a/app/controllers/application_controller.rb
+++ b/app/controllers/application_controller.rb
@@ -22,18 +22,20 @@ class ApplicationController < ActionController::Base
# ensure that the locale is encoded as the url prefix and I18n.locale is set.
#
def set_locale
- if params[:locale].nil? || !AVAILABLE_LANGUAGES.include?(params[:locale])
- locale = HttpAcceptLanguage::compatible_language_from(request.headers['HTTP_ACCEPT_LANGUAGE'], AVAILABLE_LANGUAGES) || DEFAULT_LOCALE
- locale = locale.to_s.sub('-', '_').sub(/_\w\w/, '')
- if request.path == '/'
- url = '/' + locale
+ if request.format == 'text/html'
+ if params[:locale].nil? || !AVAILABLE_LANGUAGES.include?(params[:locale])
+ locale = HttpAcceptLanguage::compatible_language_from(request.headers['HTTP_ACCEPT_LANGUAGE'], AVAILABLE_LANGUAGES) || DEFAULT_LOCALE
+ locale = locale.to_s.sub('-', '_').sub(/_\w\w/, '')
+ if request.path == '/'
+ url = '/' + locale
+ else
+ url = url_for(params.merge(:locale => locale))
+ end
+ redirect_to url
else
- url = url_for(params.merge(:locale => locale))
+ I18n.locale = params[:locale]
+ self.default_url_options[:locale] = params[:locale]
end
- redirect_to url
- else
- I18n.locale = params[:locale]
- self.default_url_options[:locale] = params[:locale]
end
end
diff --git a/app/helpers/navigation_helper.rb b/app/helpers/navigation_helper.rb
index a43eecd..fde6b45 100644
--- a/app/helpers/navigation_helper.rb
+++ b/app/helpers/navigation_helper.rb
@@ -1,7 +1,7 @@
module NavigationHelper
def has_side_column?
- if root_page?
+ if root_page? || site.menu.nil?
return false
end
second_level_children_count = site.menu.submenu(current_page_path.first).try(:size)
@@ -13,6 +13,7 @@ module NavigationHelper
end
def top_level_navigation_links
+ return unless site.menu
haml do
first = 'first'
site.menu.each do |item|