File tree Expand file tree Collapse file tree 2 files changed +39
-0
lines changed
models/post/embedded_media Expand file tree Collapse file tree 2 files changed +39
-0
lines changed Original file line number Diff line number Diff line change 35
35
display : block
36
36
margin : 0 auto
37
37
38
+ .embedded-vimeo
39
+ iframe
40
+ display : block
41
+ margin : 0 auto
42
+
38
43
.embedded-poll
39
44
padding : 10px 15px
40
45
max-width : 200px
Original file line number Diff line number Diff line change
1
+ class Post
2
+ class EmbeddedMedia
3
+ class VimeoTag < EmbeddedMedia ::Tag
4
+
5
+ def initialize ( _embedded_media , vimeo_id )
6
+ @vimeo_id = vimeo_id
7
+ end
8
+
9
+ def self . parse_url ( url )
10
+ return nil unless url =~ %r[^https?://(?:www\. )?vimeo\. com/]
11
+ # https://stackoverflow.com/questions/13286785/get-video-id-from-vimeo-url/13286930#13286930
12
+ vimeo_id = /^.*(?:vimeo.com)\/ (?:channels\/ |channels\/ \w +\/ |groups\/ [^\/ ]*\/ videos\/ |video\/ |album\/ \d +\/ video\/ |)(\d +)(?:$|\/ |\? )/ . match ( url ) [ 1 ]
13
+ self . new ( Post ::EmbeddedMedia , vimeo_id )
14
+ end
15
+
16
+ def to_html
17
+ content_tag (
18
+ :iframe ,
19
+ nil ,
20
+ frameborder : 0 ,
21
+ allowfullscreen : true ,
22
+ width : 606 ,
23
+ height : 455 ,
24
+ src : "//player.vimeo.com/video/#{ @vimeo_id } " ,
25
+ allowfullscreen : ''
26
+ )
27
+ end
28
+
29
+ def to_s
30
+ "{{Vimeo:#{ @vimeo_id } }}"
31
+ end
32
+ end
33
+ end
34
+ end
You can’t perform that action at this time.
0 commit comments