|
|
@ -93,21 +93,37 @@ Templates.compile = function(callback) {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (relativePath.match(/^\/admin\/[\s\S]*?/)) {
|
|
|
|
|
|
|
|
addIndex(relativePath, file);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
mkdirp.sync(path.join(viewsPath, relativePath.split('/').slice(0, -1).join('/')));
|
|
|
|
mkdirp.sync(path.join(viewsPath, relativePath.split('/').slice(0, -1).join('/')));
|
|
|
|
fs.writeFile(path.join(viewsPath, relativePath), file, next);
|
|
|
|
fs.writeFile(path.join(viewsPath, relativePath), file, next);
|
|
|
|
}, function(err) {
|
|
|
|
}, function(err) {
|
|
|
|
if (err) {
|
|
|
|
if (err) {
|
|
|
|
winston.error('[themes] ' + err.stack);
|
|
|
|
winston.error('[themes] ' + err.stack);
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
|
|
|
|
compileIndex(viewsPath, function() {
|
|
|
|
winston.info('[themes] Successfully compiled templates.');
|
|
|
|
winston.info('[themes] Successfully compiled templates.');
|
|
|
|
emitter.emit('templates:compiled');
|
|
|
|
emitter.emit('templates:compiled');
|
|
|
|
if (callback) {
|
|
|
|
if (callback) {
|
|
|
|
callback();
|
|
|
|
callback();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var searchIndex = {};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
function addIndex(path, file) {
|
|
|
|
|
|
|
|
searchIndex[path] = file;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
function compileIndex(viewsPath, callback) {
|
|
|
|
|
|
|
|
fs.writeFile(path.join(viewsPath, '/indexed.json'), JSON.stringify(searchIndex), callback);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
module.exports = Templates;
|
|
|
|
module.exports = Templates;
|