Skip to content

Commit

Permalink
Issue #196 - Youtube plugin should embed video
Browse files Browse the repository at this point in the history
  • Loading branch information
oponder committed Mar 9, 2013
1 parent 7530273 commit 7e653d6
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions app/assets/javascripts/backbone/plugins/youtube_embed.js.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,10 @@ class Kandan.Plugins.YouTubeEmbed

template: _.template '''
<div class="youtube-preview">
<a target="_blank" class="youtube-preview-link" href="<%= videoUrl %>">
<img class="youtube-preview-image" src="<%= thumbUrl %>" />
</a>
<iframe width="560" height="315"
src="http://www.youtube.com/embed/<%= videoId %>"
frameborder="0" allowfullscreen>
</iframe>
<div class="name"><%= subtitle %></div>
</div>
'''
Expand All @@ -27,15 +28,15 @@ class Kandan.Plugins.YouTubeEmbed
videoUrl = message.content.split(" ")[0]

videoId = message.content.match(@options.idRegex)[1]

thumbUrl = "http://img.youtube.com/vi/#{ videoId }/0.jpg"

subtitle = null
subtitle = "Youtube: #{comment}" if comment? and comment.length > 0
subtitle ||= videoUrl

message.content = @options.template({
videoUrl: videoUrl,
thumbUrl: thumbUrl,
videoId: videoId
subtitle: subtitle
})
return Kandan.Helpers.Activities.buildFromMessageTemplate(message)

0 comments on commit 7e653d6

Please sign in to comment.