Merge pull request #1074 from consul/youtube-videos

Youtube videos
This commit is contained in:
Juanjo Bazán
2016-04-19 10:22:42 +02:00
2 changed files with 13 additions and 9 deletions

View File

@@ -339,6 +339,10 @@
.debate-show, .proposal-show, .investment-project-show {
p {
word-wrap: break-word;
}
.social-share-full .social-share-button {
display:inline;
}

View File

@@ -1,30 +1,30 @@
module EmbedVideosHelper
def embedded_video_code
link = @proposal.video_url
link = @proposal.video_url
if link.match(/vimeo.*/)
server = "Vimeo"
elsif link.match(/youtu*.*/)
server = "YouTube"
end
end
if server == "Vimeo"
regExp = /vimeo.*(staffpicks\/|channels\/|videos\/|video\/|\/)([^#\&\?]*).*/
src = "https://player.vimeo.com/video/"
elsif server == "YouTube"
regExp = /youtu.*(youtu.be\/|v\/|u\/\w\/|embed\/|watch\?v=|\&v=)([^#\&\?]*).*/
src = "https://www.youtube.com/embed/"
regExp = /youtu.*(be\/|v\/|u\/\w\/|embed\/|watch\?v=|\&v=)([^#\&\?]*).*/
src = "https://www.youtube.com/embed/"
end
if regExp
if regExp
match = link.match(regExp)
end
if match and match[2]
'<iframe src="' + src + match[2] + '" frameborder="0" allowfullscreen></iframe>'
else
else
''
end
end
end
end