|
|
@ -134,16 +134,41 @@ var fs = require('fs'),
|
|
|
|
},
|
|
|
|
},
|
|
|
|
function(next) {
|
|
|
|
function(next) {
|
|
|
|
// Static Directories for Plugins
|
|
|
|
// Static Directories for Plugins
|
|
|
|
|
|
|
|
var realPath,
|
|
|
|
|
|
|
|
validMappedPath = /^[\w\-_]+$/;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
pluginData.staticDirs = pluginData.staticDirs || {};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Deprecated, to be removed v0.5
|
|
|
|
if (pluginData.staticDir) {
|
|
|
|
if (pluginData.staticDir) {
|
|
|
|
staticDir = path.join(pluginPath, pluginData.staticDir);
|
|
|
|
winston.warn('[plugins/' + pluginData.id + '] staticDir is deprecated, use staticDirs instead');
|
|
|
|
|
|
|
|
Plugins.staticDirs[pluginData.id] = path.join(pluginPath, pluginData.staticDir);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
fs.exists(staticDir, function(exists) {
|
|
|
|
for(key in pluginData.staticDirs) {
|
|
|
|
if (exists) {
|
|
|
|
(function(mappedPath) {
|
|
|
|
Plugins.staticDirs[pluginData.id] = staticDir;
|
|
|
|
if (pluginData.staticDirs.hasOwnProperty(mappedPath)) {
|
|
|
|
next();
|
|
|
|
if (Plugins.staticDirs[mappedPath]) {
|
|
|
|
} else next();
|
|
|
|
winston.warn('[plugins/' + pluginData.id + '] Mapped path (' + mappedPath + ') already specified!');
|
|
|
|
});
|
|
|
|
} else if (!validMappedPath.test(mappedPath)) {
|
|
|
|
} else next();
|
|
|
|
winston.warn('[plugins/' + pluginData.id + '] Invalid mapped path specified: ' + mappedPath + '. Path must adhere to: ' + validMappedPath.toString());
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
realPath = pluginData.staticDirs[mappedPath];
|
|
|
|
|
|
|
|
staticDir = path.join(pluginPath, realPath);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
(function(staticDir) {
|
|
|
|
|
|
|
|
fs.exists(staticDir, function(exists) {
|
|
|
|
|
|
|
|
if (exists) {
|
|
|
|
|
|
|
|
Plugins.staticDirs[mappedPath] = staticDir;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
}(staticDir));
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}(key));
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
next();
|
|
|
|
},
|
|
|
|
},
|
|
|
|
function(next) {
|
|
|
|
function(next) {
|
|
|
|
// CSS Files for plugins
|
|
|
|
// CSS Files for plugins
|
|
|
@ -152,9 +177,16 @@ var fs = require('fs'),
|
|
|
|
winston.info('[plugins] Found ' + pluginData.css.length + ' CSS file(s) for plugin ' + pluginData.id);
|
|
|
|
winston.info('[plugins] Found ' + pluginData.css.length + ' CSS file(s) for plugin ' + pluginData.id);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
Plugins.cssFiles = Plugins.cssFiles.concat(pluginData.css.map(function(file) {
|
|
|
|
if (!pluginData.staticDir) {
|
|
|
|
return path.join('/plugins', pluginData.id, file);
|
|
|
|
Plugins.cssFiles = Plugins.cssFiles.concat(pluginData.css.map(function(file) {
|
|
|
|
}));
|
|
|
|
return path.join('/plugins', file);
|
|
|
|
|
|
|
|
}));
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
winston.warn('[plugins/' + pluginData.id + '] staticDir is deprecated, define CSS files with new staticDirs instead.');
|
|
|
|
|
|
|
|
Plugins.cssFiles = Plugins.cssFiles.concat(pluginData.css.map(function(file) {
|
|
|
|
|
|
|
|
return path.join('/plugins', pluginData.id, file);
|
|
|
|
|
|
|
|
}));
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
next();
|
|
|
|
next();
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|