video_block.rb
1.04 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
class VideoPlugin::VideoBlock < Block
attr_accessible :url, :width, :height
settings_items :url, :type => :string, :default => ""
settings_items :width, :type => :integer, :default => 400
settings_items :height, :type => :integer, :default => 315
YOUTUBE_ID_FORMAT = '\w-'
def is_youtube?
VideoPlugin::Video.is_youtube?(url)
end
def is_vimeo?
VideoPlugin::Video.is_vimeo?(url)
end
def is_video_file?
url.match(/.*(mp4|ogg|ogv|webm)$/) ? true : false
end
def format_embed_video_url_for_youtube
VideoPlugin::Video.format_embed_video_url_for_youtube(url)
end
def format_embed_video_url_for_vimeo
VideoPlugin::Video.format_embed_video_url_for_vimeo(url)
end
def self.description
_('Display a Video')
end
def help
_('This block presents a video from youtube, vimeo and some video formats (mp4, ogg, ogv and webm)')
end
private
def extract_youtube_id
VideoPlugin::Video.extract_youtube_id(url)
end
def extract_vimeo_id
VideoPlugin::Video.extract_vimeo_id(url)
end
end