closes #3663
parent
714efd0d0e
commit
ca294fc6ec
@ -1,24 +1,24 @@
|
|||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
var path = require('path');
|
var path = require('path');
|
||||||
var fs = require('fs');
|
var file = require('../../file');
|
||||||
|
|
||||||
var themesController = {};
|
var themesController = {};
|
||||||
|
|
||||||
themesController.get = function(req, res, next) {
|
themesController.get = function(req, res, next) {
|
||||||
var themeDir = path.join(__dirname, '../../../node_modules/' + req.params.theme);
|
var themeDir = path.join(__dirname, '../../../node_modules/' + req.params.theme);
|
||||||
fs.exists(themeDir, function(exists) {
|
file.exists(themeDir, function(exists) {
|
||||||
if (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 {
|
|
||||||
return next();
|
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