Skip to content

Commit d41fbef

Browse files
committed
fix(instagram and flickr): fixed issue of inline embedding
1 parent 3078758 commit d41fbef

7 files changed

Lines changed: 24 additions & 21 deletions

File tree

demo/index.html

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ <h1>Loading embed.js in a block</h1>
5555
Cur rumor nocere?Emeritis adelphis satis perderes domina est.Gloss cadunt in bi-color brema!
5656
@(IIT Roorkee) Bi-color habitio virtualiter imitaris amicitia est.Teres tatas ducunt ad racana.Genetrixs
5757
prarere in
58-
rugensis civitas! :) https://www.instagram.com/p/_JHaOcjJ7h/?taken-by=9gag https://www.instagram.com/p/-mIWFsIVV-/?taken-by=natgeo
58+
rugensis civitas! :) https://www.instagram.com/p/_JHaOcjJ7h/?taken-by=9gag https://www.instagram.com/p/-mIWFsIVV-/?taken-by=natgeo https://www.flickr.com/photos/43301211@N03/23331635460/in/explore-2015-12-09/
5959
</div>
6060
</div>
6161
<script src="https://cdnjs.cloudflare.com/ajax/libs/marked/0.3.5/marked.min.js"></script>
@@ -78,20 +78,21 @@ <h1>Loading embed.js in a block</h1>
7878
var x = new EmbedJS({
7979
element: document.getElementById('block')
8080
});
81-
x.render()
81+
x.render();
8282
// x.render();
8383
var y = new EmbedJS({
84-
element: document.getElementById('block2')
84+
element: document.getElementById('block2'),
85+
inlineEmbed:'all'
8586
});
86-
y.render()
87+
y.render();
8788

8889
x.text(function(data){
8990
console.log(data);
90-
})
91+
});
9192

9293
ejs.template.basicAudio = function(match){
9394
return 'kjkh'+ match
94-
}
95+
};
9596

9697

9798
// ejs.applyEmbedJS("block");

dist/embed.min.js

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

src/embed.js

Lines changed: 6 additions & 5 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/modules/base.es6

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,8 @@ class Base {
1010

1111
process() {
1212
if (!utils.ifInline(this.options, this.service)) {
13-
let regexInline = this.options.link ? new RegExp(`([^>]*${this.regex.source})<\/a>`,'gm') : new RegExp(`([^\\s]*${this.regex.source})`,'gm')
13+
let regexInline = this.options.link ? new RegExp(`([^>]*${this.regex.source})<\/a>`,'gm') : new RegExp(`([^\\s]*${this.regex.source})`,'gm');
14+
console.log(regexInline);
1415
this.output = this.output.replace(regexInline, (match)=> {
1516
if(this.options.link){
1617
return !this.options.inlineText ? this.template(match.slice(0, -4)) + '</a>' : match + this.template(match.slice(0,-4))

src/js/modules/image/flickr.es6

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,15 @@ import Base from '../base.es6'
44
export class Flickr extends Base{
55
constructor(input, output,options, embeds){
66
super(input,output, options, embeds);
7-
this.regex = /flickr.com\/[a-z]+\/[a-zA-Z@_$!\d]+\/[\d]+/gi;
7+
this.regex = /flickr.com\/[a-z]+\/[a-zA-Z@_$!\d\-\]+\/[\d]+/gi;
88
this.service = 'flickr'
99
}
1010

1111
template(match){
1212
let dimensions = utils.dimensions(this.options);
1313
return ejs.template.flickr(match, dimensions, this.options) || `<div class="ejs-embed">
1414
<div class="ne-image-wrapper">
15-
<iframe src="${utils.toUrl(match)}/player/" width="${dimensions.width}" height="${dimensions.height}"></iframe>
15+
<iframe src="${utils.toUrl(match.split('/?')[0])}/player/" width="${dimensions.width}" height="${dimensions.height}"></iframe>
1616
</div>
1717
</div>`
1818
}

src/js/modules/image/instagram.es6

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,13 @@ import Base from '../base.es6'
44
export class Instagram extends Base{
55
constructor(input, output,options, embeds){
66
super(input,output, options, embeds);
7-
this.regex = /instagram.com\/p\/[a-zA-Z0-9_-]+/gi;
7+
this.regex = /instagram.com\/p\/[a-zA-Z0-9_\/\?\-\=]+/gi;
88
this.service = 'instagram'
99
}
1010

1111
template(match){
1212
let dimensions = utils.dimensions(this.options);
13-
return ejs.template.instagram(match, dimensions, this.options) || `<div class="ejs-embed ejs-instagram"><iframe src="${utils.toUrl(match)}/embed/" height="${dimensions.height}"></iframe></div>`
13+
return ejs.template.instagram(match, dimensions, this.options) || `<div class="ejs-embed ejs-instagram"><iframe src="${utils.toUrl(match.split('/?')[0])}/embed/" height="${dimensions.height}"></iframe></div>`
1414
}
1515
}
1616

0 commit comments

Comments
 (0)