Permalink
Browse files

Add some comments.

  • Loading branch information...
1 parent 98f56b5 commit cfe095466f85c8900f5f64ef4afc6664271d59f8 @cweider committed Feb 20, 2012
Showing with 13 additions and 4 deletions.
  1. +4 −2 node/server.js
  2. +9 −2 node/utils/Minify.js
View
@@ -146,10 +146,12 @@ async.waterfall([
var assetCache = new CachingMiddleware;
app.all('/(minified|static)/*', assetCache.handle);
- //serve static files
+ // Minify will serve static files compressed (minify enabled). It also has
+ // file-specific hacks for ace/require-kernel/etc.
app.all('/static/:filename(*)', minify.minify);
- //serve minified files
+ // Setup middleware that will package JavaScript files served by minify for
+ // CommonJS loader on the client-side.
var jsServer = new (Yajsml.Server)({
rootPath: 'minified/'
, rootURI: 'http://' + settings.ip + ":" + settings.port + '/static/js/'
View
@@ -34,6 +34,7 @@ var ROOT_DIR = path.normalize(__dirname + "/../../static/");
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.
exports.tar = {};
for (var key in tar) {
exports.tar['/' + key] =
@@ -134,12 +135,14 @@ function getAceFile(callback) {
if (!settings.minify) {
founds = [];
}
+ // Always include the require kernel.
founds.push('$$INCLUDE_JS("../static/js/require-kernel.js")');
data += ';\n';
data += 'Ace2Editor.EMBEDED = Ace2Editor.EMBEDED || {};\n';
- //go trough all includes
+ // Request the contents of the included file on the server-side and write
+ // them into the file.
async.forEach(founds, function (item, callback) {
var filename = item.match(/"([^"]*)"/)[1];
var request = require('request');
@@ -161,8 +164,11 @@ function getAceFile(callback) {
});
}
+// Check for the existance of the file and get the last modification date.
function statFile(filename, callback) {
if (filename == 'js/ace.js') {
+ // Sometimes static assets are inlined into this file, so we have to stat
+ // everything.
lastModifiedDateOfEverything(function (error, date) {
callback(error, date, !error);
});
@@ -171,7 +177,8 @@ function statFile(filename, callback) {
} else {
fs.stat(ROOT_DIR + filename, function (error, stats) {
if (error) {
- if (error.code == "ENOENT") { // Stat the directory instead.
+ if (error.code == "ENOENT") {
+ // Stat the directory instead.
fs.stat(path.dirname(ROOT_DIR + filename), function (error, stats) {
if (error) {
if (error.code == "ENOENT") {

0 comments on commit cfe0954

Please sign in to comment.