mirror of
https://github.com/TryGhost/Ghost.git
synced 2024-12-23 19:02:29 +03:00
04dd409243
refs https://github.com/TryGhost/Team/issues/1070 - added `@tryghost/custom-theme-settings-service` as a dependency - `core/server/services/custom-theme-settings` creates an instance of the new service passing in the model used for storing the setting keys/values and a cache instance - requiring `core/shared/services/custom-theme-settings-cache` creates a cache instance, it has no dependencies so can be required anywhere and the first require will initialize the shared instance - updated the theme activation bridge to trigger the theme settings service to sync the newly activated theme settings and populate the cache - updated theme validation to pass `labs` through as an option so that we get custom theme settings back as part of the checked theme as that's what is passed to the custom theme settings service
36 lines
1.6 KiB
JavaScript
36 lines
1.6 KiB
JavaScript
const debug = require('@tryghost/debug')('themes');
|
|
const bridge = require('../../../bridge');
|
|
const labs = require('../../../shared/labs');
|
|
const customThemeSettings = require('../custom-theme-settings');
|
|
|
|
/**
|
|
* These helper methods mean that the bridge is only required in one place
|
|
* And also adds a little debug statement, which is very handy when debugging theme logic
|
|
*/
|
|
module.exports = {
|
|
activateFromBoot: (themeName, theme, checkedTheme) => {
|
|
debug('Activating theme (method A on boot)', themeName);
|
|
// TODO: probably a better place for this to happen - after successful activation / when reloading site?
|
|
if (labs.isSet('customThemeSettings')) {
|
|
customThemeSettings.activateTheme(checkedTheme);
|
|
}
|
|
bridge.activateTheme(theme, checkedTheme);
|
|
},
|
|
activateFromAPI: (themeName, theme, checkedTheme) => {
|
|
debug('Activating theme (method B on API "activate")', themeName);
|
|
// TODO: probably a better place for this to happen - after successful activation / when reloading site?
|
|
if (labs.isSet('customThemeSettings')) {
|
|
customThemeSettings.activateTheme(checkedTheme);
|
|
}
|
|
bridge.activateTheme(theme, checkedTheme);
|
|
},
|
|
activateFromAPIOverride: (themeName, theme, checkedTheme) => {
|
|
debug('Activating theme (method C on API "override")', themeName);
|
|
// TODO: probably a better place for this to happen - after successful activation / when reloading site?
|
|
if (labs.isSet('customThemeSettings')) {
|
|
customThemeSettings.activateTheme(checkedTheme);
|
|
}
|
|
bridge.activateTheme(theme, checkedTheme);
|
|
}
|
|
};
|