Change a way config is updated
The ENV viarable that is exported in app/config/environment.js is saved as JSON in <meta> 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
This commit is contained in:
parent
bf28f66b44
commit
961b487fac
|
@ -13,10 +13,6 @@
|
|||
<link rel="stylesheet" href="assets/travis.css">
|
||||
|
||||
{{content-for 'head-footer'}}
|
||||
|
||||
<script>
|
||||
window.TravisENV = {};
|
||||
</script>
|
||||
</head>
|
||||
<body>
|
||||
{{content-for 'body'}}
|
||||
|
|
|
@ -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(<meta name="travis/config/environment"\s+content="([^"]+)")
|
||||
string.gsub!(regexp) do
|
||||
ember_config = JSON.parse(URI.unescape($1))
|
||||
|
||||
string.gsub! /window.TravisENV = {}/, "window.TravisENV = #{json}"
|
||||
config = ember_config.merge config
|
||||
config = URI.escape config.to_json
|
||||
|
||||
%(<meta name="travis/config/environment" content="#{config}")
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue
Block a user