From 9448e1cbe4b4c4756d98b9b59d2fd8eb00db659b Mon Sep 17 00:00:00 2001 From: Rafael Schouten Date: Tue, 16 Sep 2014 00:13:43 +1000 Subject: [PATCH 1/3] add figaro env config --- Gemfile | 1 + Gemfile.lock | 4 ++++ ...nfirmation.text.erb => signup_confirmation.text.haml} | 4 ++-- config/application.rb | 4 ++-- config/initializers/secret_token.rb | 8 ++++++-- config/initializers/spree.rb | 9 +++++++-- 6 files changed, 22 insertions(+), 8 deletions(-) rename app/views/spree/user_mailer/{signup_confirmation.text.erb => signup_confirmation.text.haml} (76%) diff --git a/Gemfile b/Gemfile index 456234f554..3f84c28183 100644 --- a/Gemfile +++ b/Gemfile @@ -42,6 +42,7 @@ gem 'gmaps4rails' gem 'spinjs-rails' gem 'rack-ssl', :require => 'rack/ssl' gem 'custom_error_message', :github => 'jeremydurham/custom-err-msg' +gem 'figaro' gem 'foreigner' gem 'immigrant' diff --git a/Gemfile.lock b/Gemfile.lock index 9bb6e501db..94c6ead27a 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -243,6 +243,9 @@ GEM railties (>= 3.0.0) ffaker (1.15.0) ffi (1.9.3) + figaro (0.7.0) + bundler (~> 1.0) + rails (>= 3, < 5) fog (1.14.0) builder excon (~> 0.25.0) @@ -520,6 +523,7 @@ DEPENDENCIES debugger-linecache deface! factory_girl_rails + figaro foreigner foundation-icons-sass-rails foundation-rails diff --git a/app/views/spree/user_mailer/signup_confirmation.text.erb b/app/views/spree/user_mailer/signup_confirmation.text.haml similarity index 76% rename from app/views/spree/user_mailer/signup_confirmation.text.erb rename to app/views/spree/user_mailer/signup_confirmation.text.haml index 295b4c9e8f..3a30b6827e 100644 --- a/app/views/spree/user_mailer/signup_confirmation.text.erb +++ b/app/views/spree/user_mailer/signup_confirmation.text.haml @@ -1,6 +1,6 @@ Hello, -Welcome to Australia's Open Food Network! Your login email is <%= @user.email %> +Welcome to #{ENV['DEFAULT_COUNTRY']}'s Open Food Network! Your login email is #{@user.email} You can go online and start shopping through food hubs and local producers you like at http://openfoodnetwork.org.au @@ -9,5 +9,5 @@ We welcome all your questions and feedback; you can use the Send Feedback button Thanks for getting on board and we look forward to introducing you to many more great farmers, food hubs and food! Cheers, -Kirsten Larsen and the OFN Team +#{ENV['CONTACT_STRING']} diff --git a/config/application.rb b/config/application.rb index 1cddfcf3a1..d3bbdbf3fd 100644 --- a/config/application.rb +++ b/config/application.rb @@ -57,11 +57,11 @@ module Openfoodnetwork # Set Time.zone default to the specified zone and make Active Record auto-convert to this zone. # Run "rake -D time" for a list of tasks for finding time zone names. Default is UTC. - config.time_zone = 'Melbourne' + config.time_zone = ENV["TIMEZONE"] # 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 = 'en' + config.i18n.default_locale = ENV["LOCALE"] # Setting this to true causes a performance regression in Rails 3.2.17 # When we're on a version with the fix below, we can set it to true diff --git a/config/initializers/secret_token.rb b/config/initializers/secret_token.rb index fcd0a6dda4..9aac0efd56 100644 --- a/config/initializers/secret_token.rb +++ b/config/initializers/secret_token.rb @@ -3,5 +3,9 @@ # 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. -Openfoodnetwork::Application.config.secret_token = '6d784d49173d0ec820f20cfce151717bd12570e9d261460e9d3c295b90c1fd81e3843eb1bec79d9e6d4a7f04d0fd76170ca0c326ffb0f2da5b7a0b50c7442a4c' +# no regular words or you'll be exposed to dictionary attacks. +Openfoodnetwork::Application.config.secret_token = if Rails.env.development? or Rails.env.test? + ('x' * 30) # Meets basic minimum of 30 chars. +else + ENV["SECRET_TOKEN"] +end diff --git a/config/initializers/spree.rb b/config/initializers/spree.rb index bbee30379a..8078dac761 100644 --- a/config/initializers/spree.rb +++ b/config/initializers/spree.rb @@ -11,11 +11,16 @@ require 'spree/product_filters' Spree.config do |config| config.shipping_instructions = true - config.checkout_zone = 'Australia' + config.checkout_zone = ENV["CHECKOUT_ZONE"] config.address_requires_state = true # 12 should be Australia. Hardcoded for CI (Jenkins), where countries are not pre-loaded. - config.default_country_id = 12 + if Rails.env.test? or Rails.env.development? + config.default_country_id = 12 + else + country = Spree::Country.find_by_name(ENV["DEFAULT_COUNTRY"]) + config.default_country_id = country.id if country.present? + end # -- spree_paypal_express # Auto-capture payments. Without this option, payments must be manually captured in the paypal interface. From 15bfe75313dc1bad9260d35070da29c11b8a195b Mon Sep 17 00:00:00 2001 From: Rafael Schouten Date: Tue, 16 Sep 2014 00:21:10 +1000 Subject: [PATCH 2/3] ifnore figaro --- .gitignore | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.gitignore b/.gitignore index b587584d3b..8392b92c1a 100644 --- a/.gitignore +++ b/.gitignore @@ -36,3 +36,7 @@ config/initializers/feature_toggle.rb NERD_tree* coverage libpeerconnection.log +tags + +# Ignore application configuration +/config/application.yml From a5680e611e6e8ab4da93b38bbd12b55027d5855b Mon Sep 17 00:00:00 2001 From: Rafael Schouten Date: Wed, 17 Sep 2014 12:05:28 +1000 Subject: [PATCH 3/3] add example yml --- config/application.yml.example | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) create mode 100644 config/application.yml.example diff --git a/config/application.yml.example b/config/application.yml.example new file mode 100644 index 0000000000..986e1c9e22 --- /dev/null +++ b/config/application.yml.example @@ -0,0 +1,16 @@ +# Add application configuration variables here, as shown below. +# +# Change this, it has serious security implications. +# Minimum 30 but usually 128 characters. To obtain run 'rake secret', or faster, 'openssl rand -hex 128' +SECRET_TOKEN: "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" + +TIMEZONE: "Melbourne" +# Default country for dropdowns etc. +DEFAULT_COUNTRY: "Australia" +# Locale for translation. +I18N_LOCALE: "en" +# Spree zone. +CHECKOUT_ZONE: "Australia" +# Contact name for emails. +CONTACT_STRING: "Joe Bloggs and the OFN Team" +