This commit is contained in:
barisusakli
2015-09-29 18:22:41 -04:00
parent 714efd0d0e
commit ca294fc6ec
15 changed files with 128 additions and 115 deletions

View File

@@ -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'));
}
});
};