closes #3663
parent
714efd0d0e
commit
ca294fc6ec
@ -1,24 +1,24 @@
|
||||
'use strict';
|
||||
|
||||
var path = require('path');
|
||||
var fs = require('fs');
|
||||
var file = require('../../file');
|
||||
|
||||
var themesController = {};
|
||||
|
||||
themesController.get = function(req, res, next) {
|
||||
var themeDir = path.join(__dirname, '../../../node_modules/' + req.params.theme);
|
||||
fs.exists(themeDir, function(exists) {
|
||||
if (exists) {
|
||||
var themeConfig = require(path.join(themeDir, 'theme.json')),
|
||||
screenshotPath = path.join(themeDir, themeConfig.screenshot);
|
||||
if (themeConfig.screenshot && fs.existsSync(screenshotPath)) {
|
||||
res.sendFile(screenshotPath);
|
||||
} else {
|
||||
res.sendFile(path.join(__dirname, '../../../public/images/themes/default.png'));
|
||||
}
|
||||
} else {
|
||||
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'));
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
|
Loading…
Reference in New Issue