0
Fork 0
mirror of https://github.com/TryGhost/Ghost.git synced 2025-02-10 23:36:14 -05:00
ghost/core/server/services/themes/activation-bridge.js

36 lines
1.6 KiB
JavaScript
Raw Normal View History

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.api.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.api.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.api.activateTheme(checkedTheme);
}
bridge.activateTheme(theme, checkedTheme);
}
};