mirror of
https://github.com/TryGhost/Ghost.git
synced 2025-02-17 23:44:39 -05:00
Removed backwards compatibility for ghost_head
and ghost_foot
settings
refs https://github.com/TryGhost/Toolbox/issues/308 - these two settings are deprecated and we're removing all the code in v5 that kept supporting them
This commit is contained in:
parent
3b6cdc2bc5
commit
ae13b61cb0
6 changed files with 4 additions and 82 deletions
|
@ -71,14 +71,6 @@ module.exports = {
|
||||||
},
|
},
|
||||||
|
|
||||||
read(apiConfig, frame) {
|
read(apiConfig, frame) {
|
||||||
if (frame.options.key === 'ghost_head') {
|
|
||||||
frame.options.key = 'codeinjection_head';
|
|
||||||
}
|
|
||||||
|
|
||||||
if (frame.options.key === 'ghost_foot') {
|
|
||||||
frame.options.key = 'codeinjection_foot';
|
|
||||||
}
|
|
||||||
|
|
||||||
if (frame.options.key === 'active_timezone') {
|
if (frame.options.key === 'active_timezone') {
|
||||||
frame.options.key = 'timezone';
|
frame.options.key = 'timezone';
|
||||||
}
|
}
|
||||||
|
@ -141,14 +133,6 @@ module.exports = {
|
||||||
setting.value = setting.value === 'true';
|
setting.value = setting.value === 'true';
|
||||||
}
|
}
|
||||||
|
|
||||||
if (setting.key === 'ghost_head') {
|
|
||||||
setting.key = 'codeinjection_head';
|
|
||||||
}
|
|
||||||
|
|
||||||
if (setting.key === 'ghost_foot') {
|
|
||||||
setting.key = 'codeinjection_foot';
|
|
||||||
}
|
|
||||||
|
|
||||||
if (setting.key === 'active_timezone') {
|
if (setting.key === 'active_timezone') {
|
||||||
setting.key = 'timezone';
|
setting.key = 'timezone';
|
||||||
}
|
}
|
||||||
|
|
|
@ -12,7 +12,7 @@ module.exports = (attrs, frame) => {
|
||||||
// `forSettings` step. This logic can be rewritten once we get rid of deprecated
|
// `forSettings` step. This logic can be rewritten once we get rid of deprecated
|
||||||
// fields completely.
|
// fields completely.
|
||||||
if (_.isArray(attrs)) {
|
if (_.isArray(attrs)) {
|
||||||
const keysToFilter = ['ghost_head', 'ghost_foot'];
|
const keysToFilter = [];
|
||||||
|
|
||||||
// NOTE: to support edits of deprecated 'slack' setting artificial 'slack_url' and 'slack_username'
|
// NOTE: to support edits of deprecated 'slack' setting artificial 'slack_url' and 'slack_username'
|
||||||
// were added to the request body in the input serializer. These should not be returned in response
|
// were added to the request body in the input serializer. These should not be returned in response
|
||||||
|
|
|
@ -40,16 +40,6 @@ module.exports.forSettings = (attrs, frame) => {
|
||||||
if (_.isArray(attrs)) {
|
if (_.isArray(attrs)) {
|
||||||
// CASE: read single setting
|
// CASE: read single setting
|
||||||
if (frame.original.params && frame.original.params.key) {
|
if (frame.original.params && frame.original.params.key) {
|
||||||
if (frame.original.params.key === 'ghost_head') {
|
|
||||||
attrs[0].key = 'ghost_head';
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (frame.original.params.key === 'ghost_foot') {
|
|
||||||
attrs[0].key = 'ghost_foot';
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (frame.original.params.key === 'active_timezone') {
|
if (frame.original.params.key === 'active_timezone') {
|
||||||
attrs[0].key = 'active_timezone';
|
attrs[0].key = 'active_timezone';
|
||||||
return;
|
return;
|
||||||
|
@ -76,13 +66,7 @@ module.exports.forSettings = (attrs, frame) => {
|
||||||
// CASE: edit
|
// CASE: edit
|
||||||
if (frame.original.body && frame.original.body.settings) {
|
if (frame.original.body && frame.original.body.settings) {
|
||||||
frame.original.body.settings.forEach((setting) => {
|
frame.original.body.settings.forEach((setting) => {
|
||||||
if (setting.key === 'ghost_head') {
|
if (setting.key === 'active_timezone') {
|
||||||
const target = _.find(attrs, {key: 'codeinjection_head'});
|
|
||||||
target.key = 'ghost_head';
|
|
||||||
} else if (setting.key === 'ghost_foot') {
|
|
||||||
const target = _.find(attrs, {key: 'codeinjection_foot'});
|
|
||||||
target.key = 'ghost_foot';
|
|
||||||
} else if (setting.key === 'active_timezone') {
|
|
||||||
const target = _.find(attrs, {key: 'timezone'});
|
const target = _.find(attrs, {key: 'timezone'});
|
||||||
target.key = 'active_timezone';
|
target.key = 'active_timezone';
|
||||||
} else if (setting.key === 'default_locale') {
|
} else if (setting.key === 'default_locale') {
|
||||||
|
@ -112,24 +96,12 @@ module.exports.forSettings = (attrs, frame) => {
|
||||||
}
|
}
|
||||||
|
|
||||||
// CASE: browse all settings, add extra keys and keep deprecated
|
// CASE: browse all settings, add extra keys and keep deprecated
|
||||||
const ghostHead = _.cloneDeep(_.find(attrs, {key: 'codeinjection_head'}));
|
|
||||||
const ghostFoot = _.cloneDeep(_.find(attrs, {key: 'codeinjection_foot'}));
|
|
||||||
const timezone = _.cloneDeep(_.find(attrs, {key: 'timezone'}));
|
const timezone = _.cloneDeep(_.find(attrs, {key: 'timezone'}));
|
||||||
const lang = _.cloneDeep(_.find(attrs, {key: 'lang'}));
|
const lang = _.cloneDeep(_.find(attrs, {key: 'lang'}));
|
||||||
const slackURL = _.cloneDeep(_.find(attrs, {key: 'slack_url'}));
|
const slackURL = _.cloneDeep(_.find(attrs, {key: 'slack_url'}));
|
||||||
const slackUsername = _.cloneDeep(_.find(attrs, {key: 'slack_username'}));
|
const slackUsername = _.cloneDeep(_.find(attrs, {key: 'slack_username'}));
|
||||||
const locale = _.cloneDeep(_.find(attrs, {key: 'lang'}));
|
const locale = _.cloneDeep(_.find(attrs, {key: 'lang'}));
|
||||||
|
|
||||||
if (ghostHead) {
|
|
||||||
ghostHead.key = 'ghost_head';
|
|
||||||
attrs.push(ghostHead);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (ghostFoot) {
|
|
||||||
ghostFoot.key = 'ghost_foot';
|
|
||||||
attrs.push(ghostFoot);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (timezone) {
|
if (timezone) {
|
||||||
timezone.key = 'active_timezone';
|
timezone.key = 'active_timezone';
|
||||||
attrs.push(timezone);
|
attrs.push(timezone);
|
||||||
|
|
|
@ -1,7 +1,6 @@
|
||||||
const Promise = require('bluebird');
|
const Promise = require('bluebird');
|
||||||
const _ = require('lodash');
|
const _ = require('lodash');
|
||||||
const tpl = require('@tryghost/tpl');
|
const {ValidationError, BadRequestError} = require('@tryghost/errors');
|
||||||
const {NotFoundError, ValidationError, BadRequestError} = require('@tryghost/errors');
|
|
||||||
const validator = require('@tryghost/validator');
|
const validator = require('@tryghost/validator');
|
||||||
|
|
||||||
const messages = {
|
const messages = {
|
||||||
|
@ -11,30 +10,10 @@ const messages = {
|
||||||
};
|
};
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
read(apiConfig, frame) {
|
|
||||||
// @NOTE: was removed https://github.com/TryGhost/Ghost/issues/10373
|
|
||||||
if (frame.options.key === 'ghost_head' || frame.options.key === 'ghost_foot') {
|
|
||||||
return Promise.reject(new NotFoundError({
|
|
||||||
message: tpl(messages.problemFindingSetting, {
|
|
||||||
key: frame.options.key
|
|
||||||
})
|
|
||||||
}));
|
|
||||||
}
|
|
||||||
},
|
|
||||||
|
|
||||||
edit(apiConfig, frame) {
|
edit(apiConfig, frame) {
|
||||||
const errors = [];
|
const errors = [];
|
||||||
|
|
||||||
_.each(frame.data.settings, (setting) => {
|
_.each(frame.data.settings, (setting) => {
|
||||||
if (setting.key === 'ghost_head' || setting.key === 'ghost_foot') {
|
|
||||||
// @NOTE: was removed https://github.com/TryGhost/Ghost/issues/10373
|
|
||||||
errors.push(new NotFoundError({
|
|
||||||
message: tpl(messages.problemFindingSetting, {
|
|
||||||
key: setting.key
|
|
||||||
})
|
|
||||||
}));
|
|
||||||
}
|
|
||||||
|
|
||||||
// TODO: the below array is INCOMPLETE
|
// TODO: the below array is INCOMPLETE
|
||||||
// it should include all setting values that have array as a type
|
// it should include all setting values that have array as a type
|
||||||
const arrayTypeSettings = [
|
const arrayTypeSettings = [
|
||||||
|
|
|
@ -15,9 +15,7 @@ const ignoredSettings = ['slack_url', 'members_from_address', 'members_support_a
|
||||||
// NOTE: drop support in Ghost 5.0
|
// NOTE: drop support in Ghost 5.0
|
||||||
const deprecatedSupportedSettingsMap = {
|
const deprecatedSupportedSettingsMap = {
|
||||||
default_locale: 'lang',
|
default_locale: 'lang',
|
||||||
active_timezone: 'timezone',
|
active_timezone: 'timezone'
|
||||||
ghost_head: 'codeinjection_head',
|
|
||||||
ghost_foot: 'codeinjection_foot'
|
|
||||||
};
|
};
|
||||||
const deprecatedSupportedSettingsOneToManyMap = {
|
const deprecatedSupportedSettingsOneToManyMap = {
|
||||||
// NOTE: intentionally ignoring slack_url setting
|
// NOTE: intentionally ignoring slack_url setting
|
||||||
|
|
|
@ -908,11 +908,6 @@ describe('Importer', function () {
|
||||||
value: 'Pacific/Auckland'
|
value: 'Pacific/Auckland'
|
||||||
});
|
});
|
||||||
|
|
||||||
exportData.data.settings[2] = testUtils.DataGenerator.forKnex.createSetting({
|
|
||||||
key: 'ghost_foot',
|
|
||||||
value: 'AVADA KEDAVRA'
|
|
||||||
});
|
|
||||||
|
|
||||||
return dataImporter.doImport(exportData, importOptions)
|
return dataImporter.doImport(exportData, importOptions)
|
||||||
.then(function (imported) {
|
.then(function (imported) {
|
||||||
imported.problems.length.should.eql(0);
|
imported.problems.length.should.eql(0);
|
||||||
|
@ -926,12 +921,6 @@ describe('Importer', function () {
|
||||||
})
|
})
|
||||||
.then(function (result) {
|
.then(function (result) {
|
||||||
result.attributes.value.should.eql('Pacific/Auckland');
|
result.attributes.value.should.eql('Pacific/Auckland');
|
||||||
})
|
|
||||||
.then(function () {
|
|
||||||
return models.Settings.findOne(_.merge({key: 'codeinjection_foot'}, testUtils.context.internal));
|
|
||||||
})
|
|
||||||
.then(function (result) {
|
|
||||||
result.attributes.value.should.eql('AVADA KEDAVRA');
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue