fixing screenshot previews in admin/themes

This commit is contained in:
Julian Lam
2013-11-01 11:27:02 -04:00
parent 1a415b60be
commit e4c62200de
3 changed files with 26 additions and 17 deletions

View File

@@ -80,20 +80,9 @@ var utils = require('./../public/src/utils.js'),
if (fs.existsSync(config)) {
fs.readFile(config, function (err, file) {
var configObj = JSON.parse(file.toString());
if (configObj.staticDir && configObj.screenshot) {
// Verify that the provided path leads to a file that exists
fs.exists(path.join(__dirname, '../node_modules/', configObj.id, configObj.staticDir, configObj.screenshot), function(exists) {
if (exists) {
configObj.screenshot = path.join('/css/assets/', configObj.screenshot);
} else {
configObj.screenshot = nconf.get('relative_path') + '/images/themes/default.png';
}
next(err, configObj);
});
} else {
configObj.screenshot = nconf.get('relative_path') + '/images/themes/default.png';
if (err) return next();
else {
var configObj = JSON.parse(file.toString());
next(err, configObj);
}
});