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

@@ -137,10 +137,10 @@ var express = require('express'),
app.use(function (req, res, next) {
nconf.set('https', req.secure);
res.locals.csrf_token = req.session._csrf;
// Disable framing
res.setHeader("X-Frame-Options", "DENY");
next();
});
@@ -215,6 +215,26 @@ var express = require('express'),
next();
}
});
// Route paths to screenshots for installed themes
meta.themes.get(function(err, themes) {
var screenshotPath;
async.each(themes, function(themeObj, next) {
if (themeObj.screenshot) {
screenshotPath = path.join(__dirname, '../node_modules', themeObj.id, themeObj.screenshot);
fs.exists(screenshotPath, function(exists) {
if (exists) {
app.get('/css/previews/' + themeObj.id, function(req, res) {
res.sendfile(screenshotPath);
});
}
});
} else {
next(false);
}
});
});
}
], next);
},