Skip to content

Commit

Permalink
Merge branch 'release/1.0.2'
Browse files Browse the repository at this point in the history
  • Loading branch information
nleush committed Jan 12, 2017
2 parents 2844d61 + 686b421 commit 790775a
Show file tree
Hide file tree
Showing 52 changed files with 535 additions and 159 deletions.
7 changes: 7 additions & 0 deletions WHATSNEW.md
Expand Up @@ -4,6 +4,13 @@ This is the history of the Iframely changes. Updates that are older than one yea

To stay tuned and up-to-date, watch [Iframely on GitHub](https://github.com/itteco/iframely).

### 2017.01.12, Version 1.0.2

- Maintenance of the domain plugins
- Better consistency in product prices and article timestamps
- Added custom domains for hosted podcasts: podbean, simplecast and libsyn


### 2016.12.15, Version 1.0.1

- Maintenance of the domain plugins
Expand Down
9 changes: 9 additions & 0 deletions app.js
Expand Up @@ -121,9 +121,18 @@ function errorHandler(err, req, res, next) {
else if (code === 403) {
respondWithError(req, res, 403, 'Forbidden');
}
else if (code === 404) {
respondWithError(req, res, 404, 'Not found');
}
else if (code === 410) {
respondWithError(req, res, 410, 'Gone');
}
else if (code === 415) {
respondWithError(req, res, 415, 'Unsupported Media Type');
}
else if (code === 417) {
respondWithError(req, res, 417, 'Unsupported Media Type');
}
else {
respondWithError(req, res, code, 'Server error');
}
Expand Down
2 changes: 1 addition & 1 deletion docs/META.md
Expand Up @@ -62,7 +62,7 @@ Following Open Graph spec:
Following Pinterest spec:

- `price`
- `currency_code`
- `currency`
- `brand`
- `product_id`
- `availability`
Expand Down
4 changes: 2 additions & 2 deletions lib/plugins/system/oembed/oembedUtils.js
Expand Up @@ -24,7 +24,7 @@ function lookupStaticProviders(uri) {
var providers = require('./providers.json');

var protocolMatch = uri.match(/^(https?:\/\/)/);
if (!protocolMatch) {
if (!protocolMatch || /^https?:\/\/blog\./i.test(uri)) {
return null;
}
var uri2 = uri.substr(protocolMatch[1].length);
Expand Down Expand Up @@ -197,7 +197,7 @@ module.exports.getOembed = function(uri, options, callback) {

if (!error && data) {
cache.set(oembed_key, data, {
ttl: options.cache_ttl
ttl: options && options.cache_ttl
});
}

Expand Down
34 changes: 25 additions & 9 deletions lib/plugins/system/oembed/providers.json
Expand Up @@ -375,6 +375,14 @@
],
"endpoint": "http://api.meetup.com/oembed"
},
{
"name": "DeviantArt",
"templates": [
".*\\.deviantart\\.com/art/.*",
".*\\.deviantart\\.com/gallery/.*"
],
"endpoint": "http://backend.deviantart.com/oembed"
},
{
"name": "Behance",
"templates": [
Expand Down Expand Up @@ -434,13 +442,6 @@
],
"endpoint": "https://www.tumblr.com/oembed/1.0"
},
{
"name": "DeviantArt",
"templates": [
".*\\.deviantart\\.com/art/.*"
],
"endpoint": "http://backend.deviantart.com/oembed"
},
{
"name": "roomshare.jp",
"templates": [
Expand Down Expand Up @@ -543,6 +544,21 @@
"templates": [
"gty.im"
],
"endpoint": "http://embed.gettyimages.com//oembed"
}
"endpoint": "http://embed.gettyimages.com/oembed"
},
{
"name": "ReverbNation",
"templates": [
"reverbnation.com"
],
"endpoint": "https://www.reverbnation.com/oembed"
},
{
"name": "Twitch",
"templates": [
"twitch\\.tv/([a-zA-Z0-9_]+)/",
"clips.twitch.tv"
],
"endpoint": "https://api.twitch.tv/v4/oembed"
}
]
22 changes: 18 additions & 4 deletions lib/utils.js
Expand Up @@ -452,6 +452,10 @@ var NOW = new Date().getTime();

exports.unifyDate = function(date) {

if (_.isArray(date)) {
date = date[0];
}

if (typeof date === "string" && date.match(/^\d+$/)) {
date = parseInt(date);
}
Expand All @@ -467,19 +471,29 @@ exports.unifyDate = function(date) {
date = date * 1000;
}

return new Date(date).toISOString();
return new Date(date).toISOString().replace(/T.+$/, ''); // Remove time (no timezone).
}

// TODO: time in format 'Mon, 29 October 2012 18:15:00' parsed as local timezone anyway.
var timestamp = Date.parse(date);

if (isNaN(timestamp)) {
// allow Z at the end which Node doesn't seem to parse into timestamp otherwise
if (isNaN(timestamp) && date.replace) {
// allow Z at the end which Node doesn't seem to parse into timestamp otherwise
timestamp = Date.parse(date.replace(/Z$/, ''));
}

if (!isNaN(timestamp)) {
return new Date(timestamp).toISOString();
var dateStr = new Date(timestamp).toISOString();

// Remove time if no timezone specified.
if (!date.match(/Z$/i) // ISO date with Z at and.
&& !date.match(/ \w+$/i) // GMT, UTC, ...
&& !date.match(/\d\d:\d\d.*[\+\-]\d\d(:?\d\d)?$/i)) { // ISO 8601: +1000 -10 (YYYY-MM-DDThh:mm:ss[.sss]±hh:mm)

dateStr = dateStr.replace(/T.+$/, '')
}

return dateStr;
}

// Bad date to parse.
Expand Down
2 changes: 1 addition & 1 deletion modules/tests-ui/tester.js
Expand Up @@ -335,7 +335,7 @@ function processPluginTests(pluginTest, plugin, count, cb) {

// Error on unused mandatory methods.
if (unusedMethods.mandatory.length > 0) {
logEntry.errors_list = logEntry.errors || [];
logEntry.errors_list = logEntry.errors_list || [];
unusedMethods.mandatory.forEach(function(m) {
var inError = _.find(errors, function(error) {
return error.indexOf(m) > -1;
Expand Down
2 changes: 1 addition & 1 deletion package.json
@@ -1,6 +1,6 @@
{
"name": "iframely",
"version": "1.0.1",
"version": "1.0.2",

"description": "oEmbed/2 gateway endpoint. Get embed data for various http links through one self-hosted API",
"keywords": ["oembed", "embed", "open graph", "og", "twitter cards"],
Expand Down
File renamed without changes.
Expand Up @@ -7,7 +7,7 @@ module.exports = {
"*"
],

getLink: function(urlMatch) {
getLink: function(urlMatch, oembed) {
return {
type: CONFIG.T.text_html,
rel: [CONFIG.R.app, CONFIG.R.ssl, CONFIG.R.html5],
Expand All @@ -26,6 +26,7 @@ module.exports = {
"http://datawrapper.dwcdn.net/zjCKi/2/",
"http://cf.datawrapper.de/zjCKi/2/",
"http://cf.datawrapper.de/Gx44C/21/",
"http://cf.datawrapper.de/RrO5t/2/"
"http://cf.datawrapper.de/RrO5t/2/",
"http://datawrapper.dwcdn.net/pKk9h/1/"
]
};
26 changes: 26 additions & 0 deletions plugins/domains/bet.com.js
@@ -0,0 +1,26 @@
module.exports = {

re: /^https?:\/\/(?:www\.)?bet\.com\/videos?\//i,

mixins: [
"*"
],

getLink: function(og) {

if (og.video && og.video.url) {

return {
href: og.video.url.replace(/\.share\.height\-\d+\.width\-\d+\.html$/, '.share.responsive-true.html'),
rel: [CONFIG.R.player, CONFIG.R.html5, CONFIG.R.autoplay],
type: CONFIG.T.text_html,
"aspect-ratio": 16/9
}
}
},

tests: [
"http://www.bet.com/video/hiphopawards/2016/cyphers/kur-dave-east-young-m-a-sam-black-ms-jade.html",
"http://www.bet.com/video/106andpark/highlights/mack-wilds-106-and-park-3449.html"
]
};
10 changes: 6 additions & 4 deletions plugins/domains/d.pr.js
Expand Up @@ -17,14 +17,16 @@ module.exports = {
return {
href: oembed.url,
type: CONFIG.T.image,
rel: CONFIG.R.image,
width: oembed.width,
height: oembed.height
rel: CONFIG.R.image
// verify that image exists, omit sizes
// width: oembed.width,
// height: oembed.height
};
}
},

tests: [
"http://d.pr/i/9jB7"
"http://d.pr/i/9jB7",
// "http://d.pr/i/vO1p" // 404
]
};
3 changes: 2 additions & 1 deletion plugins/domains/espnfc.com.js
@@ -1,7 +1,8 @@
module.exports = {

re: [
/^https?:\/\/(?:www\.)?espnfc\.com\/[a-zA-Z\-0-9]+\/\d{2,3}\/video\/(\d+)\/?/i
/^https?:\/\/(?:www\.)?espnfc\.(?:com|us|co\.uk|com\.au)\/[a-zA-Z\-0-9]+\/\d{2,3}\/video\/(\d+)\/?/i,
/^https?:\/\/(?:www\.)?espnfcasia\.com\/[a-zA-Z\-0-9]+\/\d{2,3}\/video\/(\d+)\/?/i
],

mixins: ["*"],
Expand Down
10 changes: 9 additions & 1 deletion plugins/domains/facebook.com/facebook.post.js
Expand Up @@ -11,7 +11,7 @@ module.exports = {
/^https?:\/\/(?:www|m|business)\.facebook\.com\/media\/set\/\?set=[^\/]+(\d{10,})/i
],

getLink: function(oembed, options) {
getLink: function(url, oembed, options) {

var width = options.maxWidth || options.getProviderOptions('facebook.width', DEFAULT_WIDTH);

Expand All @@ -20,6 +20,13 @@ module.exports = {
html = html.replace(/connect\.facebook\.net\/\w{2}_\w{2}\/sdk\.js/i,
'connect.facebook.net/' + options.getProviderOptions('locale', 'en_US') + '/sdk.js'); // FB gives it based on server IP, and it has inaccurate IP2Location


if (/comment_id=\d+/i.test(url) && !/class=\"fb\-comment\-embed\"/.test(html)) {
// thank you FB for not working with comments
// https://developers.facebook.com/docs/plugins/embedded-comments
html = html.replace(/class=\"fb\-post\"/, 'class="fb-comment-embed" data-include-parent="' + (!options.getProviderOptions('facebook.exclude_comment_parent') ? 'true' : 'false') + '"');
}

return {
type: CONFIG.T.text_html,
rel: [CONFIG.R.app, CONFIG.R.ssl, CONFIG.R.html5],
Expand All @@ -33,6 +40,7 @@ module.exports = {
"https://www.facebook.com/logvynenko/posts/10151487164961783",
"https://www.facebook.com/chamvermeil/photos/a.398119066992522.1073741828.398102673660828/715129168624842/?type=1&theater",
"https://www.facebook.com/photo.php?fbid=530060777048531&set=a.215094428545169.62692.100001338405848&type=1",
"https://www.facebook.com/zuck/posts/10102577175875681?comment_id=1193531464007751&reply_comment_id=654912701278942",
{
noFeeds: true
}
Expand Down
23 changes: 19 additions & 4 deletions plugins/domains/facebook.com/facebook.video.js
Expand Up @@ -9,13 +9,27 @@ module.exports = {
/^https?:\/\/(?:www|business)\.facebook\.com\/[a-zA-Z0-9.]+\/videos\/.+/i
],

getLink: function(oembed, options) {
getLink: function(url, oembed, options) {

var html = oembed.html.replace(/connect\.facebook\.net\/\w{2}_\w{2}\/sdk\.js/i,
'connect.facebook.net/' + options.getProviderOptions('locale', 'en_US') + '/sdk.js');

var rel = [CONFIG.R.ssl, CONFIG.R.html5];

if (/comment_id=\d+/i.test(url) && !/class=\"fb\-comment\-embed\"/.test(html)) {
// thank you FB for not working with comments
// https://developers.facebook.com/docs/plugins/embedded-comments
html = html.replace(/class=\"fb\-video\"/, 'class="fb-comment-embed" data-include-parent="' + (!options.getProviderOptions('facebook.exclude_comment_parent') ? 'true' : 'false') + '"');
rel.push (CONFIG.R.app);
} else {
rel.push (CONFIG.R.player);
}


return {
type: CONFIG.T.text_html,
rel: [CONFIG.R.player, CONFIG.R.ssl, CONFIG.R.html5],
html: oembed.html.replace(/connect\.facebook\.net\/\w{2}_\w{2}\/sdk\.js/i,
'connect.facebook.net/' + options.getProviderOptions('locale', 'en_US') + '/sdk.js'),
rel: rel,
html: html,
"aspect-ratio": oembed.height ? oembed.width / oembed.height : 16/9
}
},
Expand All @@ -27,6 +41,7 @@ module.exports = {
"https://www.facebook.com/video.php?v=4392385966850",
"https://www.facebook.com/joe.yu.94/videos/10206321173378788/",
"https://business.facebook.com/KMPHFOX26/videos/10154356403004012/",
"https://www.facebook.com/tv2nyhederne/videos/1657445024271131/?comment_id=1657463030935997",
{
noFeeds: true
}
Expand Down
2 changes: 1 addition & 1 deletion plugins/domains/google.com/docs.google.com.js
Expand Up @@ -3,7 +3,7 @@ module.exports = {
provides: "schemaFileObject",

re: [
/https:\/\/(?:docs|drive)\.google\.com\/(forms|document|presentation|spreadsheets|file)\/d\/([a-zA-Z0-9_-]+)/i
/https:\/\/(?:docs|drive)\.google\.com\/(?:a\/[a-zA-Z0-9\-\_\.]+\/)?(forms|document|presentation|spreadsheets|file)\/d\/([a-zA-Z0-9_-]+)/i
],

mixins: [
Expand Down
5 changes: 3 additions & 2 deletions plugins/domains/i.gfycat.com.js
@@ -1,7 +1,7 @@
module.exports = {

re: [
/https?:\/\/(?:giant|thumbs|zippy)\.gfycat\.com\/([a-zA-Z0-9]+)(?:\-mobile)?\.(?:webm|mp4|gif)$/i,
/https?:\/\/(?:giant|thumbs|zippy)\.gfycat\.com\/([a-zA-Z0-9]+)(?:\-mobile|\-size_restricted)?\.(?:webm|mp4|gif)$/i,
/https?:\/\/gfycat\.com\/(?:detail|ifr)\/([a-zA-Z0-9]+)$/i
],

Expand All @@ -20,6 +20,7 @@ module.exports = {
"https://thumbs.gfycat.com/ObviousEuphoricHadrosaurus-mobile.mp4",
"https://gfycat.com/detail/ImmaculateWastefulCanine",
"https://zippy.gfycat.com/YellowHelplessDikdik.webm",
"https://gfycat.com/ifr/EvergreenAbsoluteAracari"
"https://gfycat.com/ifr/EvergreenAbsoluteAracari",
"https://thumbs.gfycat.com/IdealFluffyBabirusa-size_restricted.gif"
]
};
4 changes: 3 additions & 1 deletion plugins/domains/itunes.apple.com/apple.music.js
Expand Up @@ -3,7 +3,8 @@ module.exports = {
re: [
/^https?:\/\/(?:geo\.)?itunes\.apple\.com\/(\w{2})\/(album)(?:\/[^\/]+)?\/id(\d+)\?i=(\d+)?/i,
/^https?:\/\/(?:geo\.)?itunes\.apple\.com\/(\w{2})\/(album|playlist)(?:\/[^\/]+)?\/id(?:pl\.)?(\d+)/i,
/^https?:\/\/(?:geo\.)?itunes\.apple\.com\/()(album)\/id(\d+)\?/i
/^https?:\/\/(?:geo\.)?itunes\.apple\.com\/()(album)\/id(\d+)\??/i

],

mixins: [
Expand Down Expand Up @@ -33,6 +34,7 @@ module.exports = {
'https://itunes.apple.com/us/album/12-12-12-concert-for-sandy/id585701590?v0=WWW-NAUS-ITSTOP100-ALBUMS&ign-mpt=uo%3D4',
'https://itunes.apple.com/us/album/id944094900?i&ls=1',
'https://itunes.apple.com/album/id1170687816?ls=1',
"https://itunes.apple.com/album/id1125277620",
'https://geo.itunes.apple.com/us/album/trap-or-die-3/id1163301872?app=music',
'https://geo.itunes.apple.com/us/album/fake-love/id1168503200?i=1168503281&mt=1&app=music',
'https://itunes.apple.com/ca/album/greatest-feat.-kendrick-lamar/id1149503804?i=1149503816&app=music&ign-mpt=uo%3D4',
Expand Down
2 changes: 1 addition & 1 deletion plugins/domains/knightlab.js
Expand Up @@ -23,6 +23,6 @@ module.exports = {
"https://s3.amazonaws.com/uploads.knightlab.com/storymapjs/86a5b5c6facef8e74eb685573b846f6b/civilian-deaths-evidence-of-war-crimes-in-yemen/index.html",
"https://cdn.knightlab.com/libs/juxtapose/latest/embed/index.html?uid=f9031656-dcc3-11e5-a524-0e7075bba956",
"http://cdn.knightlab.com/libs/juxtapose/dev/embed/index.html?uid=75ec66e0-204a-11e5-91b9-0e7075bba956",
"http://cdn.knightlab.com/libs/timeline/latest/embed/index.html?source=0Atwxho6G5yhjdEdJNU1JMzhLdjdHUTFMNnc4bHNud3c&font=PTSerif-PTSans&maptype=toner&lang=en&hash_bookmark=true&start_zoom_adjust=2&height=650#13",
"http://cdn.knightlab.com/libs/timeline/latest/embed/index.html?source=0Atwxho6G5yhjdEdJNU1JMzhLdjdHUTFMNnc4bHNud3c&font=PTSerif-PTSans&maptype=toner&lang=en&hash_bookmark=true&start_zoom_adjust=2&height=650#13"
]
};

0 comments on commit 790775a

Please sign in to comment.