Exposed comments_enabled setting publicly

refs https://github.com/TryGhost/Team/issues/1664
This also means that themes have access to this setting
This commit is contained in:
Fabien "egg" O'Carroll 2022-07-07 12:55:31 +02:00 committed by Simon Backx
parent 41a8134c40
commit 6a8c6e9081
5 changed files with 23 additions and 6 deletions

View File

@ -36,7 +36,11 @@ async function updateGlobalTemplateOptions(req, res, next) {
{
hbs.updateTemplateOptions({
data: {
site: siteData,
site: {
...siteData,
comments_enabled: siteData.comments_enabled !== 'off',
comments_access: siteData.comments_enabled
},
labs: labsData,
config: themeData,
custom: themeSettingsData

View File

@ -36,5 +36,6 @@ module.exports = {
portal_button_icon: 'portal_button_icon',
portal_plans: 'portal_plans',
portal_name: 'portal_name',
portal_button: 'portal_button'
portal_button: 'portal_button',
comments_enabled: 'comments_enabled'
};

View File

@ -7,6 +7,7 @@ Object {
"accent_color": "#FF1A75",
"codeinjection_foot": null,
"codeinjection_head": null,
"comments_enabled": null,
"cover_image": "https://static.ghost.org/v4.0.0/images/publication-cover.jpg",
"description": "Thoughts, stories and ideas",
"facebook": "ghost",

View File

@ -485,6 +485,7 @@ Object {
"accent_color": "#FF1A75",
"codeinjection_foot": null,
"codeinjection_head": null,
"comments_enabled": null,
"cover_image": "https://static.ghost.org/v4.0.0/images/publication-cover.jpg",
"description": "Thoughts, stories and ideas",
"facebook": "ghost",
@ -578,6 +579,7 @@ Object {
"accent_color": "#FF1A75",
"codeinjection_foot": null,
"codeinjection_head": null,
"comments_enabled": null,
"cover_image": "https://static.ghost.org/v4.0.0/images/publication-cover.jpg",
"description": "Thoughts, stories and ideas",
"facebook": "ghost",

View File

@ -49,7 +49,9 @@ describe('Themes middleware', function () {
fakeActiveThemeName = 'bacon-sensation';
fakeSiteData = {};
fakeSiteData = {
comments_enabled: 'all'
};
fakeLabsData = {
// labs data is deep cloned,
@ -159,9 +161,16 @@ describe('Themes middleware', function () {
// Check labs config
should.deepEqual(data.labs, fakeLabsData);
should.equal(data.site, fakeSiteData);
should.exist(data.site.signup_url);
data.site.signup_url.should.equal('#/portal');
should.deepEqual(data.site, {
...fakeSiteData,
// signup_url should get added
signup_url: '#/portal',
// the comments_enabled setting should be mapped to comments_access, and comments_enabled should be a boolean
comments_enabled: true,
comments_access: 'all'
});
should.deepEqual(data.custom, fakeCustomThemeSettingsData);