mirror of
https://github.com/NodeBB/NodeBB.git
synced 2026-01-17 04:52:51 +01:00
25 lines
692 B
JavaScript
25 lines
692 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')),
|
|
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; |