Added support for spotify embeds

Closes #734

Thanks to @leolabs for the original PR.
This commit is contained in:
Igor Zhukov 2015-03-19 20:51:18 +03:00
parent 8d5c17be21
commit a39c14e751
3 changed files with 16 additions and 0 deletions

View File

@ -1399,6 +1399,10 @@ div.im_message_video_thumb {
.im_message_soundcloud_embed {
padding-bottom: 56.25%; /* 16/9 ratio */
}
.im_message_spotify_embed {
width: 300px;
height: 80px;
}
.im_message_media_embed iframe,
.im_message_media_embed webview {
position: absolute;

View File

@ -225,6 +225,13 @@ angular.module('myApp.directives', ['myApp.filters'])
'&amp;auto_play=false&amp;hide_related=true&amp;show_comments=false&amp;show_user=true&amp;show_reposts=false&amp;visual=true"></' + embedTag + '></div>';
break;
case 'spotify':
var spotifyUrl = embedData[1];
html = '<div class="im_message_media_embed im_message_spotify_embed"><' + embedTag + ' type="text/html" frameborder="0" allowtransparency="true" ' +
'src="https://embed.spotify.com/?uri=spotify:' + encodeEntities(encodeURIComponent(spotifyUrl)) +
'"></' + embedTag + '></div>';
break;
case 'twitter':
html = '<div class="im_message_twitter_embed"><blockquote class="twitter-tweet" lang="en"><a href="' + embedData[1] + '"></a></blockquote></div>';

View File

@ -3798,6 +3798,8 @@ angular.module('myApp.services', ['myApp.i18n', 'izhukov.utils'])
var facebookRegex = /^https?:\/\/(?:www\.)?facebook\.com\/.+?\/posts\/\d+/i;
var gplusRegex = /^https?:\/\/plus\.google\.com\/\d+\/posts\/[a-zA-Z0-9\-\_]+/i;
var soundcloudRegex = /^https?:\/\/(?:soundcloud\.com|snd\.sc)\/([a-zA-Z0-9%\-\_]+)\/([a-zA-Z0-9%\-\_]+)/i;
var spotifyRegex = /(https?:\/\/(open\.spotify\.com|play\.spotify\.com|spoti\.fi)\/(.+)|spotify:(.+))/i;
return {
wrapRichText: wrapRichText,
@ -4022,6 +4024,9 @@ angular.module('myApp.services', ['myApp.i18n', 'izhukov.utils'])
return ['soundcloud', embedUrlMatches[0]];
}
}
else if (embedUrlMatches = url.match(spotifyRegex)) {
return ['spotify', embedUrlMatches[3].replace('/', ':')];
}
if (!Config.Modes.chrome_packed) { // Need external JS
if (embedUrlMatches = url.match(twitterRegex)) {