@@ -4,39 +4,40 @@ import helper from './../helper.es6'
44import fetchJsonp from '../../vendor/fetch_jsonp.js'
55
66export 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 = / s l i d e s h a r e .n e t \/ [ a - z A - Z 0 - 9 _ - ] * \/ [ a - z A - Z 0 - 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 = / s l i d e s h a r e .n e t \/ [ a - z A - Z 0 - 9 _ - ] * \/ [ a - z A - Z 0 - 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