mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-11-03 20:45:58 +01:00
changing method to retrieve themes to use /node_modules
This commit is contained in:
38
src/meta.js
38
src/meta.js
@@ -42,31 +42,31 @@ var utils = require('./../public/src/utils.js'),
|
|||||||
|
|
||||||
Meta.themes = {
|
Meta.themes = {
|
||||||
get: function(callback) {
|
get: function(callback) {
|
||||||
var themePath = path.join(__dirname, '../', 'public/themes');
|
var themePath = path.join(__dirname, '../node_modules');
|
||||||
fs.readdir(themePath, function(err, files) {
|
fs.readdir(themePath, function(err, files) {
|
||||||
var themeArr = [];
|
async.filter(files, function(file, next) {
|
||||||
async.each(files, function(file, next) {
|
fs.stat(path.join(themePath, file), function(err, fileStat) {
|
||||||
fs.lstat(path.join(themePath, file), function(err, stats) {
|
if (err) next(false);
|
||||||
if(stats.isDirectory()) {
|
|
||||||
var themeDir = file,
|
|
||||||
themeConfPath = path.join(themePath, themeDir, 'theme.json');
|
|
||||||
|
|
||||||
fs.exists(themeConfPath, function(exists) {
|
next((fileStat.isDirectory() && file.slice(0, 13) === 'nodebb-theme-'));
|
||||||
if (exists) {
|
});
|
||||||
fs.readFile(themeConfPath, function(err, conf) {
|
}, function(themes) {
|
||||||
conf = JSON.parse(conf);
|
async.map(themes, function(theme, next) {
|
||||||
conf.src = nconf.get('url') + 'themes/' + themeDir + '/' + conf.src;
|
var config = path.join(themePath, theme, 'theme.json');
|
||||||
if (conf.screenshot) conf.screenshot = nconf.get('url') + 'themes/' + themeDir + '/' + conf.screenshot;
|
|
||||||
else conf.screenshot = nconf.get('url') + 'images/themes/default.png';
|
if (fs.existsSync(config)) {
|
||||||
themeArr.push(conf);
|
fs.readFile(config, function(err, file) {
|
||||||
next();
|
var configObj = JSON.parse(file.toString());
|
||||||
|
if (!configObj.screenshot) configObj.screenshot = nconf.get('relative_path') + '/images/themes/default.png';
|
||||||
|
next(err, configObj);
|
||||||
});
|
});
|
||||||
} else next();
|
} else next();
|
||||||
|
}, function(err, themes) {
|
||||||
|
themes = themes.filter(function(theme) {
|
||||||
|
return (theme !== undefined);
|
||||||
});
|
});
|
||||||
} else next();
|
callback(null, themes);
|
||||||
});
|
});
|
||||||
}, function(err) {
|
|
||||||
callback(err, themeArr);
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -800,6 +800,7 @@ var SocketIO = require('socket.io').listen(global.server, { log:false }),
|
|||||||
|
|
||||||
socket.on('api:admin.themes.getInstalled', function(callback) {
|
socket.on('api:admin.themes.getInstalled', function(callback) {
|
||||||
meta.themes.get(function(err, themeArr) {
|
meta.themes.get(function(err, themeArr) {
|
||||||
|
console.log(themeArr);
|
||||||
callback(themeArr);
|
callback(themeArr);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user