summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Gemfile42
-rw-r--r--Gemfile.lock1
-rw-r--r--app/controllers/application_controller.rb22
-rw-r--r--app/helpers/navigation_helper.rb3
-rw-r--r--config/environments/production.rb2
-rw-r--r--lib/menu.rb2
6 files changed, 23 insertions, 49 deletions
diff --git a/Gemfile b/Gemfile
index 9ed38ca..7748246 100644
--- a/Gemfile
+++ b/Gemfile
@@ -1,52 +1,24 @@
source 'https://rubygems.org'
gem 'rails', '3.2.12'
-
-# Bundle edge Rails instead:
-# gem 'rails', :git => 'git://github.com/rails/rails.git'
-
gem 'sqlite3'
-
gem 'json'
+gem 'markdown-rails' # allows static pages with .md
+gem 'haml' # allow pages with .haml
+gem 'RedCloth' # allow :textile in HAML
+gem 'sass-rails' # not sure why can't be in :assets group
+
# Gems used only for assets and not required
# in production environments by default.
group :assets do
- gem 'sass-rails' #, '~> 3.2.3'
- gem 'haml'
- gem 'RedCloth'
-
- # see https://github.com/iain/http_accept_language
- #gem 'http_accept_language'
- #gem 'http_accept_language', '>= 2.0.0.pre'
-
gem 'uglifier', '>= 1.0.3'
- gem 'execjs'
- # See https://github.com/sstephenson/execjs#readme for more supported runtimes
+ gem 'execjs' # See https://github.com/sstephenson/execjs#readme for supported runtimes
gem 'therubyrhino'
end
gem 'jquery-rails'
-
-# To use ActiveModel has_secure_password
-# gem 'bcrypt-ruby', '~> 3.0.0'
-
-# To use Jbuilder templates for JSON
-# gem 'jbuilder'
-
-# Use unicorn as the web server
-# gem 'unicorn'
-
-# Deploy with Capistrano
-gem 'capistrano'
-
-# To use debugger
-# gem 'ruby-debug'
-
-# allows static pages with .md
-gem 'markdown-rails'
-
-gem 'sass'
+gem 'capistrano' # deploy with Capistrano
group :development do
gem 'thin'
diff --git a/Gemfile.lock b/Gemfile.lock
index 0f987e9..cfda894 100644
--- a/Gemfile.lock
+++ b/Gemfile.lock
@@ -134,7 +134,6 @@ DEPENDENCIES
json
markdown-rails
rails (= 3.2.12)
- sass
sass-rails
sqlite3
therubyrhino
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|
diff --git a/config/environments/production.rb b/config/environments/production.rb
index 49c5009..815463c 100644
--- a/config/environments/production.rb
+++ b/config/environments/production.rb
@@ -10,7 +10,7 @@ LeapPublicSite::Application.configure do
# Make rails server static assets if we are running Mongrel or WEBrick,
# otherwise, let apache do it.
- config.serve_static_assets = config.serve_static_assets = ( defined?(Mongrel) || defined?(WEBrick) ) ? true : false
+ config.serve_static_assets = (defined?(Mongrel) || defined?(WEBrick) || defined?(Thin)) ? true : false
# Compress JavaScripts and CSS
config.assets.compress = true
diff --git a/lib/menu.rb b/lib/menu.rb
index c156e07..4da8441 100644
--- a/lib/menu.rb
+++ b/lib/menu.rb
@@ -31,7 +31,7 @@ class Menu
#
def submenu(item_name=nil)
if item_name
- self.children.detect {|child| child.name == item_name} || Menu.new
+ self.children.detect {|child| child.name == item_name}
else
self.children
end