diff --git a/public/src/forum/admin/themes.js b/public/src/forum/admin/themes.js
index 4e66561107..830e8ff025 100644
--- a/public/src/forum/admin/themes.js
+++ b/public/src/forum/admin/themes.js
@@ -73,7 +73,7 @@ define(function() {
if (themes.length > 0) {
for (var x = 0, numThemes = themes.length; x < numThemes; x++) {
liEl.setAttribute('data-theme', themes[x].id);
- liEl.innerHTML = '
' +
+ liEl.innerHTML = '
' +
'
' +
'
' +
' ' +
diff --git a/src/meta.js b/src/meta.js
index f82538ea6a..0a14614ea8 100644
--- a/src/meta.js
+++ b/src/meta.js
@@ -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);
}
});
diff --git a/src/webserver.js b/src/webserver.js
index 08dbeab485..605b0e22fe 100644
--- a/src/webserver.js
+++ b/src/webserver.js
@@ -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);
},