Merge branch 'master' into develop

This commit is contained in:
Gaël Métais
2018-01-16 20:37:56 -06:00
7 changed files with 37 additions and 37 deletions
@@ -751,7 +751,7 @@
}
function onDetailsClick(row) {
// Close if it's alreay open
// Close if it's already open
if (row.classList.contains('showDetails')) {
closeDetails(row);
return;
@@ -924,4 +924,4 @@
};
});
})();
})();
+1 -1
View File
@@ -893,7 +893,7 @@ var policies = {
"totalWeight": {
"tool": "redownload",
"label": "Total weight",
"message": "<p>The weight is of course very important if you want the page to load fast. Try to stay under 1MB, which is alreay very long to download over a slow connection.</p><p>Please note that Yellow Lab Tools' engine (PhantomJS) is not compatible with image srcset (unless you use a polyfill). This can lead to incorrect page weight.</p>",
"message": "<p>The weight is of course very important if you want the page to load fast. Try to stay under 1MB, which is already very long to download over a slow connection.</p><p>Please note that Yellow Lab Tools' engine (PhantomJS) is not compatible with image srcset (unless you use a polyfill). This can lead to incorrect page weight.</p>",
"isOkThreshold": 716800,
"isBadThreshold": 2097152,
"isAbnormalThreshold": 3145728,
+8 -8
View File
@@ -1,5 +1,5 @@
var debug = require('debug')('ylt:screenshotHandler');
var lwip = require('lwip');
var Jimp = require('jimp');
var tmp = require('temporary');
var Q = require('q');
var fs = require('fs');
@@ -57,7 +57,7 @@ var screenshotHandler = function() {
this.openImage = function(imagePath) {
var deferred = Q.defer();
lwip.open(imagePath, function(err, image){
Jimp.read(imagePath, function(err, image){
if (err) {
debug('Could not open imagePath %s', imagePath);
debug(err);
@@ -76,7 +76,7 @@ var screenshotHandler = function() {
this.resizeImage = function(image, newWidth) {
var deferred = Q.defer();
var currentWidth = image.width();
var currentWidth = image.bitmap.width;
var ratio = newWidth / currentWidth;
image.scale(ratio, function(err, image){
@@ -101,7 +101,7 @@ var screenshotHandler = function() {
var deferred = Q.defer();
// Create a canvas with the same dimensions as your image:
lwip.create(image.width(), image.height(), 'white', function(err, canvas){
new Jimp(image.bitmap.width, image.bitmap.height, 0xFFFFFF, function(err, canvas){
if (err) {
debug('Could not create a white canvas');
debug(err);
@@ -109,7 +109,7 @@ var screenshotHandler = function() {
deferred.reject(err);
} else {
// Paste original image on top of the canvas
canvas.paste(0, 0, image, function(err, image){
canvas.composite(image, 0, 0, function(err, image){
if (err) {
debug('Could not paste image on the white canvas');
debug(err);
@@ -131,7 +131,7 @@ var screenshotHandler = function() {
this.toBuffer = function(image) {
var deferred = Q.defer();
image.toBuffer('jpg', {quality: 90}, function(err, buffer){
image.quality(90).getBuffer(Jimp.MIME_JPEG, function(err, buffer){
if (err) {
debug('Could not save image to buffer');
debug(err);
@@ -143,7 +143,7 @@ var screenshotHandler = function() {
}
});
return deferred.promise;
return deferred.promise;
};
@@ -167,4 +167,4 @@ var screenshotHandler = function() {
};
};
module.exports = new screenshotHandler();
module.exports = new screenshotHandler();
+3 -3
View File
@@ -296,7 +296,7 @@ var FileMinifier = function() {
return deferred.promise;
}
// Avoid loosing time trying to compress some JS libraries known as already compressed
// Avoid losing time trying to compress some JS libraries known as already compressed
function isKnownAsMinified(url) {
var result = false;
@@ -322,7 +322,7 @@ var FileMinifier = function() {
return result;
}
// Avoid loosing some trying to compress JS files if they alreay look minified
// Avoid losing some trying to compress JS files if they already look minified
// by counting the number of lines compared to the total size.
// Less than 2KB per line is suspicious
function looksAlreadyMinified(code) {
@@ -351,4 +351,4 @@ var FileMinifier = function() {
};
};
module.exports = new FileMinifier();
module.exports = new FileMinifier();
+1 -1
View File
@@ -55,7 +55,7 @@
"is-ttf": "0.2.2",
"is-woff": "1.0.3",
"is-woff2": "1.0.0",
"lwip": "0.0.9",
"jimp": "0.2.28",
"md5": "2.2.1",
"meow": "3.7.0",
"minimize": "2.1.0",
+16 -16
View File
@@ -7,17 +7,17 @@ var path = require('path');
describe('screenshotHandler', function() {
var imagePath = path.join(__dirname, '../fixtures/logo-large.png');
var screenshot, lwipImage;
var screenshot, jimpImage;
it('should open an image and return an lwip object', function(done) {
it('should open an image and return an jimp object', function(done) {
ScreenshotHandler.openImage(imagePath)
.then(function(image) {
lwipImage = image;
jimpImage = image;
lwipImage.should.be.an('object');
lwipImage.width().should.equal(620);
lwipImage.height().should.equal(104);
jimpImage.should.be.an('object');
jimpImage.bitmap.width.should.equal(620);
jimpImage.bitmap.height.should.equal(104);
done();
})
@@ -26,14 +26,14 @@ describe('screenshotHandler', function() {
});
});
it('should resize an lwip image', function(done) {
ScreenshotHandler.resizeImage(lwipImage, 310)
it('should resize an jimp image', function(done) {
ScreenshotHandler.resizeImage(jimpImage, 310)
.then(function(image) {
lwipImage = image;
jimpImage = image;
lwipImage.width().should.equal(310);
lwipImage.height().should.equal(52);
jimpImage.bitmap.width.should.equal(310);
jimpImage.bitmap.height.should.equal(52);
done();
})
@@ -43,8 +43,8 @@ describe('screenshotHandler', function() {
});
it('should transform a lwip image into a buffer', function(done) {
ScreenshotHandler.toBuffer(lwipImage)
it('should transform a jimp image into a buffer', function(done) {
ScreenshotHandler.toBuffer(jimpImage)
.then(function(buffer) {
buffer.should.be.an.instanceof(Buffer);
done();
@@ -125,4 +125,4 @@ describe('screenshotHandler', function() {
done(err);
});
});
});
});
+6 -6
View File
@@ -228,14 +228,14 @@ describe('redownload', function() {
newEntry.weightCheck.bodySize.should.equal(4193);
newEntry.weightCheck.bodyBuffer.should.deep.equal(fileContent);
// Opening the image in lwip to check if the format is good
var lwip = require('lwip');
lwip.open(newEntry.weightCheck.bodyBuffer, 'png', function(err, image) {
image.width().should.equal(620);
image.height().should.equal(104);
// Opening the image in jimp to check if the format is good
var Jimp = require('jimp');
Jimp.read(newEntry.weightCheck.bodyBuffer, function(err, image) {
image.bitmap.width.should.equal(620);
image.bitmap.height.should.equal(104);
done(err);
});
})
.fail(function(err) {