From 22332dbe9dc9db9f36e7d66fdda6aa7c0b1ebd56 Mon Sep 17 00:00:00 2001 From: booo Date: Wed, 21 Dec 2011 18:18:22 +0100 Subject: [PATCH] fix issue #281; remove white spaces --- node/utils/Minify.js | 104 +++++++++++++++++++++---------------------- package.json | 3 +- 2 files changed, 52 insertions(+), 55 deletions(-) diff --git a/node/utils/Minify.js b/node/utils/Minify.js index fd1dd0793..1db1e05f6 100644 --- a/node/utils/Minify.js +++ b/node/utils/Minify.js @@ -1,7 +1,7 @@ /** - * This Module manages all /minified/* requests. It controls the - * minification && compression of Javascript and CSS. - */ + * This Module manages all /minified/* requests. It controls the + * minification && compression of Javascript and CSS. + */ /* * 2011 Peter 'Pita' Martischka (Primary Technology Ltd) @@ -28,7 +28,7 @@ var jsp = require("uglify-js").parser; var pro = require("uglify-js").uglify; var path = require('path'); var Buffer = require('buffer').Buffer; -var gzip = require('gzip'); +var zlib = require('zlib'); var server = require('../server'); var os = require('os'); @@ -44,7 +44,7 @@ var timesliderJS = ["jquery.min.js", "plugins.js", "undo-xpopup.js", "json2.js", exports.minifyJS = function(req, res, jsFilename) { res.header("Content-Type","text/javascript"); - + //choose the js files we need if(jsFilename == "pad.js") { @@ -58,20 +58,20 @@ exports.minifyJS = function(req, res, jsFilename) { throw new Error("there is no profile for creating " + name); } - + //minifying is enabled if(settings.minify) { var fileValues = {}; var embeds = {}; var latestModification = 0; - + async.series([ //find out the highest modification date function(callback) - { + { var folders2check = ["../static/css","../static/js"]; - + //go trough this two folders async.forEach(folders2check, function(path, callback) { @@ -79,27 +79,27 @@ exports.minifyJS = function(req, res, jsFilename) fs.readdir(path, function(err, files) { if(ERR(err, callback)) return; - + //we wanna check the directory itself for changes too files.push("."); - + //go trough all files in this folder - async.forEach(files, function(filename, callback) + async.forEach(files, function(filename, callback) { //get the stat data of this file fs.stat(path + "/" + filename, function(err, stats) { if(ERR(err, callback)) return; - + //get the modification time var modificationTime = stats.mtime.getTime(); - + //compare the modification time to the highest found if(modificationTime > latestModification) { latestModification = modificationTime; } - + callback(); }); }, callback); @@ -116,7 +116,7 @@ exports.minifyJS = function(req, res, jsFilename) ERR(err, callback); return; } - + //there is no minfied file or there new changes since this file was generated, so continue generating this file if((err && err.code == "ENOENT") || stats.mtime.getTime() < latestModification) { @@ -128,48 +128,48 @@ exports.minifyJS = function(req, res, jsFilename) callback("stop"); } }); - }, + }, //load all js files function (callback) { async.forEach(jsFiles, function (item, callback) { fs.readFile("../static/js/" + item, "utf-8", function(err, data) - { + { if(ERR(err, callback)) return; fileValues[item] = data; callback(); }); }, callback); }, - //find all includes in ace.js and embed them + //find all includes in ace.js and embed them function(callback) - { + { //if this is not the creation of pad.js, skip this part if(jsFilename != "pad.js") { callback(); return; } - + var founds = fileValues["ace.js"].match(/\$\$INCLUDE_[a-zA-Z_]+\([a-zA-Z0-9.\/_"]+\)/gi); - + //go trough all includes async.forEach(founds, function (item, callback) { var filename = item.match(/"[^"]*"/g)[0].substr(1); filename = filename.substr(0,filename.length-1); - + var type = item.match(/INCLUDE_[A-Z]+/g)[0].substr("INCLUDE_".length); - + var quote = item.search("_Q") != -1; - + //read the included file fs.readFile(filename, "utf-8", function(err, data) - { + { if(ERR(err, callback)) return; - - //compress the file + + //compress the file if(type == "JS") { embeds[item] = "