videawesome 0.0.3 → 0.0.4
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/videawesome.rb +10 -7
- metadata +3 -3
data/lib/videawesome.rb
CHANGED
@@ -1,27 +1,30 @@
|
|
1
1
|
module Videawesome
|
2
2
|
class Convertor
|
3
|
+
|
4
|
+
URL = /(ht)tp\:\/\/[www.youtube||vimeo||youtu]+\.[com||be]/
|
5
|
+
YOUTUBE = /[a-zA-Z0-9]{3,12}/
|
6
|
+
VIMEO = /[0-9]{3,12}/
|
7
|
+
|
3
8
|
def self.youtube_video(url, text, height, width)
|
4
|
-
|
5
|
-
url_ident =url.scan(ident_regexp).to_s
|
9
|
+
url_ident =url.scan(YOUTUBE).to_s
|
6
10
|
altered_text = text.gsub(url,"<iframe title='YouTube video player' class='youtube-player' type='text/html' width='#{width}' height='#{height}' src='http://www.youtube.com/v/#{url_ident}' frameborder='0'></iframe><br /><small> dont have flash player installed? <a href=\"http://www.youtube.com/v/#{url_ident}\" target=\"_blank\">click here</a></small>")
|
7
11
|
end
|
8
12
|
|
9
13
|
def self.vimeo_video(url, text, height, width)
|
10
|
-
|
11
|
-
url_ident = url.scan(ident_regexp).to_s
|
14
|
+
url_ident = url.scan(VIMEO).to_s
|
12
15
|
altered_text = text.gsub(url,"<iframe title='Vimeo Video Player' src='http://player.vimeo.com/video#{url_ident}' width='#{width}' height='#{height}' frameborder='0'></iframe><br /> <small>dont have flash player installed? <a href=\"http://player.vimeo.com/video#{url_ident}\" target=\"_blank\">click here</a></small>")
|
13
16
|
end
|
14
17
|
|
15
18
|
def self.parse_video(text, height, width)
|
16
|
-
|
17
|
-
url = text.split.grep(youtube_regexp).to_s
|
19
|
+
url = text.split.grep(URL).to_s
|
18
20
|
|
19
|
-
if url != "" && url.match("youtube.com") || url.match("
|
21
|
+
if url != "" && url.match("youtube.com") || url.match("youtu.be")
|
20
22
|
text = youtube_video(url, text, height, width)
|
21
23
|
elsif url != "" && url.match("vimeo.com")
|
22
24
|
text = vimeo_video(url, text, height, width)
|
23
25
|
end
|
24
26
|
return text
|
25
27
|
end
|
28
|
+
|
26
29
|
end
|
27
30
|
end
|
metadata
CHANGED