mirror of
https://github.com/TryGhost/Ghost.git
synced 2024-12-21 09:52:06 +03:00
25b0657784
no issue If Ghost was booted or a theme activated with the `customThemeSettings` flag disabled but with a theme that has custom settings, enabling the flag later on wouldn't show the settings in Admin or make the settings available in the front-end. Similarly, disabling `customThemeSettings` when Ghost had been booted/or theme activated with it enabled meant that settings were still available on the front-end. - added an event listener for `settings.labs.edited` that fully re-activates a theme so that it's passed through gscan again and the custom theme settings passed back are included/excluded based on the flag value and any required settings sync with the database is performed
55 lines
1.7 KiB
JavaScript
55 lines
1.7 KiB
JavaScript
const activate = require('./activate');
|
|
const themeLoader = require('./loader');
|
|
const storage = require('./storage');
|
|
const getJSON = require('./to-json');
|
|
const installer = require('./installer');
|
|
|
|
const settingsCache = require('../../../shared/settings-cache');
|
|
|
|
// Needed for theme re-activation after customThemeSettings flag is toggled
|
|
// @TODO: remove when customThemeSettings flag is removed
|
|
const labs = require('../../../shared/labs');
|
|
const events = require('../../lib/common/events');
|
|
let _lastLabsValue;
|
|
|
|
module.exports = {
|
|
/*
|
|
* Load the currently active theme
|
|
*/
|
|
init: async () => {
|
|
const themeName = settingsCache.get('active_theme');
|
|
|
|
/**
|
|
* When customThemeSettings labs flag is toggled we need to re-validate and activate
|
|
* the active theme so that it's settings are read and synced
|
|
*
|
|
* @TODO: remove when customThemeSettings labs flag is removed
|
|
*/
|
|
_lastLabsValue = labs.isSet('customThemeSettings');
|
|
events.on('settings.labs.edited', () => {
|
|
if (labs.isSet('customThemeSettings') !== _lastLabsValue) {
|
|
_lastLabsValue = labs.isSet('customThemeSettings');
|
|
|
|
activate.activate(settingsCache.get('active_theme'));
|
|
}
|
|
});
|
|
|
|
return activate.loadAndActivate(themeName);
|
|
},
|
|
/**
|
|
* Load all inactive themes
|
|
*/
|
|
loadInactiveThemes: themeLoader.loadAllThemes,
|
|
/**
|
|
* Methods used in the API
|
|
*/
|
|
api: {
|
|
getJSON,
|
|
activate: activate.activate,
|
|
getZip: storage.getZip,
|
|
setFromZip: storage.setFromZip,
|
|
installFromGithub: installer.installFromGithub,
|
|
destroy: storage.destroy
|
|
}
|
|
};
|