diff --git a/.gitignore b/.gitignore index f60933a3c1..f465ad7306 100644 --- a/.gitignore +++ b/.gitignore @@ -15,6 +15,7 @@ tmp/ .#* *~ *.~lock.* +tags .emacs.desktop .DS_Store *.sublime-project* @@ -36,5 +37,4 @@ config/initializers/feature_toggle.rb NERD_tree* coverage libpeerconnection.log -tags -app/assets/javascripts/tags +/config/application.yml diff --git a/Gemfile b/Gemfile index 4fec11abeb..4975ff475b 100644 --- a/Gemfile +++ b/Gemfile @@ -43,6 +43,7 @@ gem 'spinjs-rails' gem 'rack-ssl', :require => 'rack/ssl' gem 'custom_error_message', :github => 'jeremydurham/custom-err-msg' gem 'angularjs-file-upload-rails', '~> 1.1.0' +gem 'figaro' gem 'foreigner' gem 'immigrant' diff --git a/Gemfile.lock b/Gemfile.lock index 4af4129c5b..798e5dee5a 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -244,6 +244,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) @@ -529,6 +532,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/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" + 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 f722c60f1a..dca89955b7 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.