diff options
Diffstat (limited to 'lib')
-rw-r--r-- | lib/alaveteli_external_command.rb | 5 | ||||
-rw-r--r-- | lib/configuration.rb | 64 | ||||
-rw-r--r-- | lib/tasks/themes.rake | 8 |
3 files changed, 69 insertions, 8 deletions
diff --git a/lib/alaveteli_external_command.rb b/lib/alaveteli_external_command.rb index 7d32be904..3bfc34e3a 100644 --- a/lib/alaveteli_external_command.rb +++ b/lib/alaveteli_external_command.rb @@ -14,16 +14,15 @@ module AlaveteliExternalCommand if program_name =~ %r(^/) program_path = program_name else - utility_search_path = MySociety::Config.get("UTILITY_SEARCH_PATH", ["/usr/bin", "/usr/local/bin"]) found = false - utility_search_path.each do |d| + Configuration::utility_search_path.each do |d| program_path = File.join(d, program_name) if File.file? program_path and File.executable? program_path found = true break end end - raise "Could not find #{program_name} in any of #{utility_search_path.join(', ')}" if !found + raise "Could not find #{program_name} in any of #{Configuration::utility_search_path.join(', ')}" if !found end xc = ExternalCommand.new(program_path, *args) diff --git a/lib/configuration.rb b/lib/configuration.rb new file mode 100644 index 000000000..03ca62343 --- /dev/null +++ b/lib/configuration.rb @@ -0,0 +1,64 @@ +# Configuration values with defaults + +# TODO: Make this return different values depending on the current rails environment + +module Configuration + DEFAULTS = { + :ADMIN_BASE_URL => '/admin/', + :ADMIN_PASSWORD => '', + :ADMIN_PUBLIC_URL => '', + :ADMIN_USERNAME => '', + :AVAILABLE_LOCALES => '', + :BLACKHOLE_PREFIX => 'do-not-reply-to-this-address', + :BLOG_FEED => '', + :CONTACT_EMAIL => 'contact@localhost', + :CONTACT_NAME => 'Alaveteli', + :COOKIE_STORE_SESSION_SECRET => 'this default is insecure as code is open source, please override for live sites in config/general; this will do for local development', + :DEBUG_RECORD_MEMORY => false, + :DEFAULT_LOCALE => '', + :DOMAIN => 'localhost:3000', + :EXCEPTION_NOTIFICATIONS_FROM => nil, + :EXCEPTION_NOTIFICATIONS_TO => nil, + :FORCE_REGISTRATION_ON_NEW_REQUEST => false, + :FORWARD_NONBOUNCE_RESPONSES_TO => 'user-support@localhost', + :FRONTPAGE_PUBLICBODY_EXAMPLES => '', + :GA_CODE => '', + :GAZE_URL => '', + :HTML_TO_PDF_COMMAND => nil, + :INCOMING_EMAIL_DOMAIN => 'localhost', + :INCOMING_EMAIL_PREFIX => '', + :INCOMING_EMAIL_SECRET => 'dummysecret', + :ISO_COUNTRY_CODE => 'GB', + :MAX_REQUESTS_PER_USER_PER_DAY => nil, + :NEW_RESPONSE_REMINDER_AFTER_DAYS => [3, 10, 24], + :RAW_EMAILS_LOCATION => 'files/raw_emails', + :READ_ONLY => '', + :RECAPTCHA_PRIVATE_KEY => 'x', + :RECAPTCHA_PUBLIC_KEY => 'x', + :REPLY_LATE_AFTER_DAYS => 20, + :REPLY_VERY_LATE_AFTER_DAYS => 40, + :SITE_NAME => 'Alaveteli', + :SKIP_ADMIN_AUTH => false, + :SPECIAL_REPLY_VERY_LATE_AFTER_DAYS => 60, + :THEME_URL => "", + :THEME_URLS => [], + :TRACK_SENDER_EMAIL => 'contact@localhost', + :TRACK_SENDER_NAME => 'Alaveteli', + :TWITTER_USERNAME => '', + :USE_DEFAULT_BROWSER_LANGUAGE => true, + :USE_GHOSTSCRIPT_COMPRESSION => nil, + :UTILITY_SEARCH_PATH => ["/usr/bin", "/usr/local/bin"], + :VARNISH_HOST => nil, + :WORKING_OR_CALENDAR_DAYS => 'working', + } + + def Configuration.method_missing(name) + key = name.to_s.upcase + if DEFAULTS.has_key?(key.to_sym) + MySociety::Config.get(key, DEFAULTS[key.to_sym]) + else + super + end + end +end + diff --git a/lib/tasks/themes.rake b/lib/tasks/themes.rake index 6eb64b4b0..f06cf6312 100644 --- a/lib/tasks/themes.rake +++ b/lib/tasks/themes.rake @@ -86,12 +86,10 @@ namespace :themes do desc "Install themes specified in the config file's THEME_URLS" task :install => :environment do verbose = true - theme_urls = MySociety::Config.get("THEME_URLS", []) - theme_urls.each{ |theme_url| install_theme(theme_url, verbose) } - theme_url = MySociety::Config.get("THEME_URL", "") - if ! theme_url.blank? + Configuration::theme_urls.each{ |theme_url| install_theme(theme_url, verbose) } + if ! Configuration::theme_url.blank? # Old version of the above, for backwards compatibility - install_theme(theme_url, verbose, deprecated=true) + install_theme(Configuration::theme_url, verbose, deprecated=true) end end end
\ No newline at end of file |