diff --git a/bin/cli.js b/bin/cli.js index 58a8fb4..54cfbe8 100644 --- a/bin/cli.js +++ b/bin/cli.js @@ -1,10 +1,11 @@ #!/usr/bin/env node -var debug = require('debug')('ylt:cli'); -var meow = require('meow'); -var path = require('path'); +var debug = require('debug')('ylt:cli'); +var meow = require('meow'); +var path = require('path'); +var jstoxml = require('jstoxml'); -var ylt = require('../lib/index'); +var ylt = require('../lib/index'); var cli = meow({ help: [ @@ -19,6 +20,7 @@ var cli = meow({ ' --cookie Adds a cookie on the main domain.', ' --auth-user Basic HTTP authentication username.', ' --auth-pass Basic HTTP authentication password.', + ' --reporter The output format: "json" or "xml". Default is "json".', '' ].join('\n'), pkg: '../package.json' @@ -67,6 +69,12 @@ options.cookie = cli.flags.cookie || null; options.authUser = cli.flags.authUser || null; options.authPass = cli.flags.authPass || 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"'); + process.exit(1); +} + (function execute(url, options) { 'use strict'; @@ -76,7 +84,13 @@ options.authPass = cli.flags.authPass || null; then(function(data) { debug('Success'); - console.log(JSON.stringify(data, null, 2)); + switch(cli.flags.reporter) { + case 'xml': + console.log(jstoxml.toXML(data, {indent: ' '})); + break; + default: + console.log(JSON.stringify(data, null, 2)); + } }).fail(function(err) { diff --git a/front/src/css/rule.css b/front/src/css/rule.css index 508d3b0..ccc72a5 100644 --- a/front/src/css/rule.css +++ b/front/src/css/rule.css @@ -29,9 +29,16 @@ border-radius: 0.5em; margin: 0 auto 0.5em; } +.rule h3 { + margin-bottom: 0em; +} +.rule .okThreshold { + font-style: italic; + font-size: 0.9em; +} .rule .message { width: 80%; - margin: 0 auto; + margin: 1.5em auto; } .rule .message p { margin: 0.5em; diff --git a/front/src/less/rule.less b/front/src/less/rule.less index 9cf165e..7a2571f 100644 --- a/front/src/less/rule.less +++ b/front/src/less/rule.less @@ -32,9 +32,18 @@ margin: 0 auto 0.5em; } +.rule h3 { + margin-bottom: 0em; +} + +.rule .okThreshold { + font-style: italic; + font-size: 0.9em; +} + .rule .message { width: 80%; - margin: 0 auto; + margin: 1.5em auto; p { margin: 0.5em; } diff --git a/front/src/views/index.html b/front/src/views/index.html index f83be65..e6e55e1 100644 --- a/front/src/views/index.html +++ b/front/src/views/index.html @@ -2,7 +2,7 @@

Free and open source!

- +
diff --git a/front/src/views/rule.html b/front/src/views/rule.html index cf61e4f..b484ead 100644 --- a/front/src/views/rule.html +++ b/front/src/views/rule.html @@ -14,6 +14,14 @@ {{rule.value | bytes}} {{rule.value}} +
+ Have + {{rule.policy.isOkThreshold | bytes}} + {{rule.policy.isOkThreshold}} + or less + or more + to get the 100/100 score. +
diff --git a/lib/metadata/policies.js b/lib/metadata/policies.js index 213cad0..96cfee3 100644 --- a/lib/metadata/policies.js +++ b/lib/metadata/policies.js @@ -195,8 +195,8 @@ var policies = { "label": "document.write calls", "message": "

They slow down the page construction, especially if they are used to insert scripts in the page. Remove them ASAP.

If you cannot remove them because they come from a third-party script (such as ads), have a look at PostScribe.

", "isOkThreshold": 0, - "isBadThreshold": 10, - "isAbnormalThreshold": 20, + "isBadThreshold": 5, + "isAbnormalThreshold": 10, "hasOffenders": true, "offendersTransformFn": function(offenders) { return { @@ -254,8 +254,8 @@ var policies = { "tool": "phantomas", "label": "Global variables", "message": "

It is a bad practice because they clutter up the global namespace. If two scripts use the same variable name in the global scope, it can cause conflicts and it is generally hard to debug.

Global variables also take a (very) little bit longer to be accessed than variables in the local scope of a function.

", - "isOkThreshold": 30, - "isBadThreshold": 150, + "isOkThreshold": 40, + "isBadThreshold": 200, "isAbnormalThreshold": 700, "hasOffenders": true, "offendersTransformFn": function(offenders) { diff --git a/package.json b/package.json index 4be3d98..1b13e19 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "yellowlabtools", - "version": "1.7.6", + "version": "1.7.7", "description": "Online tool to audit a webpage for performance and front-end quality issues", "license": "GPL-2.0", "author": { @@ -17,13 +17,13 @@ }, "main": "./lib/index.js", "dependencies": { - "angular": "1.4.4", - "angular-animate": "1.4.4", - "angular-chart.js": "0.7.6", + "angular": "1.4.5", + "angular-animate": "1.4.5", + "angular-chart.js": "0.8.3", "angular-local-storage": "0.2.2", - "angular-resource": "1.4.4", - "angular-route": "1.4.4", - "angular-sanitize": "1.4.4", + "angular-resource": "1.4.5", + "angular-route": "1.4.5", + "angular-sanitize": "1.4.5", "async": "1.4.2", "body-parser": "1.13.3", "chart.js": "1.0.2", @@ -34,6 +34,7 @@ "express": "4.13.3", "imagemin": "3.2.0", "imagemin-jpegoptim": "4.0.0", + "jstoxml": "0.2.3", "lwip": "0.0.7", "meow": "3.3.0", "minimize": "1.7.0", @@ -54,7 +55,7 @@ "grunt-contrib-copy": "~0.8.1", "grunt-contrib-cssmin": "~0.13.0", "grunt-contrib-htmlmin": "~0.4.0", - "grunt-contrib-jshint": "~0.11.2", + "grunt-contrib-jshint": "~0.11.3", "grunt-contrib-less": "~1.0.1", "grunt-contrib-uglify": "~0.9.2", "grunt-env": "~0.4.4", @@ -63,11 +64,11 @@ "grunt-inline-angular-templates": "~0.1.5", "grunt-line-remover": "~0.0.2", "grunt-mocha-test": "~0.12.7", - "grunt-replace": "~0.10.2", + "grunt-replace": "~0.11.0", "grunt-usemin": "~3.1.1", "grunt-webfont": "~0.5.4", "matchdep": "~0.3.0", - "mocha": "~2.2.5", + "mocha": "~2.3.2", "sinon": "~1.16.1", "sinon-chai": "~2.8.0" },