Files
NodeBB/src/controllers/admin/themes.js
Peter Jaszkowiak feb8405f95 ESlint eol-last
2017-02-18 02:30:48 -07:00

26 lines
698 B
JavaScript

'use strict';
var path = require('path');
var file = require('../../file');
var themesController = {};
themesController.get = function (req, res, next) {
var themeDir = path.join(__dirname, '../../../node_modules/' + req.params.theme);
file.exists(themeDir, function (exists) {
if (!exists) {
return next();
}
var themeConfig = require(path.join(themeDir, 'theme.json'));
var screenshotPath = path.join(themeDir, themeConfig.screenshot);
if (themeConfig.screenshot && file.existsSync(screenshotPath)) {
res.sendFile(screenshotPath);
} else {
res.sendFile(path.join(__dirname, '../../../public/images/themes/default.png'));
}
});
};
module.exports = themesController;