forked from itteco/iframely
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbehance.net.js
68 lines (54 loc) · 2.12 KB
/
behance.net.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
var $ = require('cheerio');
module.exports = {
re: [
/https?:\/\/www\.behance\.net\/gallery\/([a-zA-Z0-9\-\(\)]+)\/([0-9]+)/i,
/https?:\/\/www\.behance\.net\/gallery\/([0-9]+)\/([a-zA-Z0-9\-\(\)]+)/i,
/https?:\/\/([a-z-\.]+)\/gallery\/([a-zA-Z0-9\-\(\)]+)\/([0-9]+)/i,
/https?:\/\/([a-z-\.]+)\/gallery\/([0-9]+)\/([a-zA-Z0-9\-\(\)]+)/i
],
mixins: [
"oembed-thumbnail",
"domain-icon",
"oembed-author",
"oembed-canonical",
"copyright",
"og-description",
"keywords",
"oembed-site",
"oembed-title"
],
getLink: function(oembed, meta) {
var site = (meta.og && meta.og.site_name) || (meta.twitter && meta.twitter.site) || oembed.provider_name;
if (!site || !/behance/i.test(site)) {
return;
}
var $container = $('<div>');
try {
$container.html(oembed.html);
} catch (ex) {}
var $iframe = $container.find('iframe');
// if embed code contains <iframe>, return src
if ($iframe.length === 1) {
return {
href: $iframe.attr('src').replace("http://", "https://"),
type: CONFIG.T.text_html,
rel: [CONFIG.R.reader, CONFIG.R.oembed, CONFIG.R.html5],
//"min-width": oembed.thumbnail_width,
"min-height": oembed.thumbnail_height,
"aspect-ratio": 1 / Math.sqrt(2) // A4
};
}
},
tests: [{
skipMixins: ["copyright", "og-description"]
},
"http://www.behance.net/gallery/ORBITAL-MECHANICS/10105739",
"http://www.behance.net/gallery/TRIGGER/9939801",
"http://www.behance.net/gallery/MEGA-CITIES/8406797",
"http://portfolios.scad.edu/gallery/Privy-Boards-Graphic-Shirts/11126843",
"http://ndagallery.cooperhewitt.org/gallery/12332063/Barclays-Center"
// possible false positives:
// http://www.engadget.com/gallery/a-tour-of-qualcomms-connected-home-of-the-future/3251997/
// http://absurdynka.deviantart.com/gallery/3866789/calligraphy
]
};