Skip to content

Commit

Permalink
Merge pull request #317 from WPMedia/AIO-343
Browse files Browse the repository at this point in the history
Added height and width customField KVP  AIO-343
  • Loading branch information
HardipAtWpost committed Dec 22, 2020
2 parents 529312f + 593f455 commit 0d0604b
Show file tree
Hide file tree
Showing 52 changed files with 587 additions and 237 deletions.
5 changes: 5 additions & 0 deletions .changeset/dirty-moons-yawn.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@wpmedia/feeds-prop-types': minor
---

Added resizer width and height kvp
25 changes: 25 additions & 0 deletions .changeset/pre.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
{
"mode": "exit",
"tag": "ttk",
"initialVersions": {
"@wpmedia/feeds-source-collections-block": "0.1.0",
"@wpmedia/feeds-source-content-api-block": "0.9.0",
"@wpmedia/feeds-source-video-api-block": "0.3.0",
"@wpmedia/mrss-feature-block": "0.9.0",
"@wpmedia/rss-fbia-feature-block": "0.7.0",
"@wpmedia/rss-feature-block": "0.8.0",
"@wpmedia/rss-flipboard-feature-block": "0.9.0",
"@wpmedia/rss-google-news-feature-block": "0.7.0",
"@wpmedia/rss-msn-feature-block": "0.8.0",
"@wpmedia/sitemap-feature-block": "0.9.0",
"@wpmedia/sitemap-index-feature-block": "0.9.0",
"@wpmedia/sitemap-news-feature-block": "0.8.0",
"@wpmedia/sitemap-video-feature-block": "0.7.0",
"@wpmedia/feeds-content-elements": "0.4.0",
"@wpmedia/feeds-find-video-stream": "0.2.0",
"@wpmedia/feeds-prop-types": "0.6.0",
"@wpmedia/feeds-resizer": "0.3.0",
"@wpmedia/feeds-xml-output": "0.3.0"
},
"changesets": ["dirty-moons-yawn"]
}
2 changes: 1 addition & 1 deletion blocks/feeds-source-collections-block/package-lock.json

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

2 changes: 1 addition & 1 deletion blocks/feeds-source-content-api-block/package-lock.json

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

2 changes: 1 addition & 1 deletion blocks/feeds-source-video-api-block/package-lock.json

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

7 changes: 7 additions & 0 deletions blocks/mrss-feature-block/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
# @wpmedia/mrss-feature-block

## 0.9.1-ttk.0

### Patch Changes

- Updated dependencies []:
- @wpmedia/feeds-prop-types@0.7.0-ttk.0

## 0.9.0

### Minor Changes
Expand Down
13 changes: 12 additions & 1 deletion blocks/mrss-feature-block/features/mrss/xml.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@ const rssTemplate = (
itemCategory,
includeContent,
resizerURL,
resizerWidth,
resizerHeight,
domain,
feedTitle,
feedLanguage,
Expand Down Expand Up @@ -132,7 +134,13 @@ const rssTemplate = (
...(img &&
img.url && {
'media:thumbnail': {
'@url': buildResizerURL(img.url, resizerKey, resizerURL),
'@url': buildResizerURL(
img.url,
resizerKey,
resizerURL,
resizerWidth,
resizerHeight,
),
},
}),
},
Expand All @@ -149,6 +157,7 @@ export function Mrss({ globalContent, customFields, arcSite }) {
feedTitle = '',
feedLanguage = '',
} = getProperties(arcSite)
const { width = 0, height = 0 } = customFields.resizerKVP || {}

// can't return null for xml return type, must return valid xml template
return rssTemplate(
Expand All @@ -157,6 +166,8 @@ export function Mrss({ globalContent, customFields, arcSite }) {
{
...customFields,
resizerURL,
resizerWidth: width,
resizerHeight: height,
domain: feedDomainURL,
feedTitle,
feedLanguage,
Expand Down
1 change: 1 addition & 0 deletions blocks/mrss-feature-block/features/mrss/xml.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,7 @@ it('returns RSS template with default values', () => {
pubDate: 'display_date',
itemCategory: 'taxonomy.primary_section.name',
videoInfo: { bitrate: 5400, stream_type: 'mp4' },
resizerKVP: {},
},
})
expect(video).toMatchSnapshot({
Expand Down
30 changes: 15 additions & 15 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.

4 changes: 2 additions & 2 deletions blocks/mrss-feature-block/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@wpmedia/mrss-feature-block",
"version": "0.9.0",
"version": "0.9.1-ttk.0",
"description": "Fusion components for building rss",
"main": "index.js",
"files": [
Expand All @@ -23,7 +23,7 @@
"homepage": "https://github.com/WPMedia/feed-components#readme",
"dependencies": {
"@wpmedia/feeds-content-elements": "^0.4.0",
"@wpmedia/feeds-prop-types": "^0.4.0",
"@wpmedia/feeds-prop-types": "^0.7.0-ttk.1",
"@wpmedia/feeds-resizer": "^0.3.0",
"jmespath": "^0.15.0",
"moment": "^2.24.0"
Expand Down
7 changes: 7 additions & 0 deletions blocks/rss-fbia-feature-block/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
# @wpmedia/sitemaps-feature-block

## 0.7.1-ttk.0

### Patch Changes

- Updated dependencies []:
- @wpmedia/feeds-prop-types@0.7.0-ttk.0

## 0.7.0

### Minor Changes
Expand Down
86 changes: 70 additions & 16 deletions blocks/rss-fbia-feature-block/features/rss/xml.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ const rssTemplate = (
includePromo,
includeContent,
resizerURL,
resizerWidth,
resizerHeight,
domain,
feedTitle,
feedLanguage,
Expand Down Expand Up @@ -103,7 +105,13 @@ const rssTemplate = (
(category = jmespath.search(s, itemCategory)) &&
category && { category: category }),
...(includeContent !== 0 &&
(body = fbiaBuildContent.parse(s, includeContent, domain)) &&
(body = fbiaBuildContent.parse(
s,
includeContent,
domain,
resizerWidth,
resizerHeight,
)) &&
body && {
'content:encoded': {
$: body,
Expand All @@ -114,7 +122,13 @@ const rssTemplate = (
img.url && {
'media:content': {
'@type': 'image/jpeg',
'@url': buildResizerURL(img.url, resizerKey, resizerURL),
'@url': buildResizerURL(
img.url,
resizerKey,
resizerURL,
resizerWidth,
resizerHeight,
),
...(jmespath.search(img, imageCaption) && {
'media:description': {
'@type': 'plain',
Expand Down Expand Up @@ -148,6 +162,7 @@ export function FbiaRss({ globalContent, customFields, arcSite }) {
feedTitle = '',
feedLanguage = '',
} = getProperties(arcSite)
const { width = 0, height = 0 } = customFields.resizerKVP || {}

function FbiaBuildContent(
domain,
Expand All @@ -165,7 +180,7 @@ export function FbiaRss({ globalContent, customFields, arcSite }) {
) {
BuildContent.call(this)

this.buildHTMLHead = (s, domain) => {
this.buildHTMLHead = (s, domain, resizerWidth, resizerHeight) => {
const img =
s.promo_items && (s.promo_items.basic || s.promo_items.lead_art)
const url = `${domain}${s.website_url || s.canonical_url || ''}`
Expand Down Expand Up @@ -219,7 +234,7 @@ export function FbiaRss({ globalContent, customFields, arcSite }) {
],
}
}
this.buildHTMLBody = (s, numRows, domain) => {
this.buildHTMLBody = (s, numRows, domain, resizerWidth, resizerHeight) => {
const authorDescription =
jmespath.search(s, 'credits.by[].description') || []
const lastUpdatedDate = jmespath.search(s, 'last_updated_date')
Expand Down Expand Up @@ -275,7 +290,13 @@ export function FbiaRss({ globalContent, customFields, arcSite }) {
figure: {
'@class': 'fb-feed-cover',
img: {
'@src': buildResizerURL(image.url, resizerKey, resizerURL),
'@src': buildResizerURL(
image.url,
resizerKey,
resizerURL,
resizerWidth,
resizerHeight,
),
},
...(customFields.imageCaption &&
jmespath.search(image, customFields.imageCaption) && {
Expand Down Expand Up @@ -308,7 +329,13 @@ export function FbiaRss({ globalContent, customFields, arcSite }) {
'#': header,
},
'#': [
this.buildContentElements(s, numRows, domain),
this.buildContentElements(
s,
numRows,
domain,
resizerWidth,
resizerHeight,
),
...(adScripts && [adScripts]),
],
footer: {
Expand All @@ -324,7 +351,14 @@ export function FbiaRss({ globalContent, customFields, arcSite }) {
},
}
}
this.buildContentElements = (s, numRows, domain) => {

this.buildContentElements = (
s,
numRows,
domain,
resizerWidth,
resizerHeight,
) => {
let item
const body = []
const maxRows =
Expand Down Expand Up @@ -355,8 +389,8 @@ export function FbiaRss({ globalContent, customFields, arcSite }) {
element,
resizerKey,
resizerURL,
resizeWidth,
resizeHeight,
resizerWidth,
resizerHeight,
)
break
case 'header':
Expand All @@ -367,8 +401,8 @@ export function FbiaRss({ globalContent, customFields, arcSite }) {
element,
resizerKey,
resizerURL,
resizeWidth,
resizeHeight,
resizerWidth,
resizerHeight,
)
break
case 'interstitial_link':
Expand Down Expand Up @@ -419,13 +453,25 @@ export function FbiaRss({ globalContent, customFields, arcSite }) {
)
return body.length ? body : ['']
}
this.image = (element, resizerKey, resizerURL) => {
this.image = (
element,
resizerKey,
resizerURL,
resizerWidth,
resizerHeight,
) => {
const credits = jmespath.search(element, 'credits.by[].name') || []
return {
figure: {
img: {
'@': {
src: buildResizerURL(element.url, resizerKey, resizerURL),
src: buildResizerURL(
element.url,
resizerKey,
resizerURL,
resizerWidth,
resizerHeight,
),
},
},
...(element.caption && {
Expand Down Expand Up @@ -490,12 +536,18 @@ export function FbiaRss({ globalContent, customFields, arcSite }) {
}
return item
}
this.parse = (s, numRows, domain) => {
this.parse = (s, numRows, domain, resizerWidth, resizerHeight) => {
const fbiaContent = {
html: {
'@lang': feedLanguage,
head: this.buildHTMLHead(s, domain),
body: this.buildHTMLBody(s, numRows, domain),
head: this.buildHTMLHead(s, domain, resizerWidth, resizerHeight),
body: this.buildHTMLBody(
s,
numRows,
domain,
resizerWidth,
resizerHeight,
),
},
}
return '<!doctype html>'.concat(fragment(fbiaContent).toString())
Expand All @@ -521,6 +573,8 @@ export function FbiaRss({ globalContent, customFields, arcSite }) {
return rssTemplate(get(globalContent, 'content_elements', []), {
...customFields,
resizerURL,
resizerWidth: width,
resizerHeight: height,
domain: feedDomainURL,
feedTitle,
feedLanguage,
Expand Down

0 comments on commit 0d0604b

Please sign in to comment.