diff --git a/app/assets/javascripts/src/Metamaps.js b/app/assets/javascripts/src/Metamaps.js index a75fdace..bb9ec307 100644 --- a/app/assets/javascripts/src/Metamaps.js +++ b/app/assets/javascripts/src/Metamaps.js @@ -1534,12 +1534,9 @@ Metamaps.Util = { * */ Metamaps.Realtime = { - // this is for the heroku staging environment - //Metamaps.Realtime.socket = io.connect('http://gentle-savannah-1303.herokuapp.com'); - // this is for metamaps.cc - //Metamaps.Realtime.socket = io.connect('http://metamaps.cc:5001'); - // this is for localhost development - //Metamaps.Realtime.socket = io.connect('http://localhost:5001'); + stringForLocalhost: 'http://localhost:5001', + stringForMetamaps: 'http://metamaps.cc:5001', + stringForHeroku: 'http://gentle-savannah-1303.herokuapp.com', socket: null, isOpen: false, changing: false, @@ -1560,7 +1557,9 @@ Metamaps.Realtime = { }); $('body').click(self.close); - self.socket = io.connect('http://gentle-savannah-1303.herokuapp.com'); // io.connect('http://localhost:5001'); + var railsEnv = $('body').data('env'); + var whichToConnect = railsEnv === 'development' ? self.stringForLocalhost : self.stringForHeroku; + self.socket = io.connect(whichToConnect); self.startActiveMap(); }, toggleBox: function (event) { diff --git a/app/views/layouts/application.html.erb b/app/views/layouts/application.html.erb index 3e56695e..1073c805 100644 --- a/app/views/layouts/application.html.erb +++ b/app/views/layouts/application.html.erb @@ -26,7 +26,7 @@ - + <% if notice %>

<%= notice %>

diff --git a/app/workers/grab_map_screenshot_worker.rb b/app/workers/grab_map_screenshot_worker.rb index c7a7a8f0..b3d97e4f 100644 --- a/app/workers/grab_map_screenshot_worker.rb +++ b/app/workers/grab_map_screenshot_worker.rb @@ -3,7 +3,7 @@ class GrabMapScreenshotWorker include Sidekiq::Worker def perform(map_id) - imgBase64 = `phantomjs ./script/phantomjs-save-screenshot.js #{map_id}` + imgBase64 = `phantomjs ./script/phantomjs-save-screenshot.js #{map_id} #{Rails.env}` map = Map.find(map_id) map.decode_base64(imgBase64) end diff --git a/script/phantomjs-save-screenshot.js b/script/phantomjs-save-screenshot.js index a8bfdf04..5ca47835 100755 --- a/script/phantomjs-save-screenshot.js +++ b/script/phantomjs-save-screenshot.js @@ -8,7 +8,9 @@ if (args.length <= 1) { //configurable variables - CHANGE ME var mapID = args[1]; -var url = 'http://metamaps.herokuapp.com/maps/' + mapID; +var environment = args[2]; +var address = environment === 'development' ? 'http://localhost:3000' : 'http://metamaps.herokuapp.com'; +var url = address + '/maps/' + mapID; var width = 940; var height = 630;