diff --git a/Procfile b/Procfile new file mode 100644 index 00000000..3a5d09e8 --- /dev/null +++ b/Procfile @@ -0,0 +1,2 @@ +web: bundle exec rails server -p $PORT +worker: bundle exec sidekiq -c 5 -v \ No newline at end of file diff --git a/app/assets/images/missing-map.png b/app/assets/images/missing-map.png new file mode 100644 index 00000000..5a51221a Binary files /dev/null and b/app/assets/images/missing-map.png differ diff --git a/app/assets/javascripts/src/Metamaps.Backbone.js b/app/assets/javascripts/src/Metamaps.Backbone.js index edc87d12..dd9d5cfb 100644 --- a/app/assets/javascripts/src/Metamaps.Backbone.js +++ b/app/assets/javascripts/src/Metamaps.Backbone.js @@ -72,6 +72,7 @@ Metamaps.Backbone.Map = Backbone.Model.extend({ topic_count_string: this.get('topic_count') == 1 ? ' topic' : ' topics', synapse_count_number: '' + this.get('synapse_count') + '', synapse_count_string: this.get('synapse_count') == 1 ? ' synapse' : ' synapses', + screenshot: '' }; return obj; } diff --git a/app/assets/javascripts/src/Metamaps.JIT.js b/app/assets/javascripts/src/Metamaps.JIT.js index d0d4c70c..29e08dce 100644 --- a/app/assets/javascripts/src/Metamaps.JIT.js +++ b/app/assets/javascripts/src/Metamaps.JIT.js @@ -7,7 +7,7 @@ Metamaps.JIT = { newSynapse: 'Metamaps:JIT:events:newSynapse', removeSynapse: 'Metamaps:JIT:events:removeSynapse', pan: 'Metamaps:JIT:events:pan', - zoom: 'Metamaps:JIT:events:zoom' + zoom: 'Metamaps:JIT:events:zoom', animationDone: 'Metamaps:JIT:events:animationDone', }, vizData: [], // contains the visualization-compatible graph @@ -230,7 +230,7 @@ Metamaps.JIT = { duration: 800, onComplete: function () { Metamaps.Visualize.mGraph.busy = false; - $(document).trigger(Metamaps.JIT.events.animationDone, [event]); + $(document).trigger(Metamaps.JIT.events.animationDone); } }, animateFDLayout: { diff --git a/app/models/map.rb b/app/models/map.rb index 87fb358d..3d6591e5 100644 --- a/app/models/map.rb +++ b/app/models/map.rb @@ -13,8 +13,9 @@ class Map < ActiveRecord::Base # This method associates the attribute ":image" with a file attachment has_attached_file :screenshot, :styles => { :thumb => ['188x126#', :png], - :full => ['1880x1260#', :png] - } + :full => ['940x630#', :png] + }, + :default_url => "/assets/missing-map.png" # Validate the attached image is image/jpg, image/png, etc validates_attachment_content_type :screenshot, :content_type => /\Aimage\/.*\Z/ @@ -64,6 +65,10 @@ class Map < ActiveRecord::Base self.contributors.length end + def screenshot_url + self.screenshot.url(:thumb) + end + def created_at_str self.created_at.strftime("%m/%d/%Y") end @@ -73,7 +78,7 @@ class Map < ActiveRecord::Base end def as_json(options={}) - json = super(:methods =>[:user_name, :user_image, :topic_count, :synapse_count, :contributor_count], :except => [:created_at, :updated_at]) + json = super(:methods =>[:user_name, :user_image, :topic_count, :synapse_count, :contributor_count, :screenshot_url], :except => [:screenshot_content_type, :screenshot_file_size, :screenshot_file_name, :screenshot_updated_at, :created_at, :updated_at]) json[:created_at] = self.created_at_str json[:updated_at] = self.updated_at_str json @@ -118,4 +123,19 @@ class Map < ActiveRecord::Base GrabMapScreenshotWorker.perform_async(self.id) end + def decode_base64(imgBase64) + decoded_data = Base64.decode64(imgBase64) + + data = StringIO.new(decoded_data) + data.class_eval do + attr_accessor :content_type, :original_filename + end + + data.content_type = "image/png" + data.original_filename = File.basename(self.id.to_s + '-' + 'screenshot.png') + + self.screenshot = data + self.save + end + end diff --git a/app/views/layouts/_templates.html.erb b/app/views/layouts/_templates.html.erb index fd02f3e9..a25999cb 100644 --- a/app/views/layouts/_templates.html.erb +++ b/app/views/layouts/_templates.html.erb @@ -46,8 +46,8 @@ {{name}}
- -
+ {{{screenshot}}} +
{{desc}} diff --git a/app/workers/grab_map_screenshot_worker.rb b/app/workers/grab_map_screenshot_worker.rb index 730d4a7d..71fe2441 100644 --- a/app/workers/grab_map_screenshot_worker.rb +++ b/app/workers/grab_map_screenshot_worker.rb @@ -6,12 +6,8 @@ class GrabMapScreenshotWorker imgBase64 = '' Phantomjs.run('./script/phantomjs-save-screenshot.js', map_id.to_s) { |line| imgBase64 << line - puts line } - - #this doesn't work yet - #map = Map.find(map_id) - #map.add_attachment(imgBase64) - #map.save! + map = Map.find(map_id) + map.decode_base64(imgBase64) end end diff --git a/diff.txt b/diff.txt deleted file mode 100644 index badb2420..00000000 --- a/diff.txt +++ /dev/null @@ -1,130 +0,0 @@ - - -diff --git a/app/assets/stylesheets/application.css b/app/assets/stylesheets/application.css -index bb0edb6..bb56ab0 100644 ---- a/app/assets/stylesheets/application.css -+++ b/app/assets/stylesheets/application.css -@@ -74,8 +74,9 @@ body, - /* forgot password fix */ - - .forgotPassword input[type="submit"] { -- padding: 0 5px; -- width: auto; -+ width: 300px; -+ color: #f5f5f5; -+ font-family: din-regular; - } - html { - -@@ -189,36 +190,55 @@ input[type="submit"]:active { - border-radius: 5px; - color: black; - box-shadow: 6px 6px 8px rgba(0, 0, 0, 0.4); -+ position:absolute; - top: 50%; - left:50%; -- position:absolute; -- margin-left: -166px; -+ - } -+ - .forgotPassword { - height: 134px; - margin-top: -83px; -+ font-family: din-medium; -+ color:#424242; -+ text-transform: uppercase; -+ box-shadow: 0px 3px 3px rgba(0, 0, 0, 0.23), 0px 3px 3px rgba(0, 0, 0, 0.16); -+ font-size: 17px; -+ margin-left: -166px; -+ -+} -+ -+.emailText { -+ font-family: din-regular; -+ font-size: 14px; -+ color:#424242; -+ padding-top:24px; -+ padding-bottom: 6px; -+ text-transform: none; -+ margin: 0px; - } - .centerGreyForm input[type="text"], - .centerGreyForm input[type="email"], - .centerGreyForm input[type="password"] { -- width: 250px; -+ width: 300px; - height: 32px; - font-size: 15px; - direction: ltr; - -webkit-appearance: none; - appearance: none; - display: inline-block; -- margin: 0; -- padding: 0 8px; -+ margin: 0px 0px 6px 0px; -+ padding: 10px 0px 0px 9px; - background: #fff; -+ color: #bdbdbd; - border: 1px solid #d9d9d9; - border-top: 1px solid #c0c0c0; - -webkit-box-sizing: border-box; - -moz-box-sizing: border-box; - box-sizing: border-box; -- -webkit-border-radius: 1px; -- -moz-border-radius: 1px; -- border-radius: 1px; -+ -webkit-border-radius: 2px; -+ -moz-border-radius: 2px; -+ border-radius: 2px; - font: -webkit-small-control; - color: initial; - letter-spacing: normal; -@@ -227,8 +247,10 @@ input[type="submit"]:active { - text-indent: 0px; - text-shadow: none; - display: inline-block; -- text-align: start; -+ font: din-medium; -+ text-align: left; - } -+ - .centerGreyForm input[type="text"]:hover, - .centerGreyForm input[type="email"]:hover, - .centerGreyForm input[type="password"]:hover { -@@ -237,7 +259,9 @@ input[type="submit"]:active { - -webkit-box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.1); - -moz-box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.1); - box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.1); -+ color: #424242; - } -+ - .new_topic { - /* start it off screen while it initializes the spinner, then it will be hidden with jquery */ - top: -1000px; -diff --git a/app/views/users/edit.html.erb b/app/views/users/edit.html.erb -index 738d5c6..70d6de7 100644 ---- a/app/views/users/edit.html.erb -+++ b/app/views/users/edit.html.erb -@@ -17,4 +17,3 @@ - <%= form.submit "Update", class: "update" %> - <% end %> -
-- -diff --git a/app/views/users/passwords/new.html.erb b/app/views/users/passwords/new.html.erb -index 88dddb4..3238a81 100644 ---- a/app/views/users/passwords/new.html.erb -+++ b/app/views/users/passwords/new.html.erb -@@ -6,10 +6,10 @@ - -

FORGOT PASSWORD?

- --
<%= f.label :email, "Enter Your Email:" %> -+
<%= f.label :email, "Enter your email:", :class => "emailText" %> - <%= f.email_field :email, :autofocus => true %>
- --
<%= f.submit "Send Reset Password Instructions" %>
-+
<%= f.submit "Send Password Reset Instructions" %>
- - <% end %> -
diff --git a/script/phantomjs-save-screenshot.js b/script/phantomjs-save-screenshot.js index f79a894e..c945bb7a 100755 --- a/script/phantomjs-save-screenshot.js +++ b/script/phantomjs-save-screenshot.js @@ -8,9 +8,9 @@ if (args.length <= 1) { //configurable variables - CHANGE ME var mapID = args[1]; -var url = 'http://localhost:3000/maps/' + mapID; -var width = 188; -var height = 126; +var url = 'http://metamaps.herokuapp.com/maps/' + mapID; +var width = 940; +var height = 630; //set up page and the area we'll render as a PNG var page = require('webpage').create(); @@ -23,25 +23,28 @@ page.open(url, function (status) { if (status === 'success') { //since this isn't evaluateAsync, it should also ensure the asynchronous //js stuff is loaded too, hopefully? + + page.onCallback = function(data){ + + //pass to ruby + console.log(page.renderBase64('PNG')); + + //render to the metamaps_gen002 directory for debug + //page.render('map1.png', 'PNG'); + + phantom.exit(); + }; + page.evaluate(function() { $(document).on(Metamaps.JIT.events.animationDone, function(){ - $('.upperLeftUI, .upperRightUI, .mapControls, .infoAndHelp, #barometer_tab').hide(); - Metamaps.Famous.logo.hide() + $('.upperLeftUI, .upperRightUI, .mapControls, .infoAndHelp, .uv-icon, .footer').hide(); Metamaps.JIT.zoomExtents(); - console.log('got here'); + if (typeof window.callPhantom === 'function') { + window.callPhantom(); + } });//document.on animationDone });//page.evaluate - - //pass to ruby - //console.log(page.renderBase64('PNG')); - - //render to the metamaps_gen002 directory for debug - page.render('map1.png', 'PNG'); - } else { //failed to load }//if - - setTimeout(phantom.exit,5000); - //phantom.exit(); });