From a92bba84035ff4e3e9b6ec20ef447b34f1b6af31 Mon Sep 17 00:00:00 2001 From: Alex Ware Date: Wed, 31 Jul 2019 12:38:56 +0100 Subject: [PATCH 1/6] starting to work on overrides --- projects/backend/fronts.ts | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/projects/backend/fronts.ts b/projects/backend/fronts.ts index b91aa12f89..4954af82e6 100644 --- a/projects/backend/fronts.ts +++ b/projects/backend/fronts.ts @@ -60,6 +60,15 @@ export const parseCollection = async ( (furniture && furniture.kicker) || article.kicker || '' // I'm not sure where else we should check for a kicker const headline = (furniture && furniture.headlineOverride) || article.headline + const trail = + (furniture && furniture.trailTextOverride) || 'article.???' //TODO + const byline = + (furniture && furniture.bylineOverride) || 'article.???' //TODO + const showByline = furniture.showByline //TODO + const showQuotedHeadline = furniture.showQuotedHeadline // TODO + const mediaType = furniture.mediaType // TODO// TODO + const slideshowImages = furniture.slideshowImages // TODO + const imageOverride = furniture && furniture.imageSrcOverride && From a23e461778d71a69d5a3849b128708fa13ab0845 Mon Sep 17 00:00:00 2001 From: Alex Ware Date: Wed, 31 Jul 2019 13:16:44 +0100 Subject: [PATCH 2/6] add trail --- projects/backend/capi/articles.ts | 11 ++++++++++- projects/backend/fronts.ts | 7 ++++++- projects/common/src/index.ts | 1 + 3 files changed, 17 insertions(+), 2 deletions(-) diff --git a/projects/backend/capi/articles.ts b/projects/backend/capi/articles.ts index 8cf711420e..d58a0f37c9 100644 --- a/projects/backend/capi/articles.ts +++ b/projects/backend/capi/articles.ts @@ -25,7 +25,9 @@ import { kickerPicker } from './kickerPicker' import { getBylineImages } from './byline' type NotInCAPI = 'key' -type OptionalInCAPI = 'kicker' | 'bylineImages' + +type OptionalInCAPI = 'kicker' | 'bylineImages' | 'trail' + interface CAPIExtras { path: string } @@ -65,6 +67,9 @@ const parseArticleResult = async ( const parser = elementParser(path) const kicker = kickerPicker(result, title) + + const trail = result.fields && result.fields.trailText + const byline = result.fields && result.fields.byline const bylineImages = getBylineImages(result) @@ -111,6 +116,7 @@ const parseArticleResult = async ( path: path, headline: title, kicker, + trail, image: maybeImage, byline: byline || '', bylineImages, @@ -127,6 +133,7 @@ const parseArticleResult = async ( type: 'gallery', path: path, headline: title, + trail, kicker, image: maybeImage, byline: byline || '', @@ -166,6 +173,7 @@ const parseArticleResult = async ( internalid, { type: 'crossword', + trail, path: path, headline: title, byline: byline || '', @@ -183,6 +191,7 @@ const parseArticleResult = async ( type: 'article', path: path, headline: title, + trail, kicker, image: maybeImage, byline: byline || '', diff --git a/projects/backend/fronts.ts b/projects/backend/fronts.ts index 4954af82e6..c4bb701b6e 100644 --- a/projects/backend/fronts.ts +++ b/projects/backend/fronts.ts @@ -61,7 +61,9 @@ export const parseCollection = async ( const headline = (furniture && furniture.headlineOverride) || article.headline const trail = - (furniture && furniture.trailTextOverride) || 'article.???' //TODO + (furniture && furniture.trailTextOverride) || + article.trail || + '' const byline = (furniture && furniture.bylineOverride) || 'article.???' //TODO const showByline = furniture.showByline //TODO @@ -82,6 +84,7 @@ export const parseCollection = async ( ...article, ...getCrosswordArticleOverrides(article), key: article.path, + trail, }, ] @@ -93,6 +96,7 @@ export const parseCollection = async ( key: article.path, headline, kicker, + trail, }, ] @@ -104,6 +108,7 @@ export const parseCollection = async ( key: article.path, headline, kicker, + trail, image: imageOverride || article.image, }, ] diff --git a/projects/common/src/index.ts b/projects/common/src/index.ts index 8b5f7d5ef8..5acf24907a 100644 --- a/projects/common/src/index.ts +++ b/projects/common/src/index.ts @@ -56,6 +56,7 @@ export interface Content extends WithKey { type: string headline: string kicker: string + trail: string image?: Image standfirst?: string byline?: string From 01196b3070e9832046162f19374337c8a902d943 Mon Sep 17 00:00:00 2001 From: Alex Ware Date: Wed, 31 Jul 2019 13:17:53 +0100 Subject: [PATCH 3/6] byline --- projects/backend/fronts.ts | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/projects/backend/fronts.ts b/projects/backend/fronts.ts index c4bb701b6e..a9048a40ff 100644 --- a/projects/backend/fronts.ts +++ b/projects/backend/fronts.ts @@ -65,7 +65,7 @@ export const parseCollection = async ( article.trail || '' const byline = - (furniture && furniture.bylineOverride) || 'article.???' //TODO + (furniture && furniture.bylineOverride) || article.byline || '' const showByline = furniture.showByline //TODO const showQuotedHeadline = furniture.showQuotedHeadline // TODO const mediaType = furniture.mediaType // TODO// TODO @@ -85,6 +85,7 @@ export const parseCollection = async ( ...getCrosswordArticleOverrides(article), key: article.path, trail, + byline, }, ] @@ -97,6 +98,7 @@ export const parseCollection = async ( headline, kicker, trail, + byline, }, ] @@ -110,6 +112,7 @@ export const parseCollection = async ( kicker, trail, image: imageOverride || article.image, + byline, }, ] From 9107bd9c31fb62cb1b4aac676acba5f57cf4211d Mon Sep 17 00:00:00 2001 From: Alex Ware Date: Wed, 31 Jul 2019 13:20:18 +0100 Subject: [PATCH 4/6] extra types --- projects/backend/fronts.ts | 2 +- projects/backend/fronts/issue.ts | 4 +++- projects/common/src/index.ts | 11 ++++++++++- 3 files changed, 14 insertions(+), 3 deletions(-) diff --git a/projects/backend/fronts.ts b/projects/backend/fronts.ts index a9048a40ff..513bdab877 100644 --- a/projects/backend/fronts.ts +++ b/projects/backend/fronts.ts @@ -65,7 +65,7 @@ export const parseCollection = async ( article.trail || '' const byline = - (furniture && furniture.bylineOverride) || article.byline || '' + (furniture && furniture.bylineOverride) || article.byline const showByline = furniture.showByline //TODO const showQuotedHeadline = furniture.showQuotedHeadline // TODO const mediaType = furniture.mediaType // TODO// TODO diff --git a/projects/backend/fronts/issue.ts b/projects/backend/fronts/issue.ts index 14c9b14e6d..1428003a4c 100644 --- a/projects/backend/fronts/issue.ts +++ b/projects/backend/fronts/issue.ts @@ -1,3 +1,5 @@ +import { MediaType } from '../common' + export interface PublishedIssue { id: string name: string @@ -29,7 +31,7 @@ export interface PublishedFurtniture { bylineOverride?: string showByline: boolean showQuotedHeadline: boolean - mediaType: 'UseArticleTrail' | 'Hide' | 'Cutout' | 'Slideshow' | 'Image' + mediaType: MediaType imageSrcOverride?: PublishedImage slideshowImages?: PublishedImage[] } diff --git a/projects/common/src/index.ts b/projects/common/src/index.ts index 5acf24907a..b4656b89be 100644 --- a/projects/common/src/index.ts +++ b/projects/common/src/index.ts @@ -51,7 +51,12 @@ export interface Forecast { MobileLink: string Link: string } - +export type MediaType = + | 'UseArticleTrail' + | 'Hide' + | 'Cutout' + | 'Slideshow' + | 'Image' export interface Content extends WithKey { type: string headline: string @@ -61,6 +66,10 @@ export interface Content extends WithKey { standfirst?: string byline?: string bylineImages?: { thumbnail?: Image; cutout?: Image } + showByline: boolean + showQuotedHeadline: boolean + mediaType: MediaType + slideshowImages: Image[] } export interface Article extends Content { type: 'article' From a67313e9d8650d71b1e53b29d320df87aad6ad0d Mon Sep 17 00:00:00 2001 From: Alex Ware Date: Wed, 31 Jul 2019 13:24:03 +0100 Subject: [PATCH 5/6] Add remaining overrides to extract --- projects/backend/capi/articles.ts | 7 ++++++- projects/backend/fronts.ts | 18 ++++++++++++++++-- projects/common/src/index.ts | 2 +- 3 files changed, 23 insertions(+), 4 deletions(-) diff --git a/projects/backend/capi/articles.ts b/projects/backend/capi/articles.ts index d58a0f37c9..b779f7256c 100644 --- a/projects/backend/capi/articles.ts +++ b/projects/backend/capi/articles.ts @@ -24,7 +24,12 @@ import { fromPairs } from 'ramda' import { kickerPicker } from './kickerPicker' import { getBylineImages } from './byline' -type NotInCAPI = 'key' +type NotInCAPI = + | 'key' + | 'showByline' + | 'showQuotedHeadline' + | 'mediaType' + | 'slideshowImages' type OptionalInCAPI = 'kicker' | 'bylineImages' | 'trail' diff --git a/projects/backend/fronts.ts b/projects/backend/fronts.ts index 513bdab877..450288d8ed 100644 --- a/projects/backend/fronts.ts +++ b/projects/backend/fronts.ts @@ -69,7 +69,9 @@ export const parseCollection = async ( const showByline = furniture.showByline //TODO const showQuotedHeadline = furniture.showQuotedHeadline // TODO const mediaType = furniture.mediaType // TODO// TODO - const slideshowImages = furniture.slideshowImages // TODO + const slideshowImages = + furniture.slideshowImages && + furniture.slideshowImages.map(_ => _.src).map(getImageFromURL) const imageOverride = furniture && @@ -86,6 +88,10 @@ export const parseCollection = async ( key: article.path, trail, byline, + showByline, + showQuotedHeadline, + mediaType, + slideshowImages, }, ] @@ -99,6 +105,10 @@ export const parseCollection = async ( kicker, trail, byline, + showByline, + showQuotedHeadline, + mediaType, + slideshowImages, }, ] @@ -112,7 +122,11 @@ export const parseCollection = async ( kicker, trail, image: imageOverride || article.image, - byline, + byline: byline || '', + showByline, + showQuotedHeadline, + mediaType, + slideshowImages, }, ] diff --git a/projects/common/src/index.ts b/projects/common/src/index.ts index b4656b89be..cbc1dbaae2 100644 --- a/projects/common/src/index.ts +++ b/projects/common/src/index.ts @@ -69,7 +69,7 @@ export interface Content extends WithKey { showByline: boolean showQuotedHeadline: boolean mediaType: MediaType - slideshowImages: Image[] + slideshowImages?: Image[] } export interface Article extends Content { type: 'article' From 40fda215ddb5ff976ba31bdcfe6672ec301e2b73 Mon Sep 17 00:00:00 2001 From: Alex Ware Date: Wed, 31 Jul 2019 13:43:39 +0100 Subject: [PATCH 6/6] Account for potentially invalid images --- projects/backend/fronts.ts | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/projects/backend/fronts.ts b/projects/backend/fronts.ts index 450288d8ed..81875b9930 100644 --- a/projects/backend/fronts.ts +++ b/projects/backend/fronts.ts @@ -19,6 +19,7 @@ import { PublishedFront, } from './fronts/issue' import { getCrosswordArticleOverrides } from './utils/crossword' +import { notNull } from '../common/src' export const parseCollection = async ( collectionResponse: PublishedCollection, @@ -71,7 +72,10 @@ export const parseCollection = async ( const mediaType = furniture.mediaType // TODO// TODO const slideshowImages = furniture.slideshowImages && - furniture.slideshowImages.map(_ => _.src).map(getImageFromURL) + furniture.slideshowImages + .map(_ => _.src) + .map(getImageFromURL) + .filter(notNull) const imageOverride = furniture &&