Minify uses the stardard middleware interface.

pull/344/head
Chad Weider 2012-01-17 00:57:59 -08:00
parent 1c0a74d7c6
commit c3acdbe329
2 changed files with 6 additions and 16 deletions

View File

@ -123,19 +123,7 @@ async.waterfall([
});
//serve minified files
app.get('/minified/:id', function(req, res, next)
{
var id = req.params.id;
if(id == "pad.js" || id == "timeslider.js")
{
minify.minifyJS(req,res,id);
}
else
{
next();
}
});
app.get('/minified/:filename', minify.minifyJS);
//checks for padAccess
function hasPadAccess(req, res, callback)

View File

@ -40,20 +40,22 @@ var tar = JSON.parse(fs.readFileSync(TAR_PATH, 'utf8'));
* @param req the Express request
* @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
var jsFiles = undefined;
if (Object.prototype.hasOwnProperty.call(tar, jsFilename)) {
jsFiles = tar[jsFilename];
} else {
throw new Error("there is no profile for creating " + name);
return next();
}
var rootPath = path.normalize(__dirname + "/../../" );
res.header("Content-Type","text/javascript");
//minifying is enabled
if(settings.minify)
{