From 00eb9ce1ae0b0fbc2f243107af9bef3e4fde7f8e Mon Sep 17 00:00:00 2001 From: mattimatti Date: Thu, 9 Apr 2015 11:46:40 +0200 Subject: [PATCH 1/8] Added configurable option --- tasks/photobox.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tasks/photobox.js b/tasks/photobox.js index 5fbed8e..7140610 100644 --- a/tasks/photobox.js +++ b/tasks/photobox.js @@ -26,7 +26,8 @@ module.exports = function( grunt ) { template : 'canvas', userAgent : 'Photobox', userName : '', - urls : [ 'http://4waisenkinder.de' ] + urls : [ 'http://4waisenkinder.de' ], + timeOut : 1000 } ), Photobox = require( './lib/photobox' ), pb = new Photobox( grunt, options, done ); From 5d1ef16cb2a907fb7ee8d3ebfe0592c35373e3a3 Mon Sep 17 00:00:00 2001 From: mattimatti Date: Thu, 9 Apr 2015 11:47:39 +0200 Subject: [PATCH 2/8] added timeOut parameter --- tasks/lib/photoboxScript.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tasks/lib/photoboxScript.js b/tasks/lib/photoboxScript.js index 0d904c1..4039b1e 100644 --- a/tasks/lib/photoboxScript.js +++ b/tasks/lib/photoboxScript.js @@ -75,5 +75,5 @@ page.open( url, function( status ) { page.render( imgPath ); phantom.exit(); - }, 1000 ); + }, page.settings.timeOut ); } ); From 49eabaa49ace64fb5e7b3b8ab43bdfe00ea32ff9 Mon Sep 17 00:00:00 2001 From: mattimatti Date: Thu, 9 Apr 2015 11:48:35 +0200 Subject: [PATCH 3/8] Added configurable option --- tasks/lib/photobox.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tasks/lib/photobox.js b/tasks/lib/photobox.js index ee53b58..954f427 100644 --- a/tasks/lib/photobox.js +++ b/tasks/lib/photobox.js @@ -515,7 +515,8 @@ PhotoBox.prototype.startPhotoSession = function() { localToRemoteUrlAccessEnabled : this.options.localToRemoteUrlAccessEnabled, password : this.options.password, userAgent : this.options.userAgent, - userName : this.options.userName + userName : this.options.userName, + timeOut : this.options.timeOut } ); this.pictures.forEach( function( picture ) { From 047bf9e59bbb16fb242b20314bc6691b1fd7fd8d Mon Sep 17 00:00:00 2001 From: mattimatti Date: Thu, 9 Apr 2015 11:50:36 +0200 Subject: [PATCH 4/8] Added configurable option --- README.md | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/README.md b/README.md index cdc4b8b..b5dfde2 100644 --- a/README.md +++ b/README.md @@ -175,6 +175,15 @@ Default value: `default` - `grayscale` - image information in diff image will be changed to grayscale - `darker` - image information in diff image will be changed to a darker image - `brighter` - image information in diff image will be change to a brighter image +- + +#### options.timeOut + +Type: `Integer` + +Default value: 1000 + +An Integer representing the delay in milliseconds after the screenshot should be taken. ### Usage Examples From f546a5737d517c5c96de05ead15b492361598cd8 Mon Sep 17 00:00:00 2001 From: mattimatti Date: Thu, 9 Apr 2015 11:51:33 +0200 Subject: [PATCH 5/8] Added configurable option --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index b5dfde2..2ff387d 100644 --- a/README.md +++ b/README.md @@ -175,7 +175,7 @@ Default value: `default` - `grayscale` - image information in diff image will be changed to grayscale - `darker` - image information in diff image will be changed to a darker image - `brighter` - image information in diff image will be change to a brighter image -- + #### options.timeOut From e9e3c0c488d59cf4f747f4e9d69d945b228e79f2 Mon Sep 17 00:00:00 2001 From: mattimatti Date: Thu, 9 Apr 2015 11:57:41 +0200 Subject: [PATCH 6/8] added timeOut parameter --- Gruntfile.js | 1 + 1 file changed, 1 insertion(+) diff --git a/Gruntfile.js b/Gruntfile.js index 0306fd1..6bc14fa 100644 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -35,6 +35,7 @@ module.exports = function(grunt) { waisenkinder : { options : { indexPath : 'photobox/', + timeOut : 1000, screenSizes : [ '960', '350', '1200' ], template : { name : 'canvas', From 4e9290206650a02ae56cbfde848c29fdf72f0176 Mon Sep 17 00:00:00 2001 From: mattimatti Date: Thu, 9 Apr 2015 17:50:47 +0200 Subject: [PATCH 7/8] Added hashBang Parameter --- README.md | 11 +++++++++++ tasks/lib/photobox.js | 16 +++++++++------- tasks/lib/photoboxScript.js | 4 +++- tasks/photobox.js | 3 ++- 4 files changed, 25 insertions(+), 9 deletions(-) diff --git a/README.md b/README.md index 2ff387d..725c3d2 100644 --- a/README.md +++ b/README.md @@ -185,6 +185,17 @@ Default value: 1000 An Integer representing the delay in milliseconds after the screenshot should be taken. + +#### options.hashBang + +Type: `String` + +Default value: `#!` + +The hashbang used to navigate through a single page application. + +http://example.com/#!/hash/bang + ### Usage Examples #### Default Options diff --git a/tasks/lib/photobox.js b/tasks/lib/photobox.js index 954f427..7b1985a 100644 --- a/tasks/lib/photobox.js +++ b/tasks/lib/photobox.js @@ -82,7 +82,7 @@ PhotoBox.prototype.createDiffImages = function() { this.grunt.log.subhead( 'PHOTOBOX STARTED DIFF GENERATION.'); this.pictures.forEach( function( picture ) { - picture = this.getUrlFilename( picture.replace('#', '-') ); + picture = this.getUrlFilename( picture.replace('@', '-') ); this.grunt.log.writeln( 'started diff for ' + picture ); @@ -125,10 +125,10 @@ PhotoBox.prototype.createIndexFile = function() { var templateData = this.pictures.map( function( picture ) { - var split = picture.split('#'); + var split = picture.split('@'); return { - url : this.getUrlFilename( split[0] ), + url : this.getUrlFilename( split[0].replace(this.options.hashBang, '_') ), size: split[1] }; }.bind(this) @@ -311,7 +311,7 @@ PhotoBox.prototype.getPreparedPictures = function() { this.options.urls.forEach( function( url ) { this.options.screenSizes.forEach( function( size ) { - pictures.push( url + '#' + size ); + pictures.push( url + '@' + size ); if ( size.match( /x/gi ) ) { this.grunt.log.warn( @@ -493,7 +493,8 @@ PhotoBox.prototype.getUrlFilename = function( url ) { var finalImage = ( ( !this.options.relativePaths ? parsedImage.host + '/' : '' ) + ( ( parsedImage.path !== '/' || !this.options.relativePaths ) ? parsedImage.path : 'index' ).replace( /^\//, '' ) + - ( parsedImage.query ? '/' + parsedImage.query : '' ) + ( parsedImage.query ? '/' + parsedImage.query : '' ) + + ( parsedImage.hash ? '/' + parsedImage.hash : '' ) ).replace( /^www\./g, '' ); return filenamify( finalImage, { replacement: '-' } ); @@ -516,7 +517,8 @@ PhotoBox.prototype.startPhotoSession = function() { password : this.options.password, userAgent : this.options.userAgent, userName : this.options.userName, - timeOut : this.options.timeOut + timeOut : this.options.timeOut, + hashBang : this.options.hashBang } ); this.pictures.forEach( function( picture ) { @@ -525,7 +527,7 @@ PhotoBox.prototype.startPhotoSession = function() { var args = [ '--ssl-protocol=any', path.resolve( __dirname, 'photoboxScript.js' ), - picture + '#' + this.getUrlFilename( picture ), + picture + '@' + this.getUrlFilename( picture ), this.options.indexPath, this.options.indexPath + 'options.json' ]; diff --git a/tasks/lib/photoboxScript.js b/tasks/lib/photoboxScript.js index 4039b1e..565b3cd 100644 --- a/tasks/lib/photoboxScript.js +++ b/tasks/lib/photoboxScript.js @@ -15,7 +15,7 @@ var system = require ( 'system' ), fs = require( 'fs' ), page = webpage.create(), picture = system.args[ 1 ], - split = picture.split( '#' ), + split = picture.split( '@' ), url = split[ 0 ], width = +split[ 1 ], image = split[ 2 ], @@ -64,6 +64,8 @@ page.open( url, function( status ) { height : height, width : width }; + + image = image.replace(page.settings.hashBang, '_'); var imgPath = indexPath + 'img/current/' + diff --git a/tasks/photobox.js b/tasks/photobox.js index 7140610..16e17d7 100644 --- a/tasks/photobox.js +++ b/tasks/photobox.js @@ -27,7 +27,8 @@ module.exports = function( grunt ) { userAgent : 'Photobox', userName : '', urls : [ 'http://4waisenkinder.de' ], - timeOut : 1000 + timeOut : 1000, + hashBang : '#!' } ), Photobox = require( './lib/photobox' ), pb = new Photobox( grunt, options, done ); From d8e446f91363758281ce0a6603bd97fc3399a587 Mon Sep 17 00:00:00 2001 From: mattimatti Date: Mon, 13 Apr 2015 14:22:26 +0200 Subject: [PATCH 8/8] modified test code to permit hashBang handling --- test/lib/photoboxTest.js | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/test/lib/photoboxTest.js b/test/lib/photoboxTest.js index e57280a..caea487 100644 --- a/test/lib/photoboxTest.js +++ b/test/lib/photoboxTest.js @@ -235,23 +235,28 @@ exports.photoBox = { template : { name : 'canvas', options : { + hashBang: '#!', highlightColor : '#ff0000', // template.options.hightlightColor || highlightcolor || default diffFilter : 'default' // default == no filter 'grayscale' | 'darker' | 'brighter' } }, screenSizes : [ '1000', '1200' ], - urls : [ 'http://google.com', 'http://4waisenkinder.de' ] + urls : [ 'http://google.com', 'http://4waisenkinder.de', 'http://4waisenkinder.de#myhash', 'http://4waisenkinder.de/#!/myhash' ] }, pb = new Photobox( grunt, options, cbFunction ), pictures; pictures = pb.getPreparedPictures(); - test.strictEqual( pictures.length, 4 ); - test.strictEqual( pictures[ 0 ], 'http://google.com#1000' ); - test.strictEqual( pictures[ 1 ], 'http://google.com#1200' ); - test.strictEqual( pictures[ 2 ], 'http://4waisenkinder.de#1000' ); - test.strictEqual( pictures[ 3 ], 'http://4waisenkinder.de#1200' ); + test.strictEqual( pictures.length, 8 ); + test.strictEqual( pictures[ 0 ], 'http://google.com@1000' ); + test.strictEqual( pictures[ 1 ], 'http://google.com@1200' ); + test.strictEqual( pictures[ 2 ], 'http://4waisenkinder.de@1000' ); + test.strictEqual( pictures[ 3 ], 'http://4waisenkinder.de@1200' ); + test.strictEqual( pictures[ 4 ], 'http://4waisenkinder.de#myhash@1000' ); + test.strictEqual( pictures[ 5 ], 'http://4waisenkinder.de#myhash@1200' ); + test.strictEqual( pictures[ 6 ], 'http://4waisenkinder.de/#!/myhash@1000' ); + test.strictEqual( pictures[ 7 ], 'http://4waisenkinder.de/#!/myhash@1200' ); test.done(); },