Skip to content

Commit

Permalink
Overrides (#252)
Browse files Browse the repository at this point in the history
Overrides
  • Loading branch information
AWare authored Jul 31, 2019
2 parents 0c629fd + 2394d01 commit 8eb0e83
Show file tree
Hide file tree
Showing 4 changed files with 65 additions and 4 deletions.
18 changes: 16 additions & 2 deletions projects/backend/capi/articles.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,15 @@ import { fromPairs } from 'ramda'
import { kickerPicker } from './kickerPicker'
import { getBylineImages } from './byline'

type NotInCAPI = 'key'
type OptionalInCAPI = 'kicker' | 'bylineImages'
type NotInCAPI =
| 'key'
| 'showByline'
| 'showQuotedHeadline'
| 'mediaType'
| 'slideshowImages'

type OptionalInCAPI = 'kicker' | 'bylineImages' | 'trail'

interface CAPIExtras {
path: string
}
Expand Down Expand Up @@ -65,6 +72,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)

Expand Down Expand Up @@ -111,6 +121,7 @@ const parseArticleResult = async (
path: path,
headline: title,
kicker,
trail,
image: maybeImage,
byline: byline || '',
bylineImages,
Expand All @@ -127,6 +138,7 @@ const parseArticleResult = async (
type: 'gallery',
path: path,
headline: title,
trail,
kicker,
image: maybeImage,
byline: byline || '',
Expand Down Expand Up @@ -166,6 +178,7 @@ const parseArticleResult = async (
internalid,
{
type: 'crossword',
trail,
path: path,
headline: title,
byline: byline || '',
Expand All @@ -183,6 +196,7 @@ const parseArticleResult = async (
type: 'article',
path: path,
headline: title,
trail,
kicker,
image: maybeImage,
byline: byline || '',
Expand Down
35 changes: 35 additions & 0 deletions projects/backend/fronts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -60,6 +61,22 @@ 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.trail ||
''
const byline =
(furniture && furniture.bylineOverride) || article.byline
const showByline = furniture.showByline //TODO
const showQuotedHeadline = furniture.showQuotedHeadline // TODO
const mediaType = furniture.mediaType // TODO// TODO
const slideshowImages =
furniture.slideshowImages &&
furniture.slideshowImages
.map(_ => _.src)
.map(getImageFromURL)
.filter(notNull)

const imageOverride =
furniture &&
furniture.imageSrcOverride &&
Expand All @@ -73,6 +90,12 @@ export const parseCollection = async (
...article,
...getCrosswordArticleOverrides(article),
key: article.path,
trail,
byline,
showByline,
showQuotedHeadline,
mediaType,
slideshowImages,
},
]

Expand All @@ -84,6 +107,12 @@ export const parseCollection = async (
key: article.path,
headline,
kicker,
trail,
byline,
showByline,
showQuotedHeadline,
mediaType,
slideshowImages,
},
]

Expand All @@ -95,7 +124,13 @@ export const parseCollection = async (
key: article.path,
headline,
kicker,
trail,
image: imageOverride || article.image,
byline: byline || '',
showByline,
showQuotedHeadline,
mediaType,
slideshowImages,
},
]

Expand Down
4 changes: 3 additions & 1 deletion projects/backend/fronts/issue.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import { MediaType } from '../common'

export interface PublishedIssue {
id: string
name: string
Expand Down Expand Up @@ -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[]
}
12 changes: 11 additions & 1 deletion projects/common/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,15 +52,25 @@ export interface Forecast {
MobileLink: string
Link: string
}

export type MediaType =
| 'UseArticleTrail'
| 'Hide'
| 'Cutout'
| 'Slideshow'
| 'Image'
export interface Content extends WithKey {
type: string
headline: string
kicker: string
trail: string
image?: Image
standfirst?: string
byline?: string
bylineImages?: { thumbnail?: Image; cutout?: Image }
showByline: boolean
showQuotedHeadline: boolean
mediaType: MediaType
slideshowImages?: Image[]
}
export interface Article extends Content {
type: 'article'
Expand Down

0 comments on commit 8eb0e83

Please sign in to comment.