Minify uses the stardard middleware interface.
This commit is contained in:
parent
1c0a74d7c6
commit
c3acdbe329
|
@ -123,19 +123,7 @@ async.waterfall([
|
||||||
});
|
});
|
||||||
|
|
||||||
//serve minified files
|
//serve minified files
|
||||||
app.get('/minified/:id', function(req, res, next)
|
app.get('/minified/:filename', minify.minifyJS);
|
||||||
{
|
|
||||||
var id = req.params.id;
|
|
||||||
|
|
||||||
if(id == "pad.js" || id == "timeslider.js")
|
|
||||||
{
|
|
||||||
minify.minifyJS(req,res,id);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
next();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
//checks for padAccess
|
//checks for padAccess
|
||||||
function hasPadAccess(req, res, callback)
|
function hasPadAccess(req, res, callback)
|
||||||
|
|
|
@ -40,20 +40,22 @@ var tar = JSON.parse(fs.readFileSync(TAR_PATH, 'utf8'));
|
||||||
* @param req the Express request
|
* @param req the Express request
|
||||||
* @param res the Express response
|
* @param res the Express response
|
||||||
*/
|
*/
|
||||||
exports.minifyJS = function(req, res, jsFilename)
|
exports.minifyJS = function(req, res, next)
|
||||||
{
|
{
|
||||||
res.header("Content-Type","text/javascript");
|
var jsFilename = req.params['filename'];
|
||||||
|
|
||||||
//choose the js files we need
|
//choose the js files we need
|
||||||
var jsFiles = undefined;
|
var jsFiles = undefined;
|
||||||
if (Object.prototype.hasOwnProperty.call(tar, jsFilename)) {
|
if (Object.prototype.hasOwnProperty.call(tar, jsFilename)) {
|
||||||
jsFiles = tar[jsFilename];
|
jsFiles = tar[jsFilename];
|
||||||
} else {
|
} else {
|
||||||
throw new Error("there is no profile for creating " + name);
|
return next();
|
||||||
}
|
}
|
||||||
|
|
||||||
var rootPath = path.normalize(__dirname + "/../../" );
|
var rootPath = path.normalize(__dirname + "/../../" );
|
||||||
|
|
||||||
|
res.header("Content-Type","text/javascript");
|
||||||
|
|
||||||
//minifying is enabled
|
//minifying is enabled
|
||||||
if(settings.minify)
|
if(settings.minify)
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in New Issue