Added native comments (#15223)

no issue

- Removes the comments lab flag (bumping it to GA).
- Bumps comments-ui to v0.8
This commit is contained in:
Simon Backx 2022-08-12 16:06:06 +02:00 committed by GitHub
parent 77e4be6b81
commit 27df4e536f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
12 changed files with 31 additions and 83 deletions

View File

@ -58,7 +58,6 @@ export default class FeatureService extends Service {
// labs flags
@feature('urlCache') urlCache;
@feature('beforeAfterCard') beforeAfterCard;
@feature('comments') comments;
@feature('newsletterPaywall') newsletterPaywall;
@feature('freeTrial') freeTrial;

View File

@ -213,19 +213,6 @@
</div>
</div>
</div>
<div class="gh-expandable-block">
<div class="gh-expandable-header">
<div>
<h4 class="gh-expandable-title">Comments</h4>
<p class="gh-expandable-description">
Enable comments
</p>
</div>
<div class="for-switch">
<GhFeatureFlag @flag="comments" />
</div>
</div>
</div>
<div class="gh-expandable-block">
<div class="gh-expandable-header">
<div>

View File

@ -24,9 +24,6 @@
<div class="gh-setting-members-basicsform">
<p class="intro">Fund your work with subscription revenue. Connect your Stripe account and offer premium content to your audience. Our creators are already making over $12 million per year, while <strong>Ghost takes 0% payment fees</strong>.</p>
{{#if (not (feature 'comments'))}}
<hr>
{{/if}}
<div class="flex flex-column justify-between mt3">
<section class="gh-expandable gh-setting-members-portalcta">
<div class="gh-expandable-block">
@ -47,9 +44,7 @@
<div class="gh-setting-rich-dropdown">
<Settings::MembersSubscriptionAccess @onChange={{this.membersSubscriptionAccessChanged}} />
<Settings::MembersDefaultPostAccess />
{{#if (feature 'comments')}}
<Settings::MembersCommentAccess />
{{/if}}
</div>
</div>
</div>

View File

@ -297,7 +297,6 @@
</p>
</GhFormGroup>
{{#if (feature 'comments')}}
<div class="user-settings-subgroup">
<h4 class="user-settings-heading">Email notifications</h4>
<GhFormGroup @errors={{this.user.errors}} @hasValidated={{this.user.hasValidated}} @property="email">
@ -322,8 +321,6 @@
</div>
</GhFormGroup>
</div>
{{/if}}
</fieldset>
</div>

View File

@ -1,8 +1,7 @@
const {SafeString} = require('../services/handlebars');
const {labs} = require('../services/proxy');
const {html} = require('common-tags');
function commentCount(options) {
module.exports = function commentCount(options) {
const empty = options.hash.empty === undefined ? '' : options.hash.empty;
const singular = options.hash.singular === undefined ? 'comment' : options.hash.singular;
const plural = options.hash.plural === undefined ? 'comments' : options.hash.plural;
@ -21,17 +20,4 @@ function commentCount(options) {
>
</script>
`);
}
module.exports = function commentsLabsWrapper() {
const self = this;
const args = arguments;
return labs.enabledHelper({
flagKey: 'comments',
flagName: 'Comments',
helperName: 'comment_count'
}, () => {
return commentCount.apply(self, args);
});
};

View File

@ -1,8 +1,8 @@
const {SafeString} = require('../services/handlebars');
const {urlUtils, getFrontendKey, labs, settingsCache} = require('../services/proxy');
const {urlUtils, getFrontendKey, settingsCache} = require('../services/proxy');
const {getFrontendAppConfig, getDataAttributes} = require('../utils/frontend-apps');
async function comments(options) {
module.exports = async function comments(options) {
// todo: For now check on the comment id to exclude normal pages (we probably have a better way to do this)
const commentId = this.comment_id;
@ -75,19 +75,6 @@ async function comments(options) {
return new SafeString(`
<script defer src="${scriptUrl}" ${dataAttributes} crossorigin="anonymous"></script>
`);
}
module.exports = async function commentsLabsWrapper() {
const self = this;
const args = arguments;
return labs.enabledHelper({
flagKey: 'comments',
flagName: 'Comments',
helperName: 'comments'
}, () => {
return comments.apply(self, args);
});
};
module.exports.async = true;

View File

@ -229,7 +229,7 @@ module.exports = async function ghost_head(options) { // eslint-disable-line cam
head.push(`<link rel="stylesheet" type="text/css" href="${getAssetUrl('public/cards.min.css')}">`);
}
if (labs.isSet('comments') && settingsCache.get('enable_comments') !== 'off') {
if (settingsCache.get('enable_comments') !== 'off') {
head.push(`<script defer src="${getAssetUrl('public/comment-counts.min.js')}" data-ghost-comments-counts-api="${urlUtils.getSiteUrl(true)}members/api/comments/counts/"></script>`);
}

View File

@ -147,7 +147,7 @@
"comments": {
"url": "https://cdn.jsdelivr.net/npm/@tryghost/comments-ui@~{version}/umd/comments-ui.min.js",
"styles": "https://cdn.jsdelivr.net/npm/@tryghost/comments-ui@~{version}/umd/main.css",
"version": "0.7"
"version": "0.8"
},
"editor": {
"url": "https://unpkg.com/@tryghost/koenig-react/dist/umd/koenig-react.min.js"

View File

@ -27,7 +27,6 @@ const BETA_FEATURES = [
const ALPHA_FEATURES = [
'urlCache',
'beforeAfterCard',
'comments',
'freeTrial'
];

View File

@ -230,7 +230,7 @@ Object {
},
Object {
"key": "labs",
"value": "{\\"activitypub\\":true,\\"urlCache\\":true,\\"beforeAfterCard\\":true,\\"comments\\":true,\\"freeTrial\\":true,\\"newsletterPaywall\\":true,\\"members\\":true}",
"value": "{\\"activitypub\\":true,\\"urlCache\\":true,\\"beforeAfterCard\\":true,\\"freeTrial\\":true,\\"newsletterPaywall\\":true,\\"members\\":true}",
},
Object {
"key": "slack_url",
@ -280,7 +280,7 @@ exports[`Settings API Browse Can request all settings 2: [headers] 1`] = `
Object {
"access-control-allow-origin": "http://127.0.0.1:2369",
"cache-control": "no-cache, private, no-store, must-revalidate, max-stale=0, post-check=0, pre-check=0",
"content-length": "3425",
"content-length": "3407",
"content-type": "application/json; charset=utf-8",
"etag": StringMatching /\\(\\?:W\\\\/\\)\\?"\\(\\?:\\[ !#-\\\\x7E\\\\x80-\\\\xFF\\]\\*\\|\\\\r\\\\n\\[\\\\t \\]\\|\\\\\\\\\\.\\)\\*"/,
"vary": "Origin, Accept-Encoding",

View File

@ -31,7 +31,6 @@ describe('{{comment_count}} helper', function () {
beforeEach(function () {
mockManager.mockMail();
mockManager.mockLabsEnabled('comments');
sinon.stub(settingsCache, 'get');
});

View File

@ -20,7 +20,6 @@ describe('{{comments}} helper', function () {
beforeEach(function () {
mockManager.mockMail();
mockManager.mockLabsEnabled('comments');
sinon.stub(settingsCache, 'get');
configUtils.set('comments:version', 'test.version');
});