Merge pull request #521 from cweider/fix-minify

Fix minify
pull/523/merge
Peter 'Pita' Martischka 2012-02-29 01:49:45 -08:00
commit d868fd73d4
4 changed files with 12 additions and 10 deletions

View File

@ -154,7 +154,7 @@ async.waterfall([
// CommonJS loader on the client-side.
var jsServer = new (Yajsml.Server)({
rootPath: 'minified/'
, rootURI: 'http://' + settings.ip + ":" + settings.port + '/static/js/'
, rootURI: 'http://localhost:' + settings.port + '/static/js/'
});
var StaticAssociator = Yajsml.associators.StaticAssociator;
var associations =

View File

@ -35,10 +35,9 @@ var TAR_PATH = path.join(__dirname, 'tar.json');
var tar = JSON.parse(fs.readFileSync(TAR_PATH, 'utf8'));
// Rewrite tar to include modules with no extensions and proper rooted paths.
// HACK: Also use non-extension name so redirects are not encountered.
exports.tar = {};
for (var key in tar) {
exports.tar['/' + key.replace(/\.js$/, '')] =
exports.tar['/' + key] =
tar[key].map(function (p) {return '/' + p}).concat(
tar[key].map(function (p) {return '/' + p.replace(/\.js$/, '')})
);
@ -57,6 +56,7 @@ exports.minify = function(req, res, next)
filename = path.normalize(path.join(ROOT_DIR, filename));
if (filename.indexOf(ROOT_DIR) == 0) {
filename = filename.slice(ROOT_DIR.length);
filename = filename.replace(/\\/g, '/'); // Windows (safe generally?)
} else {
res.writeHead(404, {});
res.end();
@ -148,7 +148,7 @@ function getAceFile(callback) {
var filename = item.match(/"([^"]*)"/)[1];
var request = require('request');
var baseURI = 'http://' + settings.ip + ":" + settings.port
var baseURI = 'http://localhost:' + settings.port
request(baseURI + path.normalize(path.join('/static/', filename)), function (error, response, body) {
if (!error && response.statusCode == 200) {

View File

@ -53,7 +53,7 @@ CachingMiddleware.prototype = new function () {
fs.stat(CACHE_DIR + 'minified_' + cacheKey, function (error, stats) {
var modifiedSince = (req.headers['if-modified-since']
&& new Date(req.headers['if-modified-since']));
var lastModifiedCache = stats && stats.mtime;
var lastModifiedCache = !error && stats.mtime;
if (lastModifiedCache) {
req.headers['if-modified-since'] = lastModifiedCache.toUTCString();
} else {
@ -87,11 +87,10 @@ CachingMiddleware.prototype = new function () {
// Update cache
var buffer = '';
Object.keys(headers).forEach(function (key) {
Object.keys(headers || {}).forEach(function (key) {
res.setHeader(key, headers[key]);
});
headers = _headers;
responseCache[cacheKey] = {statusCode: status, headers: headers};
old_res.write = res.write;
old_res.end = res.end;
@ -118,7 +117,10 @@ CachingMiddleware.prototype = new function () {
}
});
}
], respond);
], function () {
responseCache[cacheKey] = {statusCode: status, headers: headers};
respond();
});
};
} else if (status == 304) {
// Nothing new changed from the cached version.
@ -162,7 +164,7 @@ CachingMiddleware.prototype = new function () {
res.writeHead(statusCode, headers);
util.pump(readStream, res);
} else {
res.writeHead(200, headers);
res.writeHead(statusCode, headers);
res.end();
}
}

View File

@ -10,7 +10,7 @@
"name": "Robin Buse" }
],
"dependencies" : {
"yajsml" : "1.1.1",
"yajsml" : "1.1.2",
"request" : "2.9.100",
"require-kernel" : "1.0.3",
"socket.io" : "0.8.7",