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

Improved rendering for twitter newsletter embeds

refs https://github.com/TryGhost/Team/issues/1001

This also adds the missing alpha flag so that we can release this when
it's ready.
This commit is contained in:
Fabien egg O'Carroll 2021-12-07 11:16:11 +02:00
parent 4673bd05fc
commit 2a1eb3de88
4 changed files with 12 additions and 8 deletions

View file

@ -1,5 +1,6 @@
const {extract} = require('oembed-parser'); const {extract} = require('oembed-parser');
const logging = require('@tryghost/logging'); const logging = require('@tryghost/logging');
const labs = require('../../shared/labs');
/** /**
* @typedef {import('./oembed').ICustomProvider} ICustomProvider * @typedef {import('./oembed').ICustomProvider} ICustomProvider
@ -42,7 +43,7 @@ class TwitterOEmbedProvider {
/** @type {object} */ /** @type {object} */
const oembedData = await extract(url.href); const oembedData = await extract(url.href);
if (this.dependencies.config.bearerToken) { if (this.dependencies.config.bearerToken && labs.isSet('richTwitterNewsletters')) {
const query = { const query = {
expansions: ['attachments.poll_ids', 'attachments.media_keys', 'author_id', 'entities.mentions.username', 'geo.place_id', 'in_reply_to_user_id', 'referenced_tweets.id', 'referenced_tweets.id.author_id'], expansions: ['attachments.poll_ids', 'attachments.media_keys', 'author_id', 'entities.mentions.username', 'geo.place_id', 'in_reply_to_user_id', 'referenced_tweets.id', 'referenced_tweets.id.author_id'],
'media.fields': ['duration_ms', 'height', 'media_key', 'preview_image_url', 'type', 'url', 'width', 'public_metrics', 'alt_text'], 'media.fields': ['duration_ms', 'height', 'media_key', 'preview_image_url', 'type', 'url', 'width', 'public_metrics', 'alt_text'],

View file

@ -41,7 +41,8 @@ const ALPHA_FEATURES = [
'videoCard', 'videoCard',
'productCard', 'productCard',
'quoteStyles', 'quoteStyles',
'beforeAfterCard' 'beforeAfterCard',
'richTwitterNewsletters'
]; ];
module.exports.GA_KEYS = [...GA_FEATURES]; module.exports.GA_KEYS = [...GA_FEATURES];

View file

@ -73,7 +73,7 @@
"@tryghost/job-manager": "0.8.17", "@tryghost/job-manager": "0.8.17",
"@tryghost/kg-card-factory": "3.1.0", "@tryghost/kg-card-factory": "3.1.0",
"@tryghost/kg-default-atoms": "3.1.0", "@tryghost/kg-default-atoms": "3.1.0",
"@tryghost/kg-default-cards": "5.9.5", "@tryghost/kg-default-cards": "5.10.0",
"@tryghost/kg-markdown-html-renderer": "5.1.0", "@tryghost/kg-markdown-html-renderer": "5.1.0",
"@tryghost/kg-mobiledoc-html-renderer": "5.3.1", "@tryghost/kg-mobiledoc-html-renderer": "5.3.1",
"@tryghost/limit-service": "1.0.6", "@tryghost/limit-service": "1.0.6",

View file

@ -1442,15 +1442,17 @@
resolved "https://registry.yarnpkg.com/@tryghost/kg-default-atoms/-/kg-default-atoms-3.1.0.tgz#4daff7104c1f261b1b816dd75ae4104009f9c1e6" resolved "https://registry.yarnpkg.com/@tryghost/kg-default-atoms/-/kg-default-atoms-3.1.0.tgz#4daff7104c1f261b1b816dd75ae4104009f9c1e6"
integrity sha512-FfROzVgqJWqJ7cVdS9dcALz7rnzNfV8zcrymAJrDTHDsqzAdMfSLe1tNQRm8zas9pyZLsD8zBGmLxG9dr4WFSA== integrity sha512-FfROzVgqJWqJ7cVdS9dcALz7rnzNfV8zcrymAJrDTHDsqzAdMfSLe1tNQRm8zas9pyZLsD8zBGmLxG9dr4WFSA==
"@tryghost/kg-default-cards@5.9.5": "@tryghost/kg-default-cards@5.10.0":
version "5.9.5" version "5.10.0"
resolved "https://registry.yarnpkg.com/@tryghost/kg-default-cards/-/kg-default-cards-5.9.5.tgz#f54781d14610dd56499f71498c35a5eba040e518" resolved "https://registry.yarnpkg.com/@tryghost/kg-default-cards/-/kg-default-cards-5.10.0.tgz#4bd3aca557bd2f8f446ca57af43159adf906572c"
integrity sha512-Y0tpmOetEY4KJkl89V0o2Q7fQ9vKxxiaUkg6IFipwH8QkOer9eJ7vzHkKdR/X1NoJrfmh80v/XS1Yf8265rlpw== integrity sha512-zGj3qbjgculsg++Pt8CUnLW0cb18yWsIMgNrt3lbBm19jjgMMSFru5RgH47OQIYInJlEA2IwkBg675VE4vb+cQ==
dependencies: dependencies:
"@tryghost/kg-markdown-html-renderer" "^5.1.0" "@tryghost/kg-markdown-html-renderer" "^5.1.0"
"@tryghost/url-utils" "^2.0.0" "@tryghost/url-utils" "^2.0.0"
handlebars "^4.7.6" handlebars "^4.7.6"
juice "^8.0.0" juice "^8.0.0"
lodash "^4.17.21"
luxon "^2.1.1"
"@tryghost/kg-markdown-html-renderer@5.1.0", "@tryghost/kg-markdown-html-renderer@^5.1.0": "@tryghost/kg-markdown-html-renderer@5.1.0", "@tryghost/kg-markdown-html-renderer@^5.1.0":
version "5.1.0" version "5.1.0"
@ -7541,7 +7543,7 @@ lru_map@^0.3.3:
resolved "https://registry.yarnpkg.com/lru_map/-/lru_map-0.3.3.tgz#b5c8351b9464cbd750335a79650a0ec0e56118dd" resolved "https://registry.yarnpkg.com/lru_map/-/lru_map-0.3.3.tgz#b5c8351b9464cbd750335a79650a0ec0e56118dd"
integrity sha1-tcg1G5Rky9dQM1p5ZQoOwOVhGN0= integrity sha1-tcg1G5Rky9dQM1p5ZQoOwOVhGN0=
luxon@2.1.1: luxon@2.1.1, luxon@^2.1.1:
version "2.1.1" version "2.1.1"
resolved "https://registry.yarnpkg.com/luxon/-/luxon-2.1.1.tgz#34052f7a33a7989767637be7cf80b47db264ff88" resolved "https://registry.yarnpkg.com/luxon/-/luxon-2.1.1.tgz#34052f7a33a7989767637be7cf80b47db264ff88"
integrity sha512-6VQVNw7+kQu3hL1ZH5GyOhnk8uZm21xS7XJ/6vDZaFNcb62dpFDKcH8TI5NkoZOdMRxr7af7aYGrJlE/Wv0i1w== integrity sha512-6VQVNw7+kQu3hL1ZH5GyOhnk8uZm21xS7XJ/6vDZaFNcb62dpFDKcH8TI5NkoZOdMRxr7af7aYGrJlE/Wv0i1w==