0
Fork 0
mirror of https://github.com/TryGhost/Ghost.git synced 2025-02-03 23:00:14 -05:00

Added accent color to helper

refs https://github.com/TryGhost/Team/issues/1664
This commit is contained in:
Peter Zimon 2022-07-08 10:43:51 +02:00 committed by Simon Backx
parent 129836f52e
commit 7a4ae08b44
2 changed files with 65 additions and 1 deletions

View file

@ -20,6 +20,11 @@ async function comments(options) {
avatarSaturation = 50;
}
let accentColor = '';
if (options.data.site.accent_color) {
accentColor = options.data.site.accent_color;
}
const frontendKey = await getFrontendKey();
const data = {
@ -30,7 +35,8 @@ async function comments(options) {
'post-id': this.id,
'sentry-dsn': '', /* todo: insert sentry dsn key here */
'color-scheme': colorScheme,
'avatar-saturation': avatarSaturation
'avatar-saturation': avatarSaturation,
'accent-color': accentColor
};
let dataAttributes = '';

View file

@ -0,0 +1,58 @@
const should = require('should');
const sinon = require('sinon');
const configUtils = require('../../../utils/configUtils');
const {mockManager} = require('../../../utils/e2e-framework');
const comments = require('../../../../core/frontend/helpers/comments');
const proxy = require('../../../../core/frontend/services/proxy');
const {settingsCache} = proxy;
describe('{{comments}} helper', function () {
let keyStub;
before(function () {
keyStub = sinon.stub().resolves('xyz');
const dataService = {
getFrontendKey: keyStub
};
proxy.init({dataService});
});
beforeEach(function () {
mockManager.mockMail();
mockManager.mockLabsEnabled('comments');
sinon.stub(settingsCache, 'get');
});
afterEach(function () {
mockManager.restore();
sinon.restore();
configUtils.restore();
});
it('returns undefined if not used withing post context', function (done) {
settingsCache.get.withArgs('members_enabled').returns(true);
comments({}).then(function (rendered) {
should.not.exist(rendered);
done();
}).catch(done);
});
it('returns a script tag', async function () {
settingsCache.get.withArgs('members_enabled').returns(true);
const rendered = await comments.call({
comment_id: 'post_test',
id: 'post_id_123'
}, {
hash: {},
data: {
site: {}
}
});
should.exist(rendered);
rendered.string.should.containEql('<script defer src="https://unpkg.com/@tryghost/comments-ui');
rendered.string.should.containEql('data-ghost-comments="http://127.0.0.1:2369/" data-api="http://127.0.0.1:2369/ghost/api/content/" data-admin="http://127.0.0.1:2369/ghost/" data-key="xyz" data-post-id="post_id_123" data-sentry-dsn="" data-color-scheme="auto" data-avatar-saturation="50" data-accent-color=""');
});
});