-
Notifications
You must be signed in to change notification settings - Fork 406
Plugin Vimeo
fusion94 edited this page Feb 13, 2013
·
4 revisions
Just paste in an Vimeo url and type a subtitle.
http://vimeo.com/46257054 OpenROV Explores Aquarius
class Kandan.Plugins.VimeoEmbed
@options:
regex: /^http[s]?://(w{3}.)?vimeo.com/(\d+)/i
template: _.template '''
<div class="vimeo-preview">
<iframe src="http://player.vimeo.com/video/<%= videoId %>" width="500" height="281" frameborder="0" webkitAllowFullScreen mozallowfullscreen allowFullScreen></iframe>
<div class="name"><%= subtitle %></div>
</div>
'''
@init: ()->
Kandan.Modifiers.register @options.regex, (message, state) =>
comment = null
# No spaces in message content indicates just a link
if message.content.indexOf(" ") == -1
videoUrl = message.content
else
# Spaces indicate a subtitle
comment = $.trim(message.content.substr(message.content.indexOf(" ") + 1));
videoUrl = message.content.split(" ")[0]
videoId = message.content.match(@options.regex)[2]
subtitle = null
subtitle = "Vimeo: #{comment}" if comment? and comment.length > 0
subtitle ||= videoUrl
message.content = @options.template({
videoId: videoId,
subtitle: subtitle
})
return Kandan.Helpers.Activities.buildFromMessageTemplate(message)
Copyright © 2012-2013 - KandanApp