[Git][noosfero/noosfero][master] 3 commits: Added video type and url formatted to video plugin
Leandro Nunes
gitlab at mg.gitlab.com
Thu May 11 11:48:32 BRT 2017
Leandro Nunes pushed to branch master at Noosfero / noosfero
Commits:
a7d7e7f1 by Carlos Purificacao at 2017-05-08T11:34:39-03:00
Added video type and url formatted to video plugin
- - - - -
a9076324 by Carlos Purificacao at 2017-05-09T10:21:10-03:00
Fixed tests
- - - - -
73fff1e1 by Leandro Nunes at 2017-05-11T14:48:25+00:00
Merge branch 'add-video-type-to-video-plugin' into 'master'
Added video type and url formatted to video plugin
See merge request !1207
- - - - -
2 changed files:
- plugins/video/lib/video_plugin/video_block.rb
- plugins/video/test/unit/video_block_test.rb
Changes:
=====================================
plugins/video/lib/video_plugin/video_block.rb
=====================================
--- a/plugins/video/lib/video_plugin/video_block.rb
+++ b/plugins/video/lib/video_plugin/video_block.rb
@@ -39,6 +39,16 @@ class VideoPlugin::VideoBlock < Block
def api_content(params = {})
content = {:url => self.url}
content[:mime_type] = VideoPlugin::Video.mime_type(self.url) if VideoPlugin::Video.is_video_file?(self.url)
+ if is_youtube?
+ content[:video_type] = 'youtube'
+ content[:url_formatted] = format_embed_video_url_for_youtube
+ elsif is_vimeo?
+ content[:video_type] = "vimeo"
+ content[:url_formatted] = format_embed_video_url_for_vimeo
+ else is_video_file?
+ content[:video_type] = "video"
+ content[:url_formatted] = self.url
+ end
content
end
=====================================
plugins/video/test/unit/video_block_test.rb
=====================================
--- a/plugins/video/test/unit/video_block_test.rb
+++ b/plugins/video/test/unit/video_block_test.rb
@@ -12,9 +12,18 @@ class VideoBlockTest < ActiveSupport::TestCase
block = VideoPlugin::VideoBlock.new
block.url = "https://youtube.com/?v=XXXXX"
assert_includes block.api_content, :url
+ assert_includes block.api_content, :video_type
+ assert_includes block.api_content, :url_formatted
refute_includes block.api_content, :mime_type
end
+ should "api_content video_type is youtube" do
+ block = VideoPlugin::VideoBlock.new
+ block.url = "https://youtube.com/?v=XXXXX"
+ assert block.api_content[:video_type] == 'youtube'
+ assert_includes block.api_content[:url_formatted], 'www.youtube-nocookie.com'
+ end
+
should "is_youtube return true when the url contains http://youtube.com" do
block = VideoPlugin::VideoBlock.new
block.url = "http://youtube.com/?v=XXXXX"
@@ -108,9 +117,18 @@ class VideoBlockTest < ActiveSupport::TestCase
block = VideoPlugin::VideoBlock.new
block.url = "http://vimeo.com/98979"
assert_includes block.api_content, :url
+ assert_includes block.api_content, :video_type
+ assert_includes block.api_content, :url_formatted
refute_includes block.api_content, :mime_type
end
+ should "api_content video_type is vimeo" do
+ block = VideoPlugin::VideoBlock.new
+ block.url = "http://vimeo.com/98979"
+ assert block.api_content[:video_type] == 'vimeo'
+ assert_includes block.api_content[:url_formatted], '//player.vimeo.com/'
+ end
+
should "is_vimeo return true when the url contains http://vimeo.com" do
block = VideoPlugin::VideoBlock.new
block.url = "http://vimeo.com/98979"
@@ -196,9 +214,18 @@ class VideoBlockTest < ActiveSupport::TestCase
block = VideoPlugin::VideoBlock.new
block.url = "http://www.vmsd.com/98979.mp4"
assert_includes block.api_content, :url
+ assert_includes block.api_content, :video_type
+ assert_includes block.api_content, :url_formatted
assert_includes block.api_content, :mime_type
end
+ should "api_content video_type is video" do
+ block = VideoPlugin::VideoBlock.new
+ block.url = "http://www.vmsd.com/98979.mp4"
+ assert block.api_content[:video_type] == 'video'
+ assert_includes block.api_content[:url_formatted], block.url
+ end
+
should "is_video return true if url ends with mp4" do
block = VideoPlugin::VideoBlock.new
block.url = "http://www.vmsd.com/98979.mp4"
View it on GitLab: https://gitlab.com/noosfero/noosfero/compare/c4725ff26e9f971c1ba06c600201a9c6d2f4bdb8...73fff1e11d60bb83b5e1a4945d2671238018dc75
---
View it on GitLab: https://gitlab.com/noosfero/noosfero/compare/c4725ff26e9f971c1ba06c600201a9c6d2f4bdb8...73fff1e11d60bb83b5e1a4945d2671238018dc75
You're receiving this email because of your account on gitlab.com.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://listas.softwarelivre.org/pipermail/noosfero-dev/attachments/20170511/123b50fe/attachment-0001.html>
More information about the Noosfero-dev
mailing list