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

Added itemCredits AIO-171 #105

Merged
merged 1 commit into from
Jun 25, 2020
Merged
Show file tree
Hide file tree
Changes from all 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
7 changes: 7 additions & 0 deletions .changeset/tricky-eyes-know.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
'@wpmedia/rss-feature-block': minor
'@wpmedia/rss-google-news-feature-block': minor
'@wpmedia/feeds-prop-types': minor
---

Added itemCredits customField
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ Object {
"content:encoded": Object {
"$": "<p>try singing the happy birthday song</p><p>be sure to wash your thumbs</p>",
},
"dc:creator": "John Smith,Jane Doe",
"dc:creator": "john-smith,jane-doe",
"description": Object {
"$": "This is from the subheadlines",
},
Expand Down
3 changes: 2 additions & 1 deletion blocks/rss-feature-block/features/rss/xml.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ const rssTemplate = (
itemTitle,
itemDescription,
pubDate,
itemCredits,
itemCategory,
includePromo,
includeContent,
Expand Down Expand Up @@ -91,7 +92,7 @@ const rssTemplate = (
'#': url,
'@isPermaLink': true,
},
...((author = jmespath.search(s, 'credits.by[].name')) &&
...((author = jmespath.search(s, itemCredits)) &&
author && {
'dc:creator': author.join(','),
}),
Expand Down
9 changes: 8 additions & 1 deletion blocks/rss-feature-block/features/rss/xml.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,12 @@ const articles = {
credits: { by: [{ name: 'Harold Hands' }] },
},
},
credits: { by: [{ name: 'John Smith' }, { name: 'Jane Doe' }] },
credits: {
by: [
{ name: 'John Smith', _id: 'john-smith' },
{ name: 'Jane Doe', _id: 'jane-doe' },
],
},
headlines: { basic: 'Tips for Safe Hand washing' },
description: { basic: 'Tips to keep you wash for 20 seconds' },
subheadlines: { basic: 'This is from the subheadlines' },
Expand Down Expand Up @@ -50,6 +55,7 @@ it('returns RSS template with default values', () => {
itemTitle: 'headlines.basic',
itemDescription: 'description.basic',
pubDate: 'display_date',
itemCredits: 'credits.by[].name',
itemCategory: '',
includePromo: true,

Expand Down Expand Up @@ -90,6 +96,7 @@ it('returns RSS template with custom values', () => {
itemTitle: 'headlines.seo || headlines.basic',
itemDescription: 'subheadlines.basic || description.basic',
pubDate: 'display_date',
itemCredits: 'credits.by[]._id',
itemCategory: 'taxonomy.primary_section.name',
includePromo: true,

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,6 @@ Object {
"content:encoded": Object {
"$": "<p>try singing the happy birthday song</p><p>be sure to wash your thumbs</p><figure><img src=\\"hi/abcdefghijklmnopqrstuvwxyz=/arc-anglerfish-arc2-prod-demo.s3.amazonaws.com/QHOCF6YFIZCUFIXBVEAXENGFFM.jpg\\" alt=\\"test caption\\"/><figcaption>test caption</figcaption></figure>",
},
"dc:creator": "John Smith,Jane Doe",
"description": Object {
"$": "This is from the subheadlines",
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ const rssTemplate = (
itemTitle,
itemDescription,
pubDate,
itemCredits,
itemCategory,
includeContent,
resizerURL,
Expand Down Expand Up @@ -88,7 +89,7 @@ const rssTemplate = (
'#': url,
'@isPermaLink': true,
},
...((author = jmespath.search(s, 'credits.by[].name')) &&
...((author = jmespath.search(s, itemCredits)) &&
author && {
'dc:creator': author.join(','),
}),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,12 @@ const articles = {
credits: { by: [{ name: 'Harold Hands' }] },
},
},
credits: { by: [{ name: 'John Smith' }, { name: 'Jane Doe' }] },
credits: {
by: [
{ _id: 'john-smith', name: 'John Smith' },
{ _id: 'jane-doe', name: 'Jane Doe' },
],
},
headlines: { basic: 'Tips for Safe Hand washing' },
description: { basic: 'Tips to keep you wash for 20 seconds' },
subheadlines: { basic: 'This is from the subheadlines' },
Expand Down Expand Up @@ -58,6 +63,7 @@ it('returns Google News template with default values', () => {
itemTitle: 'headlines.basic',
itemDescription: 'description.basic',
pubDate: 'display_date',
itemCredits: 'credits.by[].name',
itemCategory: '',

imageTitle: 'title',
Expand Down Expand Up @@ -97,6 +103,7 @@ it('returns RSS template with custom values', () => {
itemTitle: 'headlines.seo || headlines.basic',
itemDescription: 'subheadlines.basic || description.basic',
pubDate: 'display_date',
itemCredits: 'credits.by._id',
itemCategory: 'taxonomy.primary_section.name',
includePromo: true,

Expand Down
9 changes: 9 additions & 0 deletions utils/prop-types/src/__snapshots__/props.test.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,15 @@ Object {
},
"type": "string",
},
"itemCredits": Object {
"tags": Object {
"defaultValue": "credits.by[].name",
"description": "ANS value for credits in the <dc:creator> tag, will join multiple names with a comma. defaults to credits.by[].name",
"group": "Item",
"label": "ANS credits key",
},
"type": "string",
},
"itemDescription": Object {
"tags": Object {
"defaultValue": "description.basic",
Expand Down
10 changes: 10 additions & 0 deletions utils/prop-types/src/propInfo.js
Original file line number Diff line number Diff line change
Expand Up @@ -195,6 +195,16 @@ export const propInfo = {
defaultValue: 'display_date',
},
},
itemCredits: {
type: 'string',
tag: {
label: 'ANS credits key',
group: 'Item',
description:
'ANS value for credits in the <dc:creator> tag, will join multiple names with a comma. defaults to credits.by[].name',
defaultValue: 'credits.by[].name',
},
},
itemCategory: {
type: 'string',
tag: {
Expand Down