Class: BlueberryCMS::Video

Inherits:
Object
  • Object
show all
Includes:
Mongoid::Document, MongoidEnumerable
Defined in:
app/models/blueberry_cms/video.rb

Constant Summary collapse

YOUTUBE_REGEX =
/https?:\/\/(?:www\.)?(?:youtu\.be\/|youtube\.com\S*[^\w\-\s])([\w\-]{11})(?=[^\w\-]|$)(?![?=&+%\w.\-]*(?:['"][^<>]*>|<\/a>))[?=&+%\w.-]*/i
VIMEO_REGEX =
/(http|https)?:\/\/(www\.)?vimeo.com\/(?:channels\/(?:\w+\/)?|groups\/([^\/]*)\/videos\/|)(\d+)(?:|\/\?)/i

Instance Method Summary collapse

Instance Method Details



31
32
33
34
35
36
37
# File 'app/models/blueberry_cms/video.rb', line 31

def embed_link
  if youtube?
    "https://www.youtube.com/embed/#{video_id}?rel=0"
  elsif vimeo?
    "https://vimeo.com/#{video_id}"
  end
end

#preview_urlObject



39
40
41
42
43
44
45
# File 'app/models/blueberry_cms/video.rb', line 39

def preview_url
  if youtube?
    "https://img.youtube.com/vi/#{video_id}/mqdefault.jpg"
  elsif vimeo?
    Vimeo::Simple::Video.info(video_id).first['thumbnail_large']
  end
end


23
24
25
26
27
28
29
# File 'app/models/blueberry_cms/video.rb', line 23

def watch_link
  if youtube?
    "https://www.youtube.com/watch?v=#{video_id}&autoplay=1&rel=0"
  elsif vimeo?
    "https://vimeo.com/#{video_id}"
  end
end