|
|
@ -86,31 +86,28 @@ async function getThemes(themePath) {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
Themes.set = async (data) => {
|
|
|
|
Themes.set = async (data) => {
|
|
|
|
const themeData = {
|
|
|
|
|
|
|
|
'theme:type': data.type,
|
|
|
|
|
|
|
|
'theme:id': data.id,
|
|
|
|
|
|
|
|
'theme:staticDir': '',
|
|
|
|
|
|
|
|
'theme:templates': '',
|
|
|
|
|
|
|
|
'theme:src': '',
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
switch (data.type) {
|
|
|
|
switch (data.type) {
|
|
|
|
case 'local': {
|
|
|
|
case 'local': {
|
|
|
|
const current = await Meta.configs.get('theme:id');
|
|
|
|
const current = await Meta.configs.get('theme:id');
|
|
|
|
var config = await fsReadfile(path.join(nconf.get('themes_path'), data.id, 'theme.json'), 'utf8');
|
|
|
|
if (current !== data.id) {
|
|
|
|
|
|
|
|
let config = await fsReadfile(path.join(nconf.get('themes_path'), data.id, 'theme.json'), 'utf8');
|
|
|
|
config = JSON.parse(config);
|
|
|
|
config = JSON.parse(config);
|
|
|
|
await db.sortedSetRemove('plugins:active', current);
|
|
|
|
|
|
|
|
await db.sortedSetAdd('plugins:active', 0, data.id);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
await db.sortedSetRemove('plugins:active', current);
|
|
|
|
|
|
|
|
const numPlugins = await db.sortedSetCard('plugins:active');
|
|
|
|
|
|
|
|
await db.sortedSetAdd('plugins:active', numPlugins, data.id);
|
|
|
|
// Re-set the themes path (for when NodeBB is reloaded)
|
|
|
|
// Re-set the themes path (for when NodeBB is reloaded)
|
|
|
|
Themes.setPath(config);
|
|
|
|
Themes.setPath(config);
|
|
|
|
|
|
|
|
|
|
|
|
themeData['theme:staticDir'] = config.staticDir ? config.staticDir : '';
|
|
|
|
await Meta.configs.setMultiple({
|
|
|
|
themeData['theme:templates'] = config.templates ? config.templates : '';
|
|
|
|
'theme:type': data.type,
|
|
|
|
themeData['theme:src'] = '';
|
|
|
|
'theme:id': data.id,
|
|
|
|
themeData.bootswatchSkin = '';
|
|
|
|
'theme:staticDir': config.staticDir ? config.staticDir : '',
|
|
|
|
|
|
|
|
'theme:templates': config.templates ? config.templates : '',
|
|
|
|
|
|
|
|
'theme:src': '',
|
|
|
|
|
|
|
|
bootswatchSkin: '',
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
await Meta.configs.setMultiple(themeData);
|
|
|
|
|
|
|
|
await events.log({
|
|
|
|
await events.log({
|
|
|
|
type: 'theme-set',
|
|
|
|
type: 'theme-set',
|
|
|
|
uid: parseInt(data.uid, 10) || 0,
|
|
|
|
uid: parseInt(data.uid, 10) || 0,
|
|
|
@ -119,6 +116,7 @@ Themes.set = async (data) => {
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
Meta.reloadRequired = true;
|
|
|
|
Meta.reloadRequired = true;
|
|
|
|
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
case 'bootswatch':
|
|
|
|
case 'bootswatch':
|
|
|
|