From cf21bd0791388fb35c15cb7b3ede2c1e44be159d Mon Sep 17 00:00:00 2001 From: Daniela Soares Feitosa Date: Sat, 16 Nov 2013 08:11:48 -0300 Subject: [PATCH] Small cosmetics changes --- plugins/video/README | 11 +++++++---- plugins/video/lib/video_block.rb | 14 +++++++------- plugins/video/lib/video_plugin.rb | 2 +- plugins/video/test/functional/video_plugin_environment_design_controller_test.rb | 2 +- plugins/video/test/unit/video_block_test.rb | 30 +++++++++++++++--------------- plugins/video/views/video_block.rhtml | 2 +- 6 files changed, 32 insertions(+), 29 deletions(-) diff --git a/plugins/video/README b/plugins/video/README index 13c2998..244f1bf 100644 --- a/plugins/video/README +++ b/plugins/video/README @@ -1,9 +1,12 @@ README - Video (Video Plugin) ================================ -Video is a plugin to allow the user adds a block where you could choose any url from youtube, vimeo and url's of the following file formats: mp4, ogg, ogv and webm. +Video is a plugin that allow users to add a block where you can choose +any url from youtube, vimeo and url's of the following file formats: +mp4, ogg, ogv and webm. -The Video block will be available for all layout columns of communities, peole, enterprises and environments. +The Video block will be available for all layout columns of communities, +people, enterprises and environments. INSTALL ======= @@ -11,7 +14,7 @@ INSTALL Enable Plugin ------------- -Also, you need to enable Video Plugin at you Noosfero: +Also, you need to enable Video Plugin on your Noosfero: cd ./script/noosfero-plugins enable video @@ -33,7 +36,7 @@ $ rake test:noosfero_plugins:video Get Involved ============ -If you found any bug and/or want to collaborate, please send an e-mail to leandronunes@gmail.com +If you find any bug and/or want to collaborate, please send an e-mail to leandronunes@gmail.com LICENSE ======= diff --git a/plugins/video/lib/video_block.rb b/plugins/video/lib/video_block.rb index 5e95d58..486741e 100644 --- a/plugins/video/lib/video_block.rb +++ b/plugins/video/lib/video_block.rb @@ -12,7 +12,7 @@ class VideoBlock < Block url.match(/^(http[s]?:\/\/)?(www.)?(vimeo.com|player.vimeo.com\/video)\/[[:digit:]]+/) ? true : false end - def is_video_file? + def is_video_file? url.match(/.*(mp4|ogg|ogv|webm)$/) ? true : false end @@ -25,11 +25,11 @@ class VideoBlock < Block end def self.description - _('Add Videos') + _('Display a Video') end def help - _('This block presents a video from youtube, vimeo and video formats mp4, ogg, ogv and webm') + _('This block presents a video from youtube, vimeo and some video formats (mp4, ogg, ogv and webm)') end def content(args={}) @@ -39,20 +39,20 @@ class VideoBlock < Block render :file => 'video_block', :locals => { :block => block } end end - + private def extract_youtube_id return nil unless is_youtube? youtube_match = url.match('v=([[:alnum:]]*)') youtube_match ||= url.match('youtu.be\/([[:alnum:]]*)') - youtube_match[1] unless youtube_match.nil? + youtube_match[1] unless youtube_match.nil? end - + def extract_vimeo_id return nil unless is_vimeo? vimeo_match = url.match('([[:digit:]]*)$') - vimeo_match[1] unless vimeo_match.nil? + vimeo_match[1] unless vimeo_match.nil? end end diff --git a/plugins/video/lib/video_plugin.rb b/plugins/video/lib/video_plugin.rb index f77588a..e3b0a4d 100644 --- a/plugins/video/lib/video_plugin.rb +++ b/plugins/video/lib/video_plugin.rb @@ -7,7 +7,7 @@ class VideoPlugin < Noosfero::Plugin end def self.plugin_description - _("A plugin that adds a block where you could add videos from youtube, vimeo and html5.") + _("A plugin that adds a block where you can add videos from youtube, vimeo and html5.") end def self.extra_blocks diff --git a/plugins/video/test/functional/video_plugin_environment_design_controller_test.rb b/plugins/video/test/functional/video_plugin_environment_design_controller_test.rb index 9f31007..2a376b4 100644 --- a/plugins/video/test/functional/video_plugin_environment_design_controller_test.rb +++ b/plugins/video/test/functional/video_plugin_environment_design_controller_test.rb @@ -118,7 +118,7 @@ class EnvironmentDesignControllerTest < ActionController::TestCase assert_tag :tag => 'div', :attributes => {:class => 'video-block-data'}, :descendant => { :tag => 'div', :attributes => {:class => 'video'} } end - should 'display a messagem to register a new url' do + should 'display a message to register a new url' do block.url='http://www.vmsd.com/test.pdf' block.save get :index diff --git a/plugins/video/test/unit/video_block_test.rb b/plugins/video/test/unit/video_block_test.rb index 601af9b..a7e3587 100644 --- a/plugins/video/test/unit/video_block_test.rb +++ b/plugins/video/test/unit/video_block_test.rb @@ -8,19 +8,19 @@ class VideoBlockTest < ActiveSupport::TestCase block.url = "http://youtube.com/?v=XXXXX" assert block.is_youtube? end - + should "is_youtube return true when the url contains https://youtube.com" do block = VideoBlock.new block.url = "https://youtube.com/?v=XXXXX" assert block.is_youtube? end - + should "is_youtube return true when the url contains https://www.youtube.com" do block = VideoBlock.new block.url = "https://www.youtube.com/?v=XXXXX" assert block.is_youtube? end - + should "is_youtube return true when the url contains www.youtube.com" do block = VideoBlock.new block.url = "www.youtube.com/?v=XXXXX" @@ -50,13 +50,13 @@ class VideoBlockTest < ActiveSupport::TestCase block.url = "http://www.yt.com/?v=XXXXX" assert !block.is_youtube? end - + should "format embed video for youtube videos" do block = VideoBlock.new block.url = "youtube.com/?v=XXXXX" assert_match /\/\/www.youtube-nocookie.com\/embed/, block.format_embed_video_url_for_youtube end - + should "format embed video return nil if is not a youtube url" do block = VideoBlock.new block.url = "http://www.yt.com/?v=XXXXX" @@ -69,7 +69,7 @@ class VideoBlockTest < ActiveSupport::TestCase block.url = "youtube.com/?v=#{id}" assert_equal id, block.send('extract_youtube_id') end - + should "extract youtube id from youtube video url's if it's a valid youtube short url" do block = VideoBlock.new id = 'oi43jre2d2' @@ -82,33 +82,33 @@ class VideoBlockTest < ActiveSupport::TestCase block.url = "http://www.yt.com/?v=XXXXX" assert_nil block.send('extract_youtube_id') end - + should "extract_youtube_id return nil if youtue url there is no id" do block = VideoBlock.new block.url = "youtube.com/" assert_nil block.send('extract_youtube_id') end - + #### Tests for Vimeo Videos - + should "is_vimeo return true when the url contains http://vimeo.com" do block = VideoBlock.new block.url = "http://vimeo.com/98979" assert block.is_vimeo? end - + should "is_vimeo return true when the url contains https://vimeo.com" do block = VideoBlock.new block.url = "https://vimeo.com/989798" assert block.is_vimeo? end - + should "is_vimeo return true when the url contains https://www.vimeo.com" do block = VideoBlock.new block.url = "https://www.vimeo.com/98987" assert block.is_vimeo? end - + should "is_vimeo return true when the url contains www.vimeo.com" do block = VideoBlock.new block.url = "www.vimeo.com/989798" @@ -144,7 +144,7 @@ class VideoBlockTest < ActiveSupport::TestCase block.url = "vimeo.com/09898" assert_match /\/\/player.vimeo.com\/video\/[[:digit:]]+/, block.format_embed_video_url_for_vimeo end - + should "format embed video return nil if is not a vimeo url" do block = VideoBlock.new block.url = "http://www.yt.com/?v=XXXXX" @@ -157,13 +157,13 @@ class VideoBlockTest < ActiveSupport::TestCase block.url = "vimeo.com/#{id}" assert_equal id, block.send('extract_vimeo_id') end - + should "extract_vimeo_id return nil if the url it's not a valid vimeo url" do block = VideoBlock.new block.url = "http://www.yt.com/XXXXX" assert_nil block.send('extract_vimeo_id') end - + should "extract_vimeo_id return nil if vimeo url there is no id" do block = VideoBlock.new block.url = "vimeo.com/" diff --git a/plugins/video/views/video_block.rhtml b/plugins/video/views/video_block.rhtml index c0c7bbf..0bfbf68 100644 --- a/plugins/video/views/video_block.rhtml +++ b/plugins/video/views/video_block.rhtml @@ -15,7 +15,7 @@ <%= render :partial => 'box_organizer/html5_video_block', :locals => { :url => block.url, :width => block.width, :height => block.height }%> <% else %> - <%= _("Register a new url (Vimeo, Youtube, Other)") %> + <%= _("Register a valid url (Vimeo, Youtube, video files)") %> <% end %> -- libgit2 0.21.2