mirror of
https://github.com/NodeBB/NodeBB.git
synced 2026-03-06 12:31:33 +01:00
Allowing theme to be re-ordered like plugins.
This commit is contained in:
@@ -72,7 +72,6 @@ Templates.compile = function(callback) {
|
||||
|
||||
coreTpls = !coreTpls ? [] : coreTpls.map(function(tpl) { return tpl.replace(coreTemplatesPath, ''); });
|
||||
baseTpls = !baseTpls ? [] : baseTpls.map(function(tpl) { return tpl.replace(baseTemplatesPath, ''); });
|
||||
themeTpls = !themeTpls ? [] : themeTpls.map(function(tpl) { return tpl.replace(themeTemplatesPath, ''); });
|
||||
|
||||
coreTpls.forEach(function(el, i) {
|
||||
paths[coreTpls[i]] = path.join(coreTemplatesPath, coreTpls[i]);
|
||||
@@ -82,9 +81,6 @@ Templates.compile = function(callback) {
|
||||
paths[baseTpls[i]] = path.join(baseTemplatesPath, baseTpls[i]);
|
||||
});
|
||||
|
||||
themeTpls.forEach(function(el, i) {
|
||||
paths[themeTpls[i]] = path.join(themeTemplatesPath, themeTpls[i]);
|
||||
});
|
||||
|
||||
for (var tpl in pluginTemplates) {
|
||||
if (pluginTemplates.hasOwnProperty(tpl)) {
|
||||
|
||||
@@ -8,7 +8,8 @@ var nconf = require('nconf'),
|
||||
async = require('async'),
|
||||
|
||||
file = require('../file'),
|
||||
db = require('../database');
|
||||
db = require('../database'),
|
||||
meta = require('../meta');
|
||||
|
||||
module.exports = function(Meta) {
|
||||
Meta.themes = {};
|
||||
@@ -76,6 +77,15 @@ module.exports = function(Meta) {
|
||||
switch(data.type) {
|
||||
case 'local':
|
||||
async.waterfall([
|
||||
async.apply(meta.configs.get, 'theme:id'),
|
||||
function(current, next) {
|
||||
async.series([
|
||||
async.apply(db.sortedSetRemove, 'plugins:active', current),
|
||||
async.apply(db.sortedSetAdd, 'plugins:active', 0, data.id)
|
||||
], function(err) {
|
||||
next(err);
|
||||
});
|
||||
},
|
||||
function(next) {
|
||||
fs.readFile(path.join(nconf.get('themes_path'), data.id, 'theme.json'), function(err, config) {
|
||||
if (!err) {
|
||||
|
||||
@@ -96,8 +96,6 @@ var fs = require('fs'),
|
||||
return next();
|
||||
}
|
||||
|
||||
plugins.push(meta.config['theme:id']);
|
||||
|
||||
plugins = plugins.filter(function(plugin){
|
||||
return plugin && typeof plugin === 'string';
|
||||
}).map(function(plugin){
|
||||
|
||||
@@ -10,7 +10,7 @@ var db = require('./database'),
|
||||
schemaDate, thisSchemaDate,
|
||||
|
||||
// IMPORTANT: REMEMBER TO UPDATE VALUE OF latestSchema
|
||||
latestSchema = Date.UTC(2015, 11, 23);
|
||||
latestSchema = Date.UTC(2016, 0, 11);
|
||||
|
||||
Upgrade.check = function(callback) {
|
||||
db.get('schemaDate', function(err, value) {
|
||||
@@ -278,6 +278,29 @@ Upgrade.upgrade = function(callback) {
|
||||
winston.info('[2015/12/23] Chats room hashes upgrade skipped!');
|
||||
next();
|
||||
}
|
||||
},
|
||||
function(next) {
|
||||
thisSchemaDate = Date.UTC(2016, 0, 11);
|
||||
|
||||
if (schemaDate < thisSchemaDate) {
|
||||
updatesMade = true;
|
||||
winston.info('[2015/12/23] Adding theme to active plugins sorted set');
|
||||
|
||||
async.waterfall([
|
||||
async.apply(db.getObjectField, 'config', 'theme:id'),
|
||||
async.apply(db.sortedSetAdd, 'plugins:active', 0)
|
||||
], function(err) {
|
||||
if (err) {
|
||||
return next(err);
|
||||
}
|
||||
|
||||
winston.info('[2015/12/23] Adding theme to active plugins sorted set done!');
|
||||
Upgrade.update(thisSchemaDate, next);
|
||||
})
|
||||
} else {
|
||||
winston.info('[2015/12/23] Adding theme to active plugins sorted set skipped!');
|
||||
next();
|
||||
}
|
||||
}
|
||||
// Add new schema updates here
|
||||
// IMPORTANT: REMEMBER TO UPDATE VALUE OF latestSchema IN LINE 24!!!
|
||||
|
||||
Reference in New Issue
Block a user