diff options
Diffstat (limited to 'config/initializers')
-rw-r--r-- | config/initializers/alaveteli.rb | 87 | ||||
-rw-r--r-- | config/initializers/backtrace_silencers.rb | 7 | ||||
-rw-r--r-- | config/initializers/gettext_i18n_rails.rb | 3 | ||||
-rw-r--r-- | config/initializers/inflections.rb | 10 | ||||
-rw-r--r-- | config/initializers/mime_types.rb | 5 | ||||
-rw-r--r-- | config/initializers/secret_token.rb | 7 | ||||
-rw-r--r-- | config/initializers/session_store.rb | 17 | ||||
-rw-r--r-- | config/initializers/single_quote_escape_workaround.rb | 31 |
8 files changed, 120 insertions, 47 deletions
diff --git a/config/initializers/alaveteli.rb b/config/initializers/alaveteli.rb new file mode 100644 index 000000000..5ce519829 --- /dev/null +++ b/config/initializers/alaveteli.rb @@ -0,0 +1,87 @@ +if RUBY_VERSION.to_f >= 1.9 + # the default encoding for IO is utf-8, and we use utf-8 internally + Encoding.default_external = Encoding.default_internal = Encoding::UTF_8 + # Suppress warning messages and require inflector to avoid iconv deprecation message + # "iconv will be deprecated in the future, use String#encode instead." when loading + # it as part of rails + original_verbose, $VERBOSE = $VERBOSE, nil + require 'active_support/inflector' + # Activate warning messages again. + $VERBOSE = original_verbose +end + +# MySociety specific helper functions +$:.push(File.join(File.dirname(__FILE__), '../../commonlib/rblib')) +# ... if these fail to include, you need the commonlib submodule from git +# (type "git submodule update --init" in the whatdotheyknow directory) + +load "validate.rb" +load "config.rb" +load "format.rb" +load "debug_helpers.rb" +load "util.rb" + +# Application version +ALAVETELI_VERSION = '0.6.8' + +# Add new inflection rules using the following format +# (all these examples are active by default): +# Inflector.inflections do |inflect| +# inflect.plural /^(ox)$/i, '\1en' +# inflect.singular /^(ox)en/i, '\1' +# inflect.irregular 'person', 'people' +# inflect.uncountable %w( fish sheep ) +# end + +# Add new mime types for use in respond_to blocks: +# Mime::Type.register "text/richtext", :rtf +# Mime::Type.register "application/x-mobile", :mobile + +# The Rails cache is set up by the Interlock plugin to use memcached + +# Domain for URLs (so can work for scripts, not just web pages) +ActionMailer::Base.default_url_options[:host] = Configuration::domain + +# So that javascript assets use full URL, so proxied admin URLs read javascript OK +if (Configuration::domain != "") + ActionController::Base.asset_host = Proc.new { |source, request| + if ENV["RAILS_ENV"] != "test" && request.fullpath.match(/^\/admin\//) + Configuration::admin_public_url + else + Configuration::domain + end + } +end + +# fallback locale and available locales +available_locales = Configuration::available_locales.split(/ /) +default_locale = Configuration::default_locale + +FastGettext.default_available_locales = available_locales +I18n.locale = default_locale +I18n.available_locales = available_locales.map {|locale_name| locale_name.to_sym} +I18n.default_locale = default_locale + +# Customise will_paginate URL generation +WillPaginate::ViewHelpers.pagination_options[:renderer] = 'WillPaginateExtension::LinkRenderer' + +# Load monkey patches and other things from lib/ +require 'ruby19.rb' +require 'activesupport_cache_extensions.rb' +require 'use_spans_for_errors.rb' +require 'make_html_4_compliant.rb' +require 'activerecord_errors_extensions.rb' +require 'willpaginate_extension.rb' +require 'i18n_fixes.rb' +require 'world_foi_websites.rb' +require 'alaveteli_external_command.rb' +require 'quiet_opener.rb' +require 'mail_handler' +require 'public_body_categories' + +# Temporarily commented out the lines below on the Rails 3 spike. +# TODO: Reinstate this properly! +#if !Configuration.exception_notifications_from.blank? && !Configuration.exception_notifications_to.blank? +# ExceptionNotification::Notifier.sender_address = Configuration::exception_notifications_from +# ExceptionNotification::Notifier.exception_recipients = Configuration::exception_notifications_to +#end diff --git a/config/initializers/backtrace_silencers.rb b/config/initializers/backtrace_silencers.rb new file mode 100644 index 000000000..59385cdf3 --- /dev/null +++ b/config/initializers/backtrace_silencers.rb @@ -0,0 +1,7 @@ +# Be sure to restart your server when you modify this file. + +# You can add backtrace silencers for libraries that you're using but don't wish to see in your backtraces. +# Rails.backtrace_cleaner.add_silencer { |line| line =~ /my_noisy_library/ } + +# You can also remove all the silencers if you're trying to debug a problem that might stem from framework code. +# Rails.backtrace_cleaner.remove_silencers! diff --git a/config/initializers/gettext_i18n_rails.rb b/config/initializers/gettext_i18n_rails.rb new file mode 100644 index 000000000..ef306682b --- /dev/null +++ b/config/initializers/gettext_i18n_rails.rb @@ -0,0 +1,3 @@ +# FIXME: Audit the translations for XSS opportunities. Ultimately it would be +# good to get rid of this and explicitly mark strings as html_safe +GettextI18nRails.translations_are_html_safe = true diff --git a/config/initializers/inflections.rb b/config/initializers/inflections.rb new file mode 100644 index 000000000..9e8b0131f --- /dev/null +++ b/config/initializers/inflections.rb @@ -0,0 +1,10 @@ +# Be sure to restart your server when you modify this file. + +# Add new inflection rules using the following format +# (all these examples are active by default): +# ActiveSupport::Inflector.inflections do |inflect| +# inflect.plural /^(ox)$/i, '\1en' +# inflect.singular /^(ox)en/i, '\1' +# inflect.irregular 'person', 'people' +# inflect.uncountable %w( fish sheep ) +# end diff --git a/config/initializers/mime_types.rb b/config/initializers/mime_types.rb new file mode 100644 index 000000000..72aca7e44 --- /dev/null +++ b/config/initializers/mime_types.rb @@ -0,0 +1,5 @@ +# Be sure to restart your server when you modify this file. + +# Add new mime types for use in respond_to blocks: +# Mime::Type.register "text/richtext", :rtf +# Mime::Type.register_alias "text/html", :iphone diff --git a/config/initializers/secret_token.rb b/config/initializers/secret_token.rb new file mode 100644 index 000000000..5277e8927 --- /dev/null +++ b/config/initializers/secret_token.rb @@ -0,0 +1,7 @@ +# Be sure to restart your server when you modify this file. + +# Your secret key for verifying the integrity of signed cookies. +# If you change this key, all old signed cookies will become invalid! +# Make sure the secret is at least 30 characters and all random, +# no regular words or you'll be exposed to dictionary attacks. +Alaveteli::Application.config.secret_token = Configuration::cookie_store_session_secret diff --git a/config/initializers/session_store.rb b/config/initializers/session_store.rb index 8cfa333f2..ca283d4e0 100644 --- a/config/initializers/session_store.rb +++ b/config/initializers/session_store.rb @@ -1,17 +1,2 @@ # Be sure to restart your server when you modify this file. - -# Your secret key for verifying cookie session data integrity. -# If you change this key, all old sessions will become invalid! -# Make sure the secret is at least 30 characters and all random, -# no regular words or you'll be exposed to dictionary attacks. - -ActionController::Base.session = { - :key => '_wdtk_cookie_session', - :secret => Configuration::cookie_store_session_secret -} -ActionController::Base.session_store = :cookie_store - -# Insert a bit of middleware code to prevent uneeded cookie setting. -require "#{Rails.root}/lib/whatdotheyknow/strip_empty_sessions" -ActionController::Dispatcher.middleware.insert_before ActionController::Base.session_store, WhatDoTheyKnow::StripEmptySessions, :key => '_wdtk_cookie_session', :path => "/", :httponly => true - +Rails.application.config.session_store :cookie_store, :key => '_wdtk_cookie_session' diff --git a/config/initializers/single_quote_escape_workaround.rb b/config/initializers/single_quote_escape_workaround.rb deleted file mode 100644 index 2e713b982..000000000 --- a/config/initializers/single_quote_escape_workaround.rb +++ /dev/null @@ -1,31 +0,0 @@ -class ERB
- module Util
-
- if "html_safe exists".respond_to?(:html_safe)
- def html_escape(s)
- s = s.to_s
- if s.html_safe?
- s
- else
- Rack::Utils.escape_html(s).html_safe
- end
- end
- else
- def html_escape(s)
- s = s.to_s
- Rack::Utils.escape_html(s).html_safe
- end
- end
-
- remove_method :h
- alias h html_escape
-
- class << self
- remove_method :html_escape
- remove_method :h
- end
-
- module_function :html_escape
- module_function :h
- end
-end
|