mirror of
https://github.com/ether/etherpad-lite.git
synced 2025-04-20 23:46:14 -04:00
Add some comments.
This commit is contained in:
parent
98f56b53b4
commit
cfe095466f
2 changed files with 13 additions and 4 deletions
|
@ -146,10 +146,12 @@ async.waterfall([
|
||||||
var assetCache = new CachingMiddleware;
|
var assetCache = new CachingMiddleware;
|
||||||
app.all('/(minified|static)/*', assetCache.handle);
|
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);
|
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)({
|
var jsServer = new (Yajsml.Server)({
|
||||||
rootPath: 'minified/'
|
rootPath: 'minified/'
|
||||||
, rootURI: 'http://' + settings.ip + ":" + settings.port + '/static/js/'
|
, rootURI: 'http://' + settings.ip + ":" + settings.port + '/static/js/'
|
||||||
|
|
|
@ -34,6 +34,7 @@ var ROOT_DIR = path.normalize(__dirname + "/../../static/");
|
||||||
var TAR_PATH = path.join(__dirname, 'tar.json');
|
var TAR_PATH = path.join(__dirname, 'tar.json');
|
||||||
var tar = JSON.parse(fs.readFileSync(TAR_PATH, 'utf8'));
|
var tar = JSON.parse(fs.readFileSync(TAR_PATH, 'utf8'));
|
||||||
|
|
||||||
|
// Rewrite tar to include modules with no extensions and proper rooted paths.
|
||||||
exports.tar = {};
|
exports.tar = {};
|
||||||
for (var key in tar) {
|
for (var key in tar) {
|
||||||
exports.tar['/' + key] =
|
exports.tar['/' + key] =
|
||||||
|
@ -134,12 +135,14 @@ function getAceFile(callback) {
|
||||||
if (!settings.minify) {
|
if (!settings.minify) {
|
||||||
founds = [];
|
founds = [];
|
||||||
}
|
}
|
||||||
|
// Always include the require kernel.
|
||||||
founds.push('$$INCLUDE_JS("../static/js/require-kernel.js")');
|
founds.push('$$INCLUDE_JS("../static/js/require-kernel.js")');
|
||||||
|
|
||||||
data += ';\n';
|
data += ';\n';
|
||||||
data += 'Ace2Editor.EMBEDED = Ace2Editor.EMBEDED || {};\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) {
|
async.forEach(founds, function (item, callback) {
|
||||||
var filename = item.match(/"([^"]*)"/)[1];
|
var filename = item.match(/"([^"]*)"/)[1];
|
||||||
var request = require('request');
|
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) {
|
function statFile(filename, callback) {
|
||||||
if (filename == 'js/ace.js') {
|
if (filename == 'js/ace.js') {
|
||||||
|
// Sometimes static assets are inlined into this file, so we have to stat
|
||||||
|
// everything.
|
||||||
lastModifiedDateOfEverything(function (error, date) {
|
lastModifiedDateOfEverything(function (error, date) {
|
||||||
callback(error, date, !error);
|
callback(error, date, !error);
|
||||||
});
|
});
|
||||||
|
@ -171,7 +177,8 @@ function statFile(filename, callback) {
|
||||||
} else {
|
} else {
|
||||||
fs.stat(ROOT_DIR + filename, function (error, stats) {
|
fs.stat(ROOT_DIR + filename, function (error, stats) {
|
||||||
if (error) {
|
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) {
|
fs.stat(path.dirname(ROOT_DIR + filename), function (error, stats) {
|
||||||
if (error) {
|
if (error) {
|
||||||
if (error.code == "ENOENT") {
|
if (error.code == "ENOENT") {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue