Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Overrides #252

Merged
merged 7 commits into from
Jul 31, 2019
Merged
Show file tree
Hide file tree
Changes from 6 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 =
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(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 @@ -51,15 +51,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