Skip to content
This repository has been archived by the owner on May 6, 2020. It is now read-only.

Add support for LiveBlogPosting article types #120

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
10 changes: 9 additions & 1 deletion amp-story/linter/caches.json
Expand Up @@ -12,9 +12,17 @@
"id": "cloudflare",
"name": "Cloudflare AMP Cache",
"docs": "https://amp.cloudflare.com/",
"cacheDomain": "cdn.cloudflare.com",
"cacheDomain": "amp.cloudflare.com",
"updateCacheApiDomainSuffix": "amp.cloudflare.com",
"thirdPartyFrameDomainSuffix": "cloudflareamp.net"
},
{
"id": "bing",
"name": "Bing AMP Cache",
"docs": "https://www.bing.com/webmaster/help/bing-amp-cache-bc1c884c",
"cacheDomain": "bing-amp.com",
"updateCacheApiDomainSuffix": "bing-amp.com",
"thirdPartyFrameDomainSuffix": "bing-amp.net"
}
]
}
18 changes: 18 additions & 0 deletions ampbench_lib.js
Expand Up @@ -388,6 +388,9 @@ class HttpBodySniffer {
BlogPosting:
this.bodyContains('"@type":"BlogPosting"') ||
this.jsonldScriptContains('"@type":"BlogPosting"'),
LiveBlogPosting:
this.bodyContains('"@type":"LiveBlogPosting"') ||
this.jsonldScriptContains('"@type":"LiveBlogPosting"'),
WebPage:
this.bodyContains('"@type":"WebPage"') ||
this.jsonldScriptContains('"@type":"WebPage"'),
Expand Down Expand Up @@ -417,6 +420,9 @@ class HttpBodySniffer {
BlogPosting:
this.bodyContains('itemtype="http://schema.org/BlogPosting"') ||
this.bodyContains('itemtype="https://schema.org/BlogPosting"'),
LiveBlogPosting:
this.bodyContains('itemtype="http://schema.org/LiveBlogPosting"') ||
this.bodyContains('itemtype="https://schema.org/LiveBlogPosting"'),
WebPage:
this.bodyContains('itemtype="http://schema.org/WebPage"') ||
this.bodyContains('itemtype="https://schema.org/WebPage"'),
Expand All @@ -436,6 +442,7 @@ class HttpBodySniffer {
this._contains_sd.jsonld_type.Article ||
this._contains_sd.jsonld_type.NewsArticle ||
this._contains_sd.jsonld_type.BlogPosting ||
this._contains_sd.jsonld_type.LiveBlogPosting ||
this._contains_sd.jsonld_type.VideoObject;

this._jsonld_type_is_amp_news_carousel_support =
Expand All @@ -451,6 +458,7 @@ class HttpBodySniffer {
this._contains_sd.microdata_type.Article ||
this._contains_sd.microdata_type.NewsArticle ||
this._contains_sd.microdata_type.BlogPosting ||
this._contains_sd.microdata_type.LiveBlogPosting ||
this._contains_sd.microdata_type.VideoObject;

this._microdata_type_is_amp_news_carousel_support =
Expand Down Expand Up @@ -498,6 +506,11 @@ class HttpBodySniffer {
+ ( this._contains_sd.microdata_type.BlogPosting
? ' BlogPosting (Microdata)' : '' )

+ ( this._contains_sd.jsonld_type.LiveBlogPosting
? ' LiveBlogPosting (JSON-LD)' : '' )
+ ( this._contains_sd.microdata_type.LiveBlogPosting
? ' LiveBlogPosting (Microdata)' : '' )

+ ( this._contains_sd.jsonld_type.WebPage
? ' WebPage (JSON-LD)' : '' )
+ ( this._contains_sd.microdata_type.WebPage
Expand Down Expand Up @@ -534,6 +547,11 @@ class HttpBodySniffer {
+ ( this._contains_sd.microdata_type.BlogPosting
? ' BlogPosting (Microdata)' : '' )

+ ( this._contains_sd.jsonld_type.LiveBlogPosting
? ' BlogPosting (JSON-LD)' : '' )
+ ( this._contains_sd.microdata_type.LiveBlogPosting
? ' BlogPosting (Microdata)' : '' )

+ ( this._contains_sd.jsonld_type.VideoObject
? ' VideoObject (JSON-LD)' : '' )
+ ( this._contains_sd.microdata_type.VideoObject
Expand Down
6 changes: 3 additions & 3 deletions ampbench_lib_sd.js
Expand Up @@ -44,8 +44,8 @@ const
SD_UNKNOWN = 'Unknown, Invalid or Unavailable';

const
AMP_SD_TYPES = ['Article', 'NewsArticle', 'BlogPosting', 'VideoObject'],
AMP_SD_TYPES_ARTICLE = ['Article', 'NewsArticle', 'BlogPosting'],
AMP_SD_TYPES = ['Article', 'NewsArticle', 'BlogPosting', 'VideoObject', 'LiveBlogPosting'],
AMP_SD_TYPES_ARTICLE = ['Article', 'NewsArticle', 'BlogPosting', 'LiveBlogPosting'],
AMP_SD_TYPES_ARTICLE_COMPANIONS = ['WebPage', 'Organization', 'ImageObject'], // TODO
AMP_SD_TYPES_RECIPE = ['Recipe'],
AMP_SD_TYPES_WEBPAGE = ['WebPage'];
Expand Down Expand Up @@ -890,7 +890,7 @@ function extract_metadata_microdata_news_types(metadata) { // scan for all news
_md_news_found = false; // init to negative!
metadata.json.forEach( (md_block, _md_block_index) => {
_md_type = last_element_of_path((md_block['@type'][0]).toString());
if (sd_type_is_amp_article(_md_type)) { // AMP_SD_TYPES_ARTICLE = ['Article', 'NewsArticle', 'BlogPosting']
if (sd_type_is_amp_article(_md_type)) { // AMP_SD_TYPES_ARTICLE = ['Article', 'NewsArticle', 'BlogPosting', 'LiveBlogPosting]
// console.log('=> _md_type: ' + _md_type);
_md_news_found = true;
_md_types.push(_md_type);
Expand Down
36 changes: 18 additions & 18 deletions package-lock.json

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