diff --git a/bin/cli.js b/bin/cli.js index e6c23bb..c03c922 100644 --- a/bin/cli.js +++ b/bin/cli.js @@ -13,7 +13,7 @@ var cli = meow({ ' yellowlabtools ', '', 'Options:', - ' --device Use "phone" or "tablet" to simulate a mobile device (by user-agent and viewport size).', + ' --device Simulates a device. Choose between phone (default), tablet, desktop and desktop-hd.', ' --screenshot Will take a screenshot and use this value as the output path. It needs to end with ".png".', //' --wait-for-selector Once the page is loaded, Phantomas will wait until the given CSS selector matches some elements.', ' --proxy Sets an HTTP proxy to pass through. Syntax is "host:port".', @@ -55,7 +55,7 @@ if (screenshot) { } // Device simulation -options.device = cli.flags.device || 'desktop'; +options.device = cli.flags.device || 'mobile'; // Wait for CSS selector options.waitForSelector = cli.flags.waitForSelector || null; diff --git a/front/src/css/main.css b/front/src/css/main.css index 2219d07..bb8866a 100644 --- a/front/src/css/main.css +++ b/front/src/css/main.css @@ -155,13 +155,15 @@ a.linkButton { .screenshotWrapper .screenshotError { color: #fff; } -.screenshotWrapper.desktop { +.screenshotWrapper.desktop, +.screenshotWrapper.desktop-hd { border: 0.2em solid #AAA; padding: 0.5em; border-top-left-radius: 0.4em; border-top-right-radius: 0.4em; } -.screenshotWrapper.desktop:before { +.screenshotWrapper.desktop:before, +.screenshotWrapper.desktop-hd:before { position: absolute; width: 15em; height: 0.6em; @@ -172,7 +174,8 @@ a.linkButton { border-bottom-right-radius: 0.2em; content: " "; } -.screenshotWrapper.desktop:after { +.screenshotWrapper.desktop:after, +.screenshotWrapper.desktop-hd:after { position: absolute; width: 0.4em; height: 0.2em; @@ -181,7 +184,8 @@ a.linkButton { background: lime; content: " "; } -.screenshotWrapper.desktop > div { +.screenshotWrapper.desktop > div, +.screenshotWrapper.desktop-hd > div { width: 12em; height: 6.75em; } diff --git a/front/src/js/services/settingsService.js b/front/src/js/services/settingsService.js index 81f9f5b..21674d4 100644 --- a/front/src/js/services/settingsService.js +++ b/front/src/js/services/settingsService.js @@ -6,7 +6,7 @@ settingsService.factory('Settings', ['localStorageService', function(localStorag getMergedSettings: function() { var defaultSettings = { - device: 'desktop', + device: 'mobile', showAdvanced: false }; diff --git a/front/src/less/main.less b/front/src/less/main.less index 05f9142..8413b02 100644 --- a/front/src/less/main.less +++ b/front/src/less/main.less @@ -168,7 +168,7 @@ a.linkButton { } } -.screenshotWrapper.desktop { +.screenshotWrapper.desktop, .screenshotWrapper.desktop-hd { border: 0.2em solid #AAA; padding: 0.5em; border-top-left-radius: 0.4em; diff --git a/front/src/views/dashboard.html b/front/src/views/dashboard.html index b07869c..cdce76d 100644 --- a/front/src/views/dashboard.html +++ b/front/src/views/dashboard.html @@ -18,7 +18,7 @@
-
+
Screenshot not available diff --git a/front/src/views/index.html b/front/src/views/index.html index a15205b..69d503a 100644 --- a/front/src/views/index.html +++ b/front/src/views/index.html @@ -7,9 +7,10 @@
[ Advanced settings  ✚ diff --git a/front/src/views/screenshot.html b/front/src/views/screenshot.html index 7f4de0d..c22bc42 100644 --- a/front/src/views/screenshot.html +++ b/front/src/views/screenshot.html @@ -2,7 +2,7 @@

Screenshot

-
+
Screenshot not available diff --git a/lib/tools/phantomas/phantomasWrapper.js b/lib/tools/phantomas/phantomasWrapper.js index 917cf53..8ffae1e 100644 --- a/lib/tools/phantomas/phantomasWrapper.js +++ b/lib/tools/phantomas/phantomasWrapper.js @@ -17,49 +17,14 @@ var PhantomasWrapper = function() { var deferred = Q.defer(); var task = data.params; - /*var options = { - - // Cusomizable options - 'engine': task.options.phantomasEngine || 'webkit', - 'timeout': task.options.timeout || 30, - 'user-agent': (task.options.device === 'desktop') ? 'Mozilla/5.0 (Windows NT 6.1) AppleWebKit/537.36 (KHTML, like Gecko) YLT Chrome/27.0.1453.110 Safari/537.36' : null, - 'tablet': (task.options.device === 'tablet'), - 'phone': (task.options.device === 'phone'), - 'screenshot': task.options.screenshot || false, - 'wait-for-selector': task.options.waitForSelector, - 'cookie': task.options.cookie, - 'auth-user': task.options.authUser, - 'auth-pass': task.options.authPass, - 'block-domain': task.options.blockDomain, - 'allow-domain': task.options.allowDomain, - 'no-externals': task.options.noExternals, - - // Mandatory - 'reporter': 'json:pretty', - 'analyze-css': true, - 'ignore-ssl-errors': true, - 'skip-modules': [ - 'ajaxRequests', // overridden - 'domHiddenContent', // overridden - 'domMutations', // not compatible with webkit - 'domQueries', // overridden - 'events', // overridden - 'filmStrip', // not needed - 'har', // not needed for the moment - 'javaScriptBottlenecks', // needs to be launched after custom module scopeYLT - 'jQuery', // overridden - 'jserrors', // overridden - 'lazyLoadableImages', //overridden - 'pageSource', // not needed - 'windowPerformance' // overridden - ].join(','), - 'include-dirs': [ - path.join(__dirname, 'custom_modules/core'), - path.join(__dirname, 'custom_modules/modules') - ].join(',') - }; - - */ + var viewportOption = null; + if (task.options.device === 'desktop') { + // Similar to an old non-retina Macbook Air 13" + viewportOption = '1280x800x1'; + } else if (task.options.device === 'desktop-hd') { + // Similar to a retina Macbook Pro 16" + viewportOption = '1536x960x2'; + } var options = { @@ -69,7 +34,7 @@ var PhantomasWrapper = function() { 'tablet': (task.options.device === 'tablet'), 'phone': (task.options.device === 'phone'), 'screenshot': task.options.screenshot || false, - 'viewport': (task.options.device === 'desktop') ? '1280x800x1' : null, + 'viewport': viewportOption, 'wait-for-network-idle': true, //'wait-for-selector': task.options.waitForSelector, 'cookie': task.options.cookie, diff --git a/server_config/settings-prod.json b/server_config/settings-prod.json index 272df56..a6efafd 100644 --- a/server_config/settings-prod.json +++ b/server_config/settings-prod.json @@ -3,9 +3,10 @@ "phantomasEngine": "webkit", "googleAnalyticsId": "", "screenshotWidth": { - "desktop": 600, + "phone": 360, "tablet": 420, - "phone": 360 + "desktop": 600, + "desktop-hd": 600 }, "baseUrl": "/", "authorizedKeys": { diff --git a/server_config/settings.json b/server_config/settings.json index 5eabca0..f8f5896 100644 --- a/server_config/settings.json +++ b/server_config/settings.json @@ -3,9 +3,10 @@ "phantomasEngine": "webkit", "googleAnalyticsId": "", "screenshotWidth": { - "desktop": 600, + "phone": 360, "tablet": 420, - "phone": 360 + "desktop": 600, + "desktop-hd": 600 }, "baseUrl": "/", "authorizedKeys": {