mirror of
https://github.com/TryGhost/Ghost.git
synced 2024-12-22 18:31:57 +03:00
4529ab514c
refs #10790 - Extracted 'setFromZip' method into themes services - Extracted 'activate' method - Extracted 'destroy' method - Extracted 'download' method - The method name here tries to follow 'setFrom...` convention we've agreed upon. So, in this case, we have get() which returns JSON response and getZip() which returns a file
33 lines
1.1 KiB
JavaScript
33 lines
1.1 KiB
JavaScript
const common = require('../../../server/lib/common');
|
|
const active = require('./active');
|
|
|
|
function activate(loadedTheme, checkedTheme, error) {
|
|
// no need to check the score, activation should be used in combination with validate.check
|
|
// Use the two theme objects to set the current active theme
|
|
try {
|
|
let previousGhostAPI;
|
|
|
|
if (active.get()) {
|
|
previousGhostAPI = active.get().engine('ghost-api');
|
|
}
|
|
|
|
active.set(loadedTheme, checkedTheme, error);
|
|
const currentGhostAPI = active.get().engine('ghost-api');
|
|
|
|
common.events.emit('services.themes.activated');
|
|
|
|
if (previousGhostAPI !== undefined && (previousGhostAPI !== currentGhostAPI)) {
|
|
common.events.emit('services.themes.api.changed');
|
|
const siteApp = require('../../../server/web/site/app');
|
|
siteApp.reload();
|
|
}
|
|
} catch (err) {
|
|
common.logging.error(new common.errors.InternalServerError({
|
|
message: common.i18n.t('errors.middleware.themehandler.activateFailed', {theme: loadedTheme.name}),
|
|
err: err
|
|
}));
|
|
}
|
|
}
|
|
|
|
module.exports = activate;
|