Skip to content

Commit 2b84036

Browse files
committed
feat(ted): Support for Ted video embedding support added
1 parent c6f448b commit 2b84036

4 files changed

Lines changed: 40 additions & 7 deletions

File tree

src/embed.es6

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ import Emoji from './modules/emoticons/emoji.es6';
2424
import Smiley from './modules/emoticons/smiley.es6';
2525
import Url from './modules/url.es6';
2626
import CodeEmbed from './modules/code/codeEmbed.es6';
27+
import VideoEmbed from './modules/video/videoEmbed.es6';
2728
import Twitter from './modules/twitter.es6';
2829

2930
(function() {
@@ -46,7 +47,9 @@ import Twitter from './modules/twitter.es6';
4647
lang : 'en'
4748
},
4849
excludeEmbed : [],
49-
codeEmbedHeight : 500
50+
codeEmbedHeight : 500,
51+
videoHeight : null,
52+
videoWidth : null,
5053
};
5154

5255
class EmbedJS {
@@ -65,6 +68,7 @@ import Twitter from './modules/twitter.es6';
6568
output = options.emoji ? await (new Emoji(output, options).process()) : output;
6669
output = options.fontIcons ? await (new Smiley(output, options).process()) : output;
6770
[output, embeds] = await (new CodeEmbed(input, output, options, embeds).process());
71+
[output, embeds] = await (new VideoEmbed(input, output, options, embeds).process());
6872

6973
if (options.tweetsEmbed) {
7074
let twitter = new Twitter(input, options, embeds);

src/modules/video/ted.es6

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
import utils from '../utils.es6';
2-
31
import Video from './video.es6';
42

53
class Ted extends Video{
@@ -9,9 +7,13 @@ class Ted extends Video{
97
}
108

119
template(id){
12-
var template = `<div class="ejs-embed">
13-
<iframe src="http://embed.ted.com/talks/${id.split('/')[2]}.html" height="${videoDimensions.height}" width="${videoDimensions.width}"></iframe>
10+
let dimensions = this.dimensions();
11+
var template =
12+
`<div class="ejs-embed">
13+
<iframe src="http://embed.ted.com/talks/${id.split('/')[2]}.html" height="${dimensions.height}" width="${dimensions.width}"></iframe>
1414
</div>`;
15-
15+
return template;
1616
}
1717
}
18+
19+
module.exports = Ted;

src/modules/video/video.es6

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ class Video {
77
this.embeds = embeds;
88
}
99

10-
get dimensions() {
10+
dimensions() {
1111
let options = this.options;
1212
let dimensions = {
1313
width: options.videoWidth,

src/modules/video/videoEmbed.es6

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
import utils from '../utils.es6';
2+
3+
import Ted from './ted.es6';
4+
5+
class VideoEmbed {
6+
constructor(input, output, options, embeds) {
7+
this.input = input;
8+
this.output = output;
9+
this.options = options;
10+
this.embeds = embeds;
11+
}
12+
13+
async process() {
14+
try {
15+
let input = this.input;
16+
let output = this.output;
17+
let embeds = this.embeds;
18+
embeds = utils.ifEmbed(this.options, 'ted') ? await (new Ted(input, this.options, embeds).process()) : output;
19+
20+
return [output, embeds];
21+
} catch (error) {
22+
console.log(error);
23+
}
24+
}
25+
}
26+
27+
module.exports = VideoEmbed

0 commit comments

Comments
 (0)