mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-11-06 22:15:48 +01:00
introduction of theme engine parsing (themes go in /public/themes!)
This commit is contained in:
37
src/meta.js
37
src/meta.js
@@ -1,6 +1,8 @@
|
||||
var utils = require('./../public/src/utils.js'),
|
||||
RDB = require('./redis.js'),
|
||||
async = require('async');
|
||||
async = require('async'),
|
||||
path = require('path'),
|
||||
fs = require('fs');
|
||||
|
||||
(function(Meta) {
|
||||
Meta.config = {
|
||||
@@ -42,4 +44,37 @@ var utils = require('./../public/src/utils.js'),
|
||||
RDB.hdel('config', field);
|
||||
}
|
||||
}
|
||||
|
||||
Meta.themes = {
|
||||
get: function(callback) {
|
||||
var themePath = path.join(__dirname, '../', 'public/themes');
|
||||
fs.readdir(themePath, function(err, files) {
|
||||
var themeArr = [];
|
||||
async.each(files, function(file, next) {
|
||||
fs.lstat(path.join(themePath, file), function(err, stats) {
|
||||
if(stats.isDirectory()) {
|
||||
var themeDir = file,
|
||||
themeConfPath = path.join(themePath, themeDir, 'theme.json');
|
||||
|
||||
fs.exists(themeConfPath, function(exists) {
|
||||
if (exists) {
|
||||
fs.readFile(themeConfPath, function(err, conf) {
|
||||
conf = JSON.parse(conf);
|
||||
conf.src = global.nconf.get('url') + 'themes/' + themeDir + '/' + conf.src;
|
||||
themeArr.push(conf);
|
||||
next();
|
||||
});
|
||||
}
|
||||
});
|
||||
} else next();
|
||||
});
|
||||
}, function(err) {
|
||||
callback(err, themeArr);
|
||||
});
|
||||
});
|
||||
},
|
||||
saveViaGithub: function(repo_url, callback) {
|
||||
// ...
|
||||
}
|
||||
}
|
||||
}(exports));
|
||||
Reference in New Issue
Block a user