Skip to content

Commit

Permalink
Merge pull request #319 from WPMedia/AIO-380
Browse files Browse the repository at this point in the history
Fix error in fb-ia AIO-380
  • Loading branch information
tbrick855 committed Dec 23, 2020
2 parents ffb8735 + 88f09ba commit ffedf62
Show file tree
Hide file tree
Showing 13 changed files with 135 additions and 133 deletions.
5 changes: 5 additions & 0 deletions .changeset/wet-turkeys-shout.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@wpmedia/rss-fbia-feature-block': minor
---

Fix issue when there are no FB Ad scripts
8 changes: 4 additions & 4 deletions blocks/mrss-feature-block/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@ Object {
},
"item": Array [
Object {
"content:encoded": Object {
"$": "<!doctype html><html lang=\\"en\\"><head><link rel=\\"canonical\\" href=\\"http://demo-prod.origin.arcpublishing.com/food/2020/04/07/tips-for-safe-hand-washing\\"/><title>Tips for Safe Hand washing</title><meta property=\\"og:title\\" content=\\"Tips for Safe Hand washing\\"/><meta property=\\"og:url\\" content=\\"http://demo-prod.origin.arcpublishing.com/food/2020/04/07/tips-for-safe-hand-washing\\"/><meta property=\\"og:description\\" content=\\"Tips to keep you wash for 20 seconds\\"/><meta property=\\"fb:use_automatic_ad_placement\\" content=\\"enable=false\\"/><meta property=\\"op:markup_version\\" content=\\"v1.0\\"/><meta property=\\"fb:article_style\\" content=\\"default\\"/><meta property=\\"og:image\\" content=\\"hi/abcdefghijklmnopqrstuvwxyz=/arc-anglerfish-arc2-prod-demo.s3.amazonaws.com/public/JTWX7EUOLJE4FCHYGN2COQAERY.png\\"/><meta property=\\"fb:likes_and_comments\\" content=\\"disable\\"/></head><body><article><header><h1>Tips for Safe Hand washing</h1><h2>Tips to keep you wash for 20 seconds</h2><time datetime=\\"2020-04-08T10:34:41.432Z\\" class=\\"op_modified\\">2020-04-08T10:34:41.432Z</time><time datetime=\\"2020-04-07T15:02:08.918Z\\" class=\\"op_published\\">2020-04-07T15:02:08.918Z</time><address><a>JOHN SMITH</a><a>JANE DOE</a></address><figure class=\\"fb-feed-cover\\"><img src=\\"hi/abcdefghijklmnopqrstuvwxyz=/arc-anglerfish-arc2-prod-demo.s3.amazonaws.com/public/JTWX7EUOLJE4FCHYGN2COQAERY.png\\"/><figcaption class=\\"op-vertical-below op-small\\">Hand washing can be fun if you make it a song<cite class=\\"op-small\\">Harold Hands</cite></figcaption></figure><h2 class=\\"op-kicker\\">coronvirus</h2></header><p>try singing the happy birthday song</p><p>be sure to wash your thumbs</p><footer><small>© 2020 google news</small></footer></article></body></html>",
},
"dc:creator": Object {
"$": "John Smith, Jane Doe",
},
Expand Down
185 changes: 89 additions & 96 deletions blocks/rss-fbia-feature-block/features/rss/xml.js
Original file line number Diff line number Diff line change
Expand Up @@ -165,9 +165,6 @@ export function FbiaRss({ globalContent, customFields, arcSite }) {
const { width = 0, height = 0 } = customFields.resizerKVP || {}

function FbiaBuildContent(
domain,
resizeWidth,
resizeHeight,
itemTitle,
itemDescription,
itemCategory,
Expand Down Expand Up @@ -244,6 +241,7 @@ export function FbiaRss({ globalContent, customFields, arcSite }) {
jmespath.search(s, 'taxonomy.primary_section.name') || ''
const header = []
let description, author
const adScripts = customFields.adScripts || ''
if (placementSection)
header.push({
section: {
Expand Down Expand Up @@ -359,98 +357,96 @@ export function FbiaRss({ globalContent, customFields, arcSite }) {
resizerWidth,
resizerHeight,
) => {
let item
const maxRows = numRows === 'all' ? 9999 : parseInt(numRows)
const body = []
const maxRows =
numRows === 'all'
? 9999
: parseInt(numRows)(s.content_elements || []).array.forEach(
(element) => {
if (body.length <= maxRows) {
switch (element.type) {
case 'blockquote':
item = this.blockquote(element)
break
case 'correction':
item = this.correction(element)
break
case 'code':
case 'custom_embed':
case 'divider':
case 'element_group':
case 'story':
item = ''
break
case 'endorsement':
item = this.endorsement(element)
break
case 'gallery':
item = this.gallery(
element,
resizerKey,
resizerURL,
resizerWidth,
resizerHeight,
)
break
case 'header':
item = this.header(element)
break
case 'image':
item = this.image(
element,
resizerKey,
resizerURL,
resizerWidth,
resizerHeight,
)
break
case 'interstitial_link':
item = this.interstitial(element, domain)
break
case 'link_list':
item = this.linkList(element, domain)
break
case 'list':
item = this.list(element)
break
case 'list_element':
item = this.listElement(element)
break
case 'numeric_rating':
item = this.numericRating(element)
break
case 'oembed_response':
item = this.oembed(element)
break
case 'quote':
item = this.quote(element)
break
case 'raw_html':
item = this.text(element)
break
case 'table':
item = this.table(element)
break
case 'text':
item = this.text(element)
break
case 'video':
item = this.video(element)
break
default:
item = this.text(element)
break
}
let item

// empty array breaks xmlbuilder2, but empty '' is OK
if (Array.isArray(item) && item.length === 0) {
item = ''
}
item && body.push(item)
}
},
)
// prettier-ignore
;(s.content_elements || []).forEach((element) => {
if (body.length <= maxRows) {
switch (element.type) {
case 'blockquote':
item = this.blockquote(element)
break
case 'correction':
item = this.correction(element)
break
case 'code':
case 'custom_embed':
case 'divider':
case 'element_group':
case 'story':
item = ''
break
case 'endorsement':
item = this.endorsement(element)
break
case 'gallery':
item = this.gallery(
element,
resizerKey,
resizerURL,
resizerWidth,
resizerHeight,
)
break
case 'header':
item = this.header(element)
break
case 'image':
item = this.image(
element,
resizerKey,
resizerURL,
resizerWidth,
resizerHeight,
)
break
case 'interstitial_link':
item = this.interstitial(element, domain)
break
case 'link_list':
item = this.linkList(element, domain)
break
case 'list':
item = this.list(element)
break
case 'list_element':
item = this.listElement(element)
break
case 'numeric_rating':
item = this.numericRating(element)
break
case 'oembed_response':
item = this.oembed(element)
break
case 'quote':
item = this.quote(element)
break
case 'raw_html':
item = this.text(element)
break
case 'table':
item = this.table(element)
break
case 'text':
item = this.text(element)
break
case 'video':
item = this.video(element)
break
default:
item = this.text(element)
break
}

// empty array breaks xmlbuilder2, but empty '' is OK
if (Array.isArray(item) && item.length === 0) {
item = ''
}
item && body.push(item)
}
})
return body.length ? body : ['']
}
this.image = (
Expand Down Expand Up @@ -555,9 +551,6 @@ export function FbiaRss({ globalContent, customFields, arcSite }) {
}

const fbiaBuildContent = new FbiaBuildContent(
customFields.domain,
customFields.resizeWidth,
customFields.resizeHeight,
customFields.itemTitle,
customFields.itemDescription,
customFields.itemCategory,
Expand Down
3 changes: 2 additions & 1 deletion blocks/rss-fbia-feature-block/features/rss/xml.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ const articles = {
content_elements: [
{
display_date: '2020-04-07T15:02:08.918Z',
last_updated_date: '2020-04-08T10:34:41.432Z',
website_url: '/food/2020/04/07/tips-for-safe-hand-washing',
promo_items: {
basic: {
Expand Down Expand Up @@ -62,7 +63,7 @@ it('returns RSS template with default values', () => {
imageTitle: 'title',
imageCaption: 'caption',
imageCredits: 'credits.by[].name',
includeContent: 0,
includeContent: 'all',
articleStyle: '',
likesAndComments: '',
adPlacement: '',
Expand Down
8 changes: 4 additions & 4 deletions blocks/rss-fbia-feature-block/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 4 additions & 4 deletions blocks/rss-feature-block/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 4 additions & 4 deletions blocks/rss-flipboard-feature-block/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 4 additions & 4 deletions blocks/rss-google-news-feature-block/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 4 additions & 4 deletions blocks/rss-msn-feature-block/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 4 additions & 4 deletions blocks/sitemap-feature-block/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit ffedf62

Please sign in to comment.