From fa3686bcc38160d541ce206e270d53feb4762577 Mon Sep 17 00:00:00 2001 From: Rishabh Garg Date: Tue, 17 Dec 2019 16:15:31 +0530 Subject: [PATCH] =?UTF-8?q?=E2=9C=A8=20Added=20new=20brand=20blog=20settin?= =?UTF-8?q?g=20(#11408)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit no issue Adds new `brand: {primary_color: ''}` blog setting behind dev flag for setting user-defined brand color in themes and emails. --- .../api/canary/utils/serializers/output/utils/mapper.js | 7 +++++++ core/server/data/schema/default-settings.json | 3 +++ core/server/services/settings/public.js | 1 + core/test/acceptance/content/settings_spec.js | 2 +- 4 files changed, 12 insertions(+), 1 deletion(-) diff --git a/core/server/api/canary/utils/serializers/output/utils/mapper.js b/core/server/api/canary/utils/serializers/output/utils/mapper.js index 5f589f531e..4c3398f016 100644 --- a/core/server/api/canary/utils/serializers/output/utils/mapper.js +++ b/core/server/api/canary/utils/serializers/output/utils/mapper.js @@ -6,6 +6,7 @@ const gating = require('./post-gating'); const clean = require('./clean'); const extraAttrs = require('./extra-attrs'); const postsMetaSchema = require('../../../../../../data/schema').tables.posts_meta; +const config = require('../../../../../../config'); const mapUser = (model, frame) => { const jsonModel = model.toJSON ? model.toJSON(frame.options) : model; @@ -99,11 +100,17 @@ const mapSettings = (attrs, frame) => { // fields completely. if (_.isArray(attrs)) { attrs = _.filter(attrs, (o) => { + if (o.key === 'brand' && !config.get('enableDeveloperExperiments')) { + return false; + } return o.key !== 'ghost_head' && o.key !== 'ghost_foot'; }); } else { delete attrs.ghost_head; delete attrs.ghost_foot; + if (!config.get('enableDeveloperExperiments')) { + delete attrs.brand; + } } return attrs; diff --git a/core/server/data/schema/default-settings.json b/core/server/data/schema/default-settings.json index fcedd13ac0..7981fec1a0 100644 --- a/core/server/data/schema/default-settings.json +++ b/core/server/data/schema/default-settings.json @@ -42,6 +42,9 @@ "icon": { "defaultValue": "" }, + "brand": { + "defaultValue": "{\"primaryColor\":\"\"}" + }, "default_locale": { "defaultValue": "en", "validations": { diff --git a/core/server/services/settings/public.js b/core/server/services/settings/public.js index 58f8f25f9d..0925cdc533 100644 --- a/core/server/services/settings/public.js +++ b/core/server/services/settings/public.js @@ -11,6 +11,7 @@ module.exports = { description: 'description', logo: 'logo', icon: 'icon', + brand: 'brand', cover_image: 'cover_image', facebook: 'facebook', twitter: 'twitter', diff --git a/core/test/acceptance/content/settings_spec.js b/core/test/acceptance/content/settings_spec.js index d146496ddd..edbe0eb90a 100644 --- a/core/test/acceptance/content/settings_spec.js +++ b/core/test/acceptance/content/settings_spec.js @@ -43,7 +43,7 @@ describe('Settings Content API', function () { // Verify we have the right keys for settings const publicProperties = _.filter(_.values(publicSettings), (o) => { - return (o !== 'ghost_head' && o !== 'ghost_foot'); + return (o !== 'ghost_head' && o !== 'ghost_foot' && o !== 'brand'); }); publicProperties.push('codeinjection_head', 'codeinjection_foot'); settings.should.have.properties(publicProperties);