Skip to content

Commit 20f8cb2

Browse files
committed
feat(vine): Support for vine added
1 parent e2ae7da commit 20f8cb2

3 files changed

Lines changed: 47 additions & 18 deletions

File tree

src/embed.es6

Lines changed: 25 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -19,13 +19,13 @@
1919
//OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
2020
//SOFTWARE.
2121

22-
import utils from './modules/utils.es6';
23-
import Emoji from './modules/emoticons/emoji.es6';
24-
import Smiley from './modules/emoticons/smiley.es6';
25-
import Url from './modules/url.es6';
22+
import utils from './modules/utils.es6';
23+
import Emoji from './modules/emoticons/emoji.es6';
24+
import Smiley from './modules/emoticons/smiley.es6';
25+
import Url from './modules/url.es6';
2626
import CodeEmbed from './modules/code/codeEmbed.es6';
2727
import VideoEmbed from './modules/video/videoEmbed.es6';
28-
import Twitter from './modules/twitter.es6';
28+
import Twitter from './modules/twitter.es6';
2929

3030
(function() {
3131

@@ -40,16 +40,23 @@ import Twitter from './modules/twitter.es6';
4040
highlightCode: true,
4141
tweetsEmbed: true,
4242
tweetOptions: {
43-
maxWidth : 550,
44-
hideMedia : false,
45-
hideThread : false,
46-
align : 'none',
47-
lang : 'en'
43+
maxWidth: 550,
44+
hideMedia: false,
45+
hideThread: false,
46+
align: 'none',
47+
lang: 'en'
48+
},
49+
excludeEmbed: [],
50+
codeEmbedHeight: 500,
51+
videoHeight: null,
52+
videoWidth: null,
53+
vineOptions: {
54+
maxWidth: null,
55+
type: 'postcard', //'postcard' or 'simple' embedding
56+
responsive: true,
57+
width : 350,
58+
height : 460
4859
},
49-
excludeEmbed : [],
50-
codeEmbedHeight : 500,
51-
videoHeight : null,
52-
videoWidth : null,
5360
};
5461

5562
class EmbedJS {
@@ -64,9 +71,9 @@ import Twitter from './modules/twitter.es6';
6471
let input = this.input;
6572
let options = this.options;
6673
let embeds = [];
67-
let output = options.link ? await (new Url(input, options).process()) : output;
68-
output = options.emoji ? await (new Emoji(output, options).process()) : output;
69-
output = options.fontIcons ? await (new Smiley(output, options).process()) : output;
74+
let output = options.link ? await (new Url(input, options).process()) : output;
75+
output = options.emoji ? await (new Emoji(output, options).process()) : output;
76+
output = options.fontIcons ? await (new Smiley(output, options).process()) : output;
7077
[output, embeds] = await (new CodeEmbed(input, output, options, embeds).process());
7178
[output, embeds] = await (new VideoEmbed(input, output, options, embeds).process());
7279

@@ -83,7 +90,7 @@ import Twitter from './modules/twitter.es6';
8390
this.render(result)
8491
}
8592

86-
render(result){
93+
render(result) {
8794
this.options.element.innerHTML = result;
8895
twttr.widgets.load(this.options.element);
8996
}

src/modules/video/videoEmbed.es6

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import Ted from './ted.es6';
44
import Dailymotion from './dailymotion.es6';
55
import Ustream from './ustream.es6';
66
import LiveLeak from './liveleak.es6';
7+
import Vine from './vine.es6';
78

89
class VideoEmbed {
910
constructor(input, output, options, embeds) {
@@ -22,6 +23,7 @@ class VideoEmbed {
2223
embeds = utils.ifEmbed(this.options, 'dailymotion') ? await (new Dailymotion(input, this.options, embeds).process()) : output;
2324
embeds = utils.ifEmbed(this.options, 'ustream') ? await (new Ustream(input, this.options, embeds).process()) : output;
2425
embeds = utils.ifEmbed(this.options, 'liveleak') ? await (new LiveLeak(input, this.options, embeds).process()) : output;
26+
embeds = utils.ifEmbed(this.options, 'vine') ? await (new Vine(input, this.options, embeds).process()) : output;
2527

2628
return [output, embeds];
2729
} catch (error) {

src/modules/video/vine.es6

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
import Video from './video.es6';
2+
3+
class Vine extends Video{
4+
constructor(input,options, embeds){
5+
super(input, options, embeds);
6+
this.regex = /vine.co\/v\/[a-zA-Z0-9]+/gi;
7+
}
8+
9+
template(match){
10+
let config = this.options.vineOptions;
11+
12+
let template =
13+
`<div class="ejs-vine">
14+
<iframe class="ejs-vine-iframe" src="https://vine.co/v/${match.split('/')[2]}/embed/${config.type}" height="${config.height}" width="${config.width}"></iframe>
15+
</div>`;
16+
return template;
17+
}
18+
}
19+
20+
module.exports = Vine;

0 commit comments

Comments
 (0)