Merge branch 'wip-phantomjs' of https://github.com/Connoropolous/metamaps_gen002 into phantom
This commit is contained in:
commit
4f94f44a1f
3 changed files with 26 additions and 24 deletions
|
@ -8,6 +8,7 @@ Metamaps.JIT = {
|
||||||
removeSynapse: 'Metamaps:JIT:events:removeSynapse',
|
removeSynapse: 'Metamaps:JIT:events:removeSynapse',
|
||||||
pan: 'Metamaps:JIT:events:pan',
|
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
|
vizData: [], // contains the visualization-compatible graph
|
||||||
/**
|
/**
|
||||||
|
@ -229,6 +230,7 @@ Metamaps.JIT = {
|
||||||
duration: 800,
|
duration: 800,
|
||||||
onComplete: function () {
|
onComplete: function () {
|
||||||
Metamaps.Visualize.mGraph.busy = false;
|
Metamaps.Visualize.mGraph.busy = false;
|
||||||
|
$(document).trigger(Metamaps.JIT.events.animationDone, [event]);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
animateFDLayout: {
|
animateFDLayout: {
|
||||||
|
@ -1679,4 +1681,4 @@ Metamaps.JIT = {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
|
@ -3,8 +3,15 @@ class GrabMapScreenshotWorker
|
||||||
include Sidekiq::Worker
|
include Sidekiq::Worker
|
||||||
|
|
||||||
def perform(map_id)
|
def perform(map_id)
|
||||||
|
imgBase64 = ''
|
||||||
Phantomjs.run('./script/phantomjs-save-screenshot.js', map_id.to_s) { |line|
|
Phantomjs.run('./script/phantomjs-save-screenshot.js', map_id.to_s) { |line|
|
||||||
|
imgBase64 << line
|
||||||
puts line
|
puts line
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#this doesn't work yet
|
||||||
|
#map = Map.find(map_id)
|
||||||
|
#map.add_attachment(imgBase64)
|
||||||
|
#map.save!
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -9,16 +9,8 @@ if (args.length <= 1) {
|
||||||
//configurable variables - CHANGE ME
|
//configurable variables - CHANGE ME
|
||||||
var mapID = args[1];
|
var mapID = args[1];
|
||||||
var url = 'http://localhost:3000/maps/' + mapID;
|
var url = 'http://localhost:3000/maps/' + mapID;
|
||||||
var width = 400;
|
var width = 188;
|
||||||
var height = 400;
|
var height = 126;
|
||||||
var thumbsDirRelative = 'app/assets/images/map_thumbnails';
|
|
||||||
|
|
||||||
//set up writing to filesystem
|
|
||||||
var fs = require('fs');
|
|
||||||
var thumbsDirectory = fs.workingDirectory + '/' + thumbsDirRelative;
|
|
||||||
if (!fs.isDirectory(thumbsDirectory)) {
|
|
||||||
fs.makeDirectory(thumbsDirectory);
|
|
||||||
}//if
|
|
||||||
|
|
||||||
//set up page and the area we'll render as a PNG
|
//set up page and the area we'll render as a PNG
|
||||||
var page = require('webpage').create();
|
var page = require('webpage').create();
|
||||||
|
@ -26,29 +18,30 @@ page.viewportSize = {
|
||||||
width: width,
|
width: width,
|
||||||
height: height
|
height: height
|
||||||
};
|
};
|
||||||
page.clipRect = {
|
|
||||||
top: 32,
|
|
||||||
left: 32,
|
|
||||||
width: width - 32,
|
|
||||||
height: height - 32
|
|
||||||
};
|
|
||||||
page.open(url, function (status) {
|
page.open(url, function (status) {
|
||||||
if (status === 'success') {
|
if (status === 'success') {
|
||||||
//since this isn't evaluateAsync, it should also ensure the asynchronous
|
//since this isn't evaluateAsync, it should also ensure the asynchronous
|
||||||
//js stuff is loaded too, hopefully?
|
//js stuff is loaded too, hopefully?
|
||||||
page.evaluate(function() {
|
page.evaluate(function() {
|
||||||
$(document).ready(function(){
|
$(document).on(Metamaps.JIT.events.animationDone, function(){
|
||||||
$('.upperLeftUI, .upperRightUI, .mapControls, .infoAndHelp, #barometer_tab, .footer').hide();
|
$('.upperLeftUI, .upperRightUI, .mapControls, .infoAndHelp, #barometer_tab').hide();
|
||||||
});//document.ready
|
Metamaps.Famous.logo.hide()
|
||||||
|
Metamaps.JIT.zoomExtents();
|
||||||
|
console.log('got here');
|
||||||
|
});//document.on animationDone
|
||||||
});//page.evaluate
|
});//page.evaluate
|
||||||
|
|
||||||
//render page into map_thumbnails directory
|
//pass to ruby
|
||||||
var filename = thumbsDirectory + '/map' + mapID + '.png';
|
//console.log(page.renderBase64('PNG'));
|
||||||
page.render(filename, 'PNG');
|
|
||||||
|
//render to the metamaps_gen002 directory for debug
|
||||||
|
page.render('map1.png', 'PNG');
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
//failed to load
|
//failed to load
|
||||||
}//if
|
}//if
|
||||||
|
|
||||||
phantom.exit();
|
setTimeout(phantom.exit,5000);
|
||||||
|
//phantom.exit();
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in a new issue