Browse Source

Added support for spotify embeds

Closes #734

Thanks to @leolabs for the original PR.
master
Igor Zhukov 10 years ago
parent
commit
a39c14e751
  1. 4
      app/css/app.css
  2. 7
      app/js/directives.js
  3. 5
      app/js/services.js

4
app/css/app.css

@ -1399,6 +1399,10 @@ div.im_message_video_thumb { @@ -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;

7
app/js/directives.js

@ -225,6 +225,13 @@ angular.module('myApp.directives', ['myApp.filters']) @@ -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>';

5
app/js/services.js

@ -3798,6 +3798,8 @@ angular.module('myApp.services', ['myApp.i18n', 'izhukov.utils']) @@ -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']) @@ -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)) {

Loading…
Cancel
Save