Baris Soner Usakli 12 years ago
commit 928594fc7c

@ -39,7 +39,7 @@ var nodebb_admin = (function(nodebb_admin) {
(function() { (function() {
var scriptEl = document.createElement('script'); var scriptEl = document.createElement('script');
scriptEl.src = 'http://api.bootswatch.com/2/?callback=nodebb_admin.themes.render'; scriptEl.src = 'http://api.bootswatch.com/3/?callback=nodebb_admin.themes.render';
document.body.appendChild(scriptEl); document.body.appendChild(scriptEl);
var bootstrapThemeContainer = document.querySelector('#bootstrap_themes'), var bootstrapThemeContainer = document.querySelector('#bootstrap_themes'),
@ -94,7 +94,7 @@ var nodebb_admin = (function(nodebb_admin) {
'<div>' + '<div>' +
'<div class="pull-right">' + '<div class="pull-right">' +
'<button class="btn btn-primary" data-action="use">Use</button> ' + '<button class="btn btn-primary" data-action="use">Use</button> ' +
'<button class="btn" data-action="preview">Preview</button>' + '<button class="btn btn-default" data-action="preview">Preview</button>' +
'</div>' + '</div>' +
'<h4>' + themes[x].name + '</h4>' + '<h4>' + themes[x].name + '</h4>' +
'<p>' + '<p>' +

@ -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';
} else next(); next(err, configObj);
}); });
} else next(); } else next();
}, function(err, themes) {
themes = themes.filter(function(theme) {
return (theme !== undefined);
});
callback(null, themes);
}); });
}, function(err) {
callback(err, themeArr);
}); });
}); });
} }

Loading…
Cancel
Save