Skip to content

Commit

Permalink
Merge pull request #91 from guardian/pf/add-ap-newswires-to-mapping
Browse files Browse the repository at this point in the history
Add our own AP & Reuters feeds to API/UI
  • Loading branch information
bryophyta authored Jan 16, 2025
2 parents 84f5ffb + f61f6e8 commit 1c747df
Show file tree
Hide file tree
Showing 5 changed files with 59 additions and 7 deletions.
4 changes: 4 additions & 0 deletions newswires/app/conf/SourceFeedSupplierMapping.scala
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ object SourceFeedSupplierMapping {

private val lookup = Map(
"REUTERS" -> List("REUTERS"),
"GUREUTERS" -> List("Reuters-Newswires"),
"AAP" -> List("AAP"),
"AP" -> List(
"ADVIS",
Expand Down Expand Up @@ -62,6 +63,9 @@ object SourceFeedSupplierMapping {
"WEATHER",
"WORLD"
),
"GUAP" -> List( // for feeds coming from our own poller
"AP-Newswires"
),
"PA" -> List(
"PA",
"PA ACCESSWIRE",
Expand Down
3 changes: 2 additions & 1 deletion newswires/app/db/FingerpostWireEntry.scala
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,8 @@ case class FingerpostWire(
language: Option[String],
usage: Option[String],
location: Option[String],
bodyText: Option[String]
bodyText: Option[String],
ednote: Option[String]
)
object FingerpostWire {
// rename a couple of fields
Expand Down
39 changes: 34 additions & 5 deletions newswires/client/src/SideNav.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import { css } from '@emotion/react';
import { useCallback, useMemo, useState } from 'react';
import { useSearch } from './context/SearchContext.tsx';
import { SearchBox } from './SearchBox';
import { brandColours } from './sharedStyles';
import { AAPBrand, APBrand, PABrand, reutersBrand } from './sharedStyles';
import type { Query } from './sharedTypes';

function decideLabelForQueryBadge(query: Query): string {
Expand All @@ -28,7 +28,36 @@ function decideLabelForQueryBadge(query: Query): string {
return labels.filter((label) => label.length > 0).join(' ');
}

const recognisedSuppliers = ['REUTERS', 'AP', 'AAP', 'PA'];
const supplierData: Record<
string,
{
label: string;
colour: string;
}
> = {
REUTERS: { label: 'Reuters', colour: reutersBrand },
AP: {
label: 'AP',
colour: APBrand,
},
AAP: {
label: 'AAP',
colour: AAPBrand,
},
PA: {
label: 'PA',
colour: PABrand,
},
GuAP: {
label: 'AP (Gu)',
colour: APBrand,
},
GuReuters: {
label: 'Reuters (Gu)',
colour: reutersBrand,
},
};
const recognisedSuppliers = Object.keys(supplierData);
const buckets = [
{ id: 'no-sports', name: 'No Sports' },
{ id: 'pa-home', name: 'PA Home' },
Expand Down Expand Up @@ -98,11 +127,11 @@ export const SideNav = () => {
onClick: () => handleEnterQuery({ ...config.query, supplier: [] }),
colour: 'black',
},
...recognisedSuppliers.map((supplier) => ({
label: supplier,
...Object.entries(supplierData).map(([supplier, { label, colour }]) => ({
label,
isActive:
activeSuppliers.includes(supplier) || activeSuppliers.length === 0,
colour: brandColours.get(supplier) ?? 'black',
colour: colour,
onClick: () => toggleSupplier(supplier),
})),
],
Expand Down
19 changes: 18 additions & 1 deletion newswires/client/src/WireDetail.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ export const WireDetail = ({
isShowingJson: boolean;
}) => {
const theme = useEuiTheme();
const { byline, keywords, usage } = wire.content;
const { byline, keywords, usage, ednote } = wire.content;

const safeBodyText = useMemo(() => {
return wire.content.bodyText
Expand Down Expand Up @@ -74,6 +74,18 @@ export const WireDetail = ({
}
`}
>
{ednote && (
<p
css={css`
border: 1px solid;
padding: ${theme.euiTheme.size.s};
margin-bottom: ${theme.euiTheme.size.s};
font-weight: ${theme.euiTheme.font.weight.bold};
`}
>
{ednote}
</p>
)}
{byline && (
<>
<EuiDescriptionListTitle>Byline</EuiDescriptionListTitle>
Expand Down Expand Up @@ -112,6 +124,11 @@ export const WireDetail = ({
<EuiDescriptionListDescription>
<article
dangerouslySetInnerHTML={{ __html: bodyTextContent }}
css={css`
& p {
margin-bottom: ${theme.euiTheme.size.s};
}
`}
data-pinboard-selection-target
/>
</EuiDescriptionListDescription>
Expand Down
1 change: 1 addition & 0 deletions newswires/client/src/sharedTypes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ const FingerpostContentSchema = z
usage: z.string(),
location: z.string(),
bodyText: z.string(),
ednote: z.string(),
})
.partial();

Expand Down

0 comments on commit 1c747df

Please sign in to comment.