0
Fork 0
mirror of https://github.com/TryGhost/Ghost.git synced 2025-04-15 03:01:37 -05:00

Added setting for newsletter footer content (#12359)

no-issue

We want to give users to ability to customise the content of their newsletter, and the first step
toward that is a setting in which we can store text or html to embed in the template
This commit is contained in:
Fabien 'egg' O'Carroll 2020-11-13 13:18:47 +00:00 committed by GitHub
parent d7a0833821
commit 3f9053ae94
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
8 changed files with 16 additions and 6 deletions

View file

@ -4,9 +4,9 @@ const {createTransactionalMigration} = require('../../utils');
module.exports = createTransactionalMigration(
async function up(connection) {
logging.info('Updating newsletter settings - newsletter_show_badge, newsletter_show_header, newsletter_body_font_category - to newsletter group');
logging.info('Updating newsletter settings - newsletter_show_badge, newsletter_show_header, newsletter_body_font_category, newsletter_footer_content - to newsletter group');
await connection('settings')
.whereIn('key', ['newsletter_show_badge', 'newsletter_show_header', 'newsletter_body_font_category'])
.whereIn('key', ['newsletter_show_badge', 'newsletter_show_header', 'newsletter_body_font_category', 'newsletter_footer_content'])
.update({
group: 'newsletter'
});

View file

@ -423,6 +423,10 @@
]
},
"type": "string"
},
"newsletter_footer_content": {
"defaultValue": "",
"type": "string"
}
}
}

View file

@ -155,7 +155,8 @@ const serialize = async (postModel, options = {isBrowserPreview: false}) => {
const templateSettings = {
showSiteHeader: settingsCache.get('newsletter_show_header'),
bodyFontCategory: settingsCache.get('newsletter_body_font_category'),
showBadge: settingsCache.get('newsletter_show_badge')
showBadge: settingsCache.get('newsletter_show_badge'),
footerContent: settingsCache.get('newsletter_footer_content')
};
let htmlTemplate = template({post, site: getSite(), templateSettings});
if (options.isBrowserPreview) {

View file

@ -1,4 +1,5 @@
/* eslint indent: warn, no-irregular-whitespace: warn */
const iff = (cond, yes, no) => (cond ? yes : no);
module.exports = ({post, site, templateSettings}) => {
const date = new Date();
return `<!doctype html>
@ -922,6 +923,7 @@ ${ templateSettings.showBadge ? `
<tr>
<td class="wrapper" align="center">
<table role="presentation" border="0" cellpadding="0" cellspacing="0" width="100%">
${iff(!!templateSettings.footerContent, `<tr><td class="footer">${templateSettings.footerContent}</td></tr>`, '')}
<tr>
<td class="footer">${site.title} &copy; ${date.getFullYear()} <a href="%recipient.unsubscribe_url%">Unsubscribe</a></td>
</tr>

View file

@ -68,7 +68,8 @@ const defaultSettingsKeyTypes = [
{key: 'accent_color', type: 'blog'},
{key: 'newsletter_show_badge', type: 'newsletter'},
{key: 'newsletter_show_header', type: 'newsletter'},
{key: 'newsletter_body_font_category', type: 'newsletter'}
{key: 'newsletter_body_font_category', type: 'newsletter'},
{key: 'newsletter_footer_content', type: 'newsletter'}
];
describe('Settings API (canary)', function () {

View file

@ -66,6 +66,7 @@ const defaultSettingsKeyTypes = [
{key: 'default_locale', type: 'blog'},
{key: 'newsletter_show_badge', type: 'newsletter'},
{key: 'newsletter_show_header', type: 'newsletter'},
{key: 'newsletter_footer_content', type: 'newsletter'},
{key: 'newsletter_body_font_category', type: 'newsletter'}
];

View file

@ -68,7 +68,8 @@ const defaultSettingsKeys = [
'accent_color',
'newsletter_show_badge',
'newsletter_show_header',
'newsletter_body_font_category'
'newsletter_body_font_category',
'newsletter_footer_content'
];
describe('Settings API (v3)', function () {

View file

@ -34,7 +34,7 @@ describe('DB version integrity', function () {
// Only these variables should need updating
const currentSchemaHash = '102b04bbd38cd2451fbf0957ffc35b30';
const currentFixturesHash = 'd46d696c94d03e41a5903500547fea77';
const currentSettingsHash = '229360069a9c77a945727a3c5869c3c6';
const currentSettingsHash = '7090015734403bd6cb16a7d2ad88a539';
const currentRoutesHash = '3d180d52c663d173a6be791ef411ed01';
// If this test is failing, then it is likely a change has been made that requires a DB version bump,