From 961b487fac0a16fabd19a10be95c078258321141 Mon Sep 17 00:00:00 2001 From: Piotr Sarnacki Date: Tue, 3 Feb 2015 17:20:04 +0100 Subject: [PATCH] Change a way config is updated The ENV viarable that is exported in app/config/environment.js is saved as JSON in tag in index.html. In order to properly set the settings from the app we need to get it from there, update the JSON and write it back --- app/index.html | 4 ---- waiter/lib/travis/web/app.rb | 38 +++++++++++++++++++++--------------- 2 files changed, 22 insertions(+), 20 deletions(-) diff --git a/app/index.html b/app/index.html index c836d983..acba4eaa 100644 --- a/app/index.html +++ b/app/index.html @@ -13,10 +13,6 @@ {{content-for 'head-footer'}} - - {{content-for 'body'}} diff --git a/waiter/lib/travis/web/app.rb b/waiter/lib/travis/web/app.rb index 0ccb2693..900ff9a0 100644 --- a/waiter/lib/travis/web/app.rb +++ b/waiter/lib/travis/web/app.rb @@ -158,27 +158,33 @@ class Travis::Web::App end def set_config(string, opts = {}) - p options + # TODO: clean up config = {} - config[:api_endpoint] = options[:api_endpoint] if options[:api_endpoint] - config[:pages_endpoint] = options[:pages_endpoint] if options[:pages_endpoint] - config[:billing_endpoint] = options[:billing_endpoint] if options[:billing_endpoint] - config[:source_endpoint] = options[:source_endpoint] if options[:source_endpoint] + config['api_endpoint'] = options[:api_endpoint] if options[:api_endpoint] + config['pages_endpoint'] = options[:pages_endpoint] if options[:pages_endpoint] + config['billing_endpoint'] = options[:billing_endpoint] if options[:billing_endpoint] + config['source_endpoint'] = options[:source_endpoint] if options[:source_endpoint] pusher = {} - pusher[:key] = options[:pusher_key] if options[:pusher_key] - pusher[:host] = options[:pusher_host] if options[:pusher_host] - pusher[:path] = options[:pusher_path] if options[:pusher_path] - config[:pusher] = pusher + pusher['key'] = options[:pusher_key] if options[:pusher_key] + pusher['host'] = options[:pusher_host] if options[:pusher_host] + pusher['path'] = options[:pusher_path] if options[:pusher_path] + config['pusher'] = pusher - config[:ga_code] = options[:ga_code] if options[:ga_code] - config[:pro] = options[:pro] if options[:pro] - config[:enterprise] = options[:enterprise] if options[:enterprise] + config['ga_code'] = options[:ga_code] if options[:ga_code] + config['pro'] = options[:pro] if options[:pro] + config['enterprise'] = options[:enterprise] if options[:enterprise] - config[:code_climate] = options[:code_climate] if options[:code_climate] - config[:code_climate_url] = options[:code_climate_url] if options[:code_climate_url] + config['code_climate'] = options[:code_climate] if options[:code_climate] + config['code_climate_url'] = options[:code_climate_url] if options[:code_climate_url] - json = config.to_json + regexp = %r(