diff options
Diffstat (limited to 'config')
-rw-r--r-- | config/application.rb | 35 | ||||
-rw-r--r-- | config/deploy.rb | 3 | ||||
-rw-r--r-- | config/deploy.yml.example | 2 | ||||
-rw-r--r-- | config/environments/development.rb | 14 | ||||
-rw-r--r-- | config/environments/production.rb | 17 | ||||
-rw-r--r-- | config/environments/test.rb | 5 | ||||
-rw-r--r-- | config/general.yml-example | 5 | ||||
-rw-r--r-- | config/initializers/acts_as_xapian.rb | 25 | ||||
-rw-r--r-- | config/initializers/alaveteli.rb | 2 | ||||
-rw-r--r-- | config/initializers/has_tag_string.rb | 2 | ||||
-rw-r--r-- | config/initializers/strip_attributes.rb | 2 | ||||
-rw-r--r-- | config/initializers/theme_loader.rb | 4 | ||||
-rw-r--r-- | config/packages | 1 | ||||
-rw-r--r-- | config/test.yml | 2 |
14 files changed, 113 insertions, 6 deletions
diff --git a/config/application.rb b/config/application.rb index 92fd30685..dba3a0c57 100644 --- a/config/application.rb +++ b/config/application.rb @@ -6,7 +6,7 @@ require File.dirname(__FILE__) + '/../lib/configuration' # If you have a Gemfile, require the gems listed there, including any gems # you've limited to :test, :development, or :production. -Bundler.require(:default, Rails.env) if defined?(Bundler) +Bundler.require(:default, :assets, Rails.env) if defined?(Bundler) module Alaveteli class Application < Rails::Application @@ -31,6 +31,7 @@ module Alaveteli # The default locale is :en and all translations from config/locales/*.rb,yml are auto loaded. # config.i18n.load_path += Dir[Rails.root.join('my', 'locales', '*.{rb,yml}').to_s] # config.i18n.default_locale = :de + I18n.config.enforce_available_locales = false # JavaScript files you want as :defaults (application.js is always included). # config.action_view.javascript_expansions[:defaults] = %w(jquery rails) @@ -55,6 +56,10 @@ module Alaveteli # will be in this time zone config.time_zone = ::AlaveteliConfiguration::time_zone + # Set the cache to use a memcached backend + config.cache_store = :mem_cache_store, { :namespace => AlaveteliConfiguration::domain } + config.action_dispatch.rack_cache = nil + config.after_initialize do |app| require 'routing_filters.rb' # Add a catch-all route to force routing errors to be handled by the application, @@ -70,6 +75,32 @@ module Alaveteli # Insert a bit of middleware code to prevent uneeded cookie setting. require "#{Rails.root}/lib/whatdotheyknow/strip_empty_sessions" - config.middleware.insert_before ActionDispatch::Session::CookieStore, WhatDoTheyKnow::StripEmptySessions, :key => '_wdtk_cookie_session', :path => "/", :httponly => true + config.middleware.insert_before ::ActionDispatch::Cookies, WhatDoTheyKnow::StripEmptySessions, :key => '_wdtk_cookie_session', :path => "/", :httponly => true + + # Enable the asset pipeline + config.assets.enabled = true + + # Version of your assets, change this if you want to expire all your assets + config.assets.version = '1.0' + + # Change the path that assets are served from + # config.assets.prefix = "/assets" + + # These additional precompiled Javascript files are actually + # manifests that require the real javascript files: + config.assets.precompile += ['admin.js', + 'profile-photos.js', + 'stats.js'] + # ... while these are individual files that can't easily be + # grouped: + config.assets.precompile += ['jquery.fancybox-1.3.4.pack.js', + 'jquery.Jcrop.css', + 'excanvas.min.js', + 'fonts.css', + 'print.css', + 'admin.css', + 'ie6.css', + 'ie7.css'] + end end diff --git a/config/deploy.rb b/config/deploy.rb index d26a199c8..a0189c855 100644 --- a/config/deploy.rb +++ b/config/deploy.rb @@ -13,6 +13,7 @@ set :git_enable_submodules, true set :deploy_to, configuration['deploy_to'] set :user, configuration['user'] set :use_sudo, false +set :rails_env, configuration['rails_env'] server configuration['server'], :app, :web, :db, :primary => true @@ -57,7 +58,7 @@ namespace :deploy do "#{release_path}/public/favicon.ico" => "#{shared_path}/favicon.ico", "#{release_path}/files" => "#{shared_path}/files", "#{release_path}/cache" => "#{shared_path}/cache", - "#{release_path}/vendor/plugins/acts_as_xapian/xapiandbs" => "#{shared_path}/xapiandbs", + "#{release_path}/lib/acts_as_xapian/xapiandbs" => "#{shared_path}/xapiandbs", } # "ln -sf <a> <b>" creates a symbolic link but deletes <b> if it already exists diff --git a/config/deploy.yml.example b/config/deploy.yml.example index 61931e50e..a20eb3c22 100644 --- a/config/deploy.yml.example +++ b/config/deploy.yml.example @@ -4,10 +4,12 @@ production: branch: master server: www.example.com user: deploy + rails_env: production deploy_to: /srv/www/alaveteli_production staging: repository: git://github.com/mysociety/alaveteli.git branch: develop server: test.example.com user: deploy + rails_env: production deploy_to: /srv/www/alaveteli_staging diff --git a/config/environments/development.rb b/config/environments/development.rb index a912dd5de..dbf8d7b2a 100644 --- a/config/environments/development.rb +++ b/config/environments/development.rb @@ -32,4 +32,18 @@ Alaveteli::Application.configure do # Print deprecation notices to the Rails logger config.active_support.deprecation = :log + + # Do not compress assets + config.assets.compress = false + + # Expands the lines which load the assets + config.assets.debug = true + + # Raise exception on mass assignment protection for Active Record models + config.active_record.mass_assignment_sanitizer = :strict + + # Log the query plan for queries taking more than this (works + # with SQLite, MySQL, and PostgreSQL) + config.active_record.auto_explain_threshold_in_seconds = 0.5 + end diff --git a/config/environments/production.rb b/config/environments/production.rb index 0c1929366..a3e3cebd2 100644 --- a/config/environments/production.rb +++ b/config/environments/production.rb @@ -31,4 +31,21 @@ Alaveteli::Application.configure do if AlaveteliConfiguration::force_ssl config.middleware.insert_before ActionDispatch::Cookies, ::Rack::SSL end + + # Compress JavaScripts and CSS + config.assets.compress = true + + # Choose the compressors to use + # config.assets.js_compressor = :uglifier + # config.assets.css_compressor = :yui + + # Don't fallback to assets pipeline if a precompiled asset is missed + config.assets.compile = false + + # Generate digests for assets URLs. + config.assets.digest = true + + # Precompile additional assets (application.js, application.css, and all non-JS/CSS are already added) + # config.assets.precompile += %w( search.js ) + end diff --git a/config/environments/test.rb b/config/environments/test.rb index df39e8873..97c2d4f7c 100644 --- a/config/environments/test.rb +++ b/config/environments/test.rb @@ -24,4 +24,9 @@ Alaveteli::Application.configure do # Print deprecation notices to the stderr config.active_support.deprecation = :stderr + if !AlaveteliConfiguration.exception_notifications_from.blank? && !AlaveteliConfiguration.exception_notifications_to.blank? + middleware.use ExceptionNotifier, + :sender_address => AlaveteliConfiguration::exception_notifications_from, + :exception_recipients => AlaveteliConfiguration::exception_notifications_to + end end diff --git a/config/general.yml-example b/config/general.yml-example index 60eb5ae1c..b8d9fc854 100644 --- a/config/general.yml-example +++ b/config/general.yml-example @@ -209,3 +209,8 @@ PUBLIC_BODY_LIST_FALLBACK_TO_DEFAULT_LOCALE: false # If true, while in development mode, try to send mail by SMTP to port # 1025 (the port the mailcatcher listens on by default): USE_MAILCATCHER_IN_DEVELOPMENT: true + +# Use memcached to cache HTML fragments for better performance. Will +# only have an effect in environments where +# config.action_controller.perform_caching is set to true +CACHE_FRAGMENTS: true diff --git a/config/initializers/acts_as_xapian.rb b/config/initializers/acts_as_xapian.rb new file mode 100644 index 000000000..f82193c85 --- /dev/null +++ b/config/initializers/acts_as_xapian.rb @@ -0,0 +1,25 @@ +# acts_as_xapian/init.rb: +# +# Copyright (c) 2008 UK Citizens Online Democracy. All rights reserved. +# Email: hello@mysociety.org; WWW: http://www.mysociety.org/ + +# We're moving plugins out of vendor/plugins, since keeping them there +# is deprecated as of Rails 3.2, and the xapiandbs directory should be +# moved out of there along with the plugin itself. + +old_xapiandbs_path = Rails.root.join('vendor', + 'plugins', + 'acts_as_xapian', + 'xapiandbs') + +current_xapiandbs_path = Rails.root.join('lib', + 'acts_as_xapian', + 'xapiandbs') + +if File.exists? old_xapiandbs_path + unless File.exists? current_xapiandbs_path + File.rename old_xapiandbs_path, current_xapiandbs_path + end +end + +require 'acts_as_xapian/acts_as_xapian' diff --git a/config/initializers/alaveteli.rb b/config/initializers/alaveteli.rb index 5171c052f..631251b87 100644 --- a/config/initializers/alaveteli.rb +++ b/config/initializers/alaveteli.rb @@ -10,7 +10,7 @@ load "debug_helpers.rb" load "util.rb" # Application version -ALAVETELI_VERSION = '0.14' +ALAVETELI_VERSION = '0.15' # Add new inflection rules using the following format # (all these examples are active by default): diff --git a/config/initializers/has_tag_string.rb b/config/initializers/has_tag_string.rb new file mode 100644 index 000000000..5fa33cc70 --- /dev/null +++ b/config/initializers/has_tag_string.rb @@ -0,0 +1,2 @@ +require 'has_tag_string/has_tag_string' + diff --git a/config/initializers/strip_attributes.rb b/config/initializers/strip_attributes.rb new file mode 100644 index 000000000..25f70b2f3 --- /dev/null +++ b/config/initializers/strip_attributes.rb @@ -0,0 +1,2 @@ +require 'strip_attributes/strip_attributes' +ActiveRecord::Base.extend(StripAttributes) diff --git a/config/initializers/theme_loader.rb b/config/initializers/theme_loader.rb index b3ae11e1e..9c79e513c 100644 --- a/config/initializers/theme_loader.rb +++ b/config/initializers/theme_loader.rb @@ -3,7 +3,9 @@ $alaveteli_route_extensions = [] def require_theme(theme_name) - theme_main_include = File.expand_path "../../../vendor/plugins/#{theme_name}/lib/alavetelitheme.rb", __FILE__ + theme_lib = Rails.root.join 'lib', 'themes', theme_name, 'lib' + $LOAD_PATH.unshift theme_lib.to_s + theme_main_include = Rails.root.join theme_lib, "alavetelitheme.rb" if File.exists? theme_main_include require theme_main_include end diff --git a/config/packages b/config/packages index 8bb00a849..9a07c5f20 100644 --- a/config/packages +++ b/config/packages @@ -38,3 +38,4 @@ bundler sqlite3 libsqlite3-dev libicu-dev +memcached diff --git a/config/test.yml b/config/test.yml index b26ca99d4..599e1e81a 100644 --- a/config/test.yml +++ b/config/test.yml @@ -116,7 +116,7 @@ HTML_TO_PDF_COMMAND: /usr/local/bin/wkhtmltopdf-amd64 # Exception notifications EXCEPTION_NOTIFICATIONS_FROM: do-not-reply-to-this-address@example.com -EXCEPTION_NOTIFICATIONS_TO: +EXCEPTION_NOTIFICATIONS_TO: exception-recipient@example.com MAX_REQUESTS_PER_USER_PER_DAY: 2 |