diff --git a/Gruntfile.js b/Gruntfile.js index 6a7d42b..3d9a755 100644 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -143,7 +143,7 @@ module.exports = function(grunt) { options: { reporter: 'spec', }, - src: ['test/core/imageOptimizerTest.js'] + src: ['test/core/fontAnalyzerTest.js'] }, coverage: { options: { @@ -343,7 +343,6 @@ module.exports = function(grunt) { 'copy:coverage', 'express:test', 'mochaTest:test', - 'mochaTest:coverage', 'clean:tmp' ]); diff --git a/Vagrantfile b/Vagrantfile index 43b7a13..404079f 100644 --- a/Vagrantfile +++ b/Vagrantfile @@ -1,6 +1,6 @@ Vagrant.configure("2") do |config| - config.vm.box = "ubuntu/precise64" + config.vm.box = "ubuntu/trusty64" config.vm.network :private_network, ip: "10.10.10.10" config.ssh.forward_agent = true @@ -17,6 +17,8 @@ Vagrant.configure("2") do |config| vb.customize ["modifyvm", :id, "--cpus", 2] end + config.vm.synced_folder "./", "/space/YellowLabTools" + config.vm.provision :shell, :path => "server_config/server_install.sh" end diff --git a/bin/cli.js b/bin/cli.js index 723e385..7e7cfb9 100644 --- a/bin/cli.js +++ b/bin/cli.js @@ -15,10 +15,14 @@ var cli = meow({ 'Options:', ' --device Use "phone" or "tablet" to simulate a mobile device (by user-agent and viewport size).', ' --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.', + //' --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".', ' --cookie Adds a cookie on the main domain.', ' --auth-user Basic HTTP authentication username.', ' --auth-pass Basic HTTP authentication password.', + ' --block-domain Disallow requests to given (comma-separated) domains - aka blacklist.', + ' --allow-domain Only allow requests to given (comma-separated) domains - aka whitelist.', + ' --no-externals Block all domains except the main one.', ' --reporter The output format: "json" or "xml". Default is "json".', '' ].join('\n'), @@ -56,6 +60,9 @@ options.device = cli.flags.device || 'desktop'; // Wait for CSS selector options.waitForSelector = cli.flags.waitForSelector || null; +// Proxy +options.proxy = cli.flags.proxy || null; + // Cookie options.cookie = cli.flags.cookie || null; @@ -63,6 +70,11 @@ options.cookie = cli.flags.cookie || null; options.authUser = cli.flags.authUser || null; options.authPass = cli.flags.authPass || null; +// Domain blocking +options.blockDomain = cli.flags.blockDomain || null; +options.allowDomain = cli.flags.allowDomain || null; +options.noExternals = cli.flags.noExternals || null; + // Output format if (cli.flags.reporter && cli.flags.reporter !== 'json' && cli.flags.reporter !== 'xml') { console.error('Incorrect parameters: reporter has to be "json" or "xml"'); @@ -80,8 +92,27 @@ if (cli.flags.reporter && cli.flags.reporter !== 'json' && cli.flags.reporter != debug('Success'); switch(cli.flags.reporter) { case 'xml': - var serializer = new EasyXml(); - console.log(serializer.render(data)); + var serializer = new EasyXml({ + manifest: true + }); + + // Remove some heavy parts of the results object + delete data.toolsResults; + delete data.javascriptExecutionTree; + + var xmlOutput = serializer.render(data); + + // Remove special chars from XML tags: # [ ] + xmlOutput = xmlOutput.replace(/<([^>]*)#([^>]*)>/g, '<$1>'); + xmlOutput = xmlOutput.replace(/<([^>]*)\[([^>]*)>/g, '<$1>'); + xmlOutput = xmlOutput.replace(/<([^>]*)\]([^>]*)>/g, '<$1>'); + + // Remove special chars from text content: \n \0 + xmlOutput = xmlOutput.replace(/(<[a-zA-Z]*>[^<]*)\n([^<]*<\/[a-zA-Z]*>)/g, '$1$2'); + xmlOutput = xmlOutput.replace(/\0/g, ''); + xmlOutput = xmlOutput.replace(/\uFFFF/g, ''); + + console.log(xmlOutput); break; default: console.log(JSON.stringify(data, null, 2)); diff --git a/front/src/css/rule.css b/front/src/css/rule.css index 686d735..9b51443 100644 --- a/front/src/css/rule.css +++ b/front/src/css/rule.css @@ -231,13 +231,13 @@ padding-top: 2.5em; } .totalWeightPie { - max-width: 39em; + max-width: 20em; margin: 2em auto 4em; } .totalWeightPie canvas { max-width: inherit; } -.hugeFile { +.offenderProblem { font-weight: bold; color: #e74c3c; } diff --git a/front/src/js/controllers/indexCtrl.js b/front/src/js/controllers/indexCtrl.js index 51e4741..2537a93 100644 --- a/front/src/js/controllers/indexCtrl.js +++ b/front/src/js/controllers/indexCtrl.js @@ -1,13 +1,23 @@ var indexCtrl = angular.module('indexCtrl', []); -indexCtrl.controller('IndexCtrl', ['$scope', 'Settings', 'API', function($scope, Settings, API) { +indexCtrl.controller('IndexCtrl', ['$scope', '$routeParams', '$location', 'Settings', 'API', function($scope, $routeParams, $location, Settings, API) { $scope.settings = Settings.getMergedSettings(); $scope.launchTest = function() { if ($scope.url) { + $location.search('url', null); + $location.search('run', null); Settings.saveSettings($scope.settings); API.launchTest($scope.url, $scope.settings); } }; + + // Auto fill URL field and auto launch test when the good params are set in the URL + if ($routeParams.url) { + $scope.url = $routeParams.url; + if ($routeParams.run === 'true' || $routeParams.run === 1 || $routeParams.run === '1') { + $scope.launchTest(); + } + } }]); \ No newline at end of file diff --git a/front/src/js/controllers/ruleCtrl.js b/front/src/js/controllers/ruleCtrl.js index f3da670..16c5c55 100644 --- a/front/src/js/controllers/ruleCtrl.js +++ b/front/src/js/controllers/ruleCtrl.js @@ -45,7 +45,23 @@ ruleCtrl.controller('RuleCtrl', ['$scope', '$rootScope', '$routeParams', '$locat }); $scope.weightOptions = { - tooltipTemplate: '<%=label%>: <%=value%> KB' + tooltips: { + callbacks: { + label: function(tooltipItem, data) { + var label = data.labels[tooltipItem.index]; + var value = data.datasets[tooltipItem.datasetIndex].data[tooltipItem.index]; + return label + ': ' + value + ' KB'; + } + } + }, + legend: { + display: true, + position: 'bottom', + labels: { + boxWidth: 12, + fontSize: 14 + } + } }; } @@ -87,14 +103,27 @@ ruleCtrl.controller('RuleCtrl', ['$scope', '$rootScope', '$routeParams', '$locat $scope.breakpointsSeries = ['Number of CSS rules per breakpoint']; $scope.breakpointsColours = ['#9c4274']; $scope.breakpointsOptions = { - scaleShowGridLines: false, - barShowStroke: false, - showTooltips: false, - pointDot: false, - responsive: true, - maintainAspectRatio: true, - strokeColor: 'rgba(20, 200, 20, 1)', - scaleFontSize: 9 + scales: { + xAxes: [{ + gridLines: { + display:false + } + }], + yAxes: [{ + gridLines: { + display:false + } + }] + }, + tooltips: { + enabled: false + }, + + elements: { + point: { + radius: 0 + } + } }; } } diff --git a/front/src/js/directives/offendersDirectives.js b/front/src/js/directives/offendersDirectives.js index ae84679..609871b 100644 --- a/front/src/js/directives/offendersDirectives.js +++ b/front/src/js/directives/offendersDirectives.js @@ -918,4 +918,10 @@ }; }); + offendersDirectives.filter('addSpaces', function() { + return function(str) { + return str.split('').join(' '); + }; + }); + })(); \ No newline at end of file diff --git a/front/src/js/services/apiService.js b/front/src/js/services/apiService.js index ba2680b..61e06c9 100644 --- a/front/src/js/services/apiService.js +++ b/front/src/js/services/apiService.js @@ -11,6 +11,7 @@ apiService.factory('API', ['$location', 'Runs', 'Results', function($location, R screenshot: true, device: settings.device, waitForSelector: settings.waitForSelector, + proxy: settings.proxy, cookie: settings.cookie, authUser: settings.authUser, authPass: settings.authPass, diff --git a/front/src/less/rule.less b/front/src/less/rule.less index a4310ed..7eaa056 100644 --- a/front/src/less/rule.less +++ b/front/src/less/rule.less @@ -261,7 +261,7 @@ } } -.hugeFile { +.offenderProblem { font-weight: bold; color: #e74c3c; } diff --git a/front/src/main.html b/front/src/main.html index f155eb1..c569b4e 100644 --- a/front/src/main.html +++ b/front/src/main.html @@ -16,7 +16,6 @@ - @@ -39,7 +38,7 @@ - + diff --git a/front/src/views/dashboard.html b/front/src/views/dashboard.html index ba8346e..955bdba 100644 --- a/front/src/views/dashboard.html +++ b/front/src/views/dashboard.html @@ -3,7 +3,7 @@
: -
+
{{request}}
@@ -17,7 +17,7 @@
- +
@@ -36,7 +36,7 @@