Skip to content

Commit fbd58d6

Browse files
committed
fix(test): added some test and refactoring
1 parent 188429c commit fbd58d6

13 files changed

Lines changed: 696 additions & 664 deletions

File tree

Gruntfile.js

Lines changed: 235 additions & 231 deletions
Large diffs are not rendered by default.

dist/embed.min.js

Lines changed: 3 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@
4848
"es6-promise": "^3.0.2",
4949
"eslint": "^1.10.3",
5050
"grunt": "~0.4.5",
51+
"grunt-bump": "^0.7.0",
5152
"grunt-cli": "~0.1.13",
5253
"grunt-contrib-clean": "^0.7.0",
5354
"grunt-contrib-connect": "^0.11.2",
@@ -58,7 +59,6 @@
5859
"grunt-contrib-watch": "^0.6.1",
5960
"grunt-eslint": "^17.3.1",
6061
"grunt-postcss": "^0.7.1",
61-
"grunt-release": "^0.13.0",
6262
"grunt-retinafy": "^0.1.5",
6363
"grunt-rollup": "^0.6.1",
6464
"grunt-spritesmith": "^6.1.0",

rollup.config.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,6 @@ var config = {
1616
include: 'node_modules/**'
1717
})
1818
]
19-
}
19+
};
2020

21-
module.exports = config
21+
module.exports = config;

src/embed.js

Lines changed: 251 additions & 250 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/embed.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/js/embed.es6

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -415,9 +415,11 @@ import helper from './modules/helper.es6'
415415
youtube(){
416416
},
417417
openGraph(){
418-
}, Github(){
419418
},
420-
slideShare(){}
419+
Github(){
420+
},
421+
slideShare(){
422+
}
421423
}
422424
};
423425
window.EmbedJS = EmbedJS

src/js/modules/code/gist.es6

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,8 @@ export default class Gist extends Base {
2727
zone.appendChild(gistFrame);
2828

2929
// Create the iframe's document
30-
let url = gists[i].getAttribute('data-src')
31-
url = url.indexOf('http') === -1 ? `https://${url}` : url
30+
let url = gists[i].getAttribute('data-src');
31+
url = url.indexOf('http') === -1 ? `https://${url}` : url;
3232
let gistFrameHTML = `<html><base target="_parent"/><body onload="parent.document.getElementById('ejs-gist-${i}').style.height=parseInt(document.body.scrollHeight)+20+'px'"><script type="text/javascript" src="${url}.js"></script></body></html>`;
3333

3434
// Set iframe's document with a trigger for this document to adjust the height

src/js/modules/helper.es6

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ var helper = {
1010
*/
1111
play(options) {
1212
/** Execute the customVideoClickHandler if the user wants to handle it on his own. */
13-
if (options.customVideoClickHandler) return options.videoClickHandler(options, this.template)
13+
if (options.customVideoClickHandler) return options.videoClickHandler(options, this.template);
1414

1515
let classes = document.getElementsByClassName(options.videoClickClass);
1616
let _this = this;
@@ -146,7 +146,7 @@ var helper = {
146146
while ((match = utils.matches(_this.regex, _this.input)) !== null) {
147147
let url = match[0];
148148
if (!_this.options.served.indexOf(url) === -1) continue;
149-
let text = await urlToText(_this, match, url, true)
149+
let text = await urlToText(_this, match, url, true);
150150
if (!text) continue;
151151
_this.options.served.push(url);
152152
_this.embeds.push({

src/js/modules/image/slideshare.es6

Lines changed: 32 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -4,39 +4,40 @@ import helper from './../helper.es6'
44
import fetchJsonp from '../../vendor/fetch_jsonp.js'
55

66
export default class SlideShare {
7-
constructor(input, output, options, embeds) {
8-
this.input = input;
9-
this.output = output;
10-
this.options = options;
11-
this.embeds = embeds;
12-
this.regex = /slideshare.net\/[a-zA-Z0-9_-]*\/[a-zA-Z0-9_-]*/gi;
13-
this.service = 'slideshare';
14-
}
7+
constructor(input, output, options, embeds) {
8+
this.input = input;
9+
this.output = output;
10+
this.options = options;
11+
this.embeds = embeds;
12+
this.regex = /slideshare.net\/[a-zA-Z0-9_-]*\/[a-zA-Z0-9_-]*/gi;
13+
this.service = 'slideshare';
14+
}
1515

16-
static async fetchData(url) {
17-
let api = `http://www.slideshare.net/api/oembed/2?url=${url}&format=jsonp`;
18-
let response = await fetchJsonp(api, {
19-
credentials: 'include'
20-
});
21-
let data = await response.json();
22-
return data.html;
23-
}
16+
static async fetchData(_this, url) {
17+
const dimensions = utils.dimensions(_this.options);
18+
let api = `http://www.slideshare.net/api/oembed/2?url=${url}&format=jsonp&maxwidth=${dimensions.width}&maxheight=${dimensions.height}`;
19+
let response = await fetchJsonp(api, {
20+
credentials: 'include'
21+
});
22+
let data = await response.json();
23+
return data.html;
24+
}
2425

25-
template(html) {
26-
return ejs.template.slideShare(html, this.options) || `<div class="ejs-embed ejs-slideshare">${html}</div>`;
27-
}
26+
template(html) {
27+
return ejs.template.slideShare(html, this.options) || `<div class="ejs-embed ejs-slideshare">${html}</div>`;
28+
}
2829

29-
static async urlToText(_this, match, url) {
30-
let html = await SlideShare.fetchData(url);
31-
return _this.template(html);
32-
}
30+
static async urlToText(_this, match, url) {
31+
let html = await SlideShare.fetchData(_this, url);
32+
return _this.template(html);
33+
}
3334

34-
async process() {
35-
if (!utils.ifInline(this.options, this.service)) {
36-
this.output = await helper.inlineEmbed(this, SlideShare.urlToText);
37-
} else {
38-
this.embeds = await helper.normalEmbed(this, SlideShare.urlToText);
39-
}
40-
return [this.output, this.embeds]
41-
}
35+
async process() {
36+
if (!utils.ifInline(this.options, this.service)) {
37+
this.output = await helper.inlineEmbed(this, SlideShare.urlToText);
38+
} else {
39+
this.embeds = await helper.normalEmbed(this, SlideShare.urlToText);
40+
}
41+
return [this.output, this.embeds]
42+
}
4243
}

0 commit comments

Comments
 (0)