Commit 390bcf53128697491686b2a5a1de4382dced156c
1 parent
4955f96e
Exists in
new_video_plugin
Adds Video gallery and other video stuff (like video article and video gallery block)
Showing
33 changed files
with
1369 additions
and
0 deletions
Show diff stats
@@ -0,0 +1,58 @@ | @@ -0,0 +1,58 @@ | ||
1 | +README - Video (Video Plugin) | ||
2 | +================================ | ||
3 | + | ||
4 | +Video is a plugin that allow users to add a block where you can choose | ||
5 | +any url from youtube, vimeo and url's of the following file formats: | ||
6 | +mp4, ogg, ogv and webm. | ||
7 | + | ||
8 | +The Video block will be available for all layout columns of communities, | ||
9 | +people, enterprises and environments. | ||
10 | + | ||
11 | +INSTALL | ||
12 | +======= | ||
13 | + | ||
14 | +Enable Plugin | ||
15 | +------------- | ||
16 | + | ||
17 | +Also, you need to enable Video Plugin on your Noosfero: | ||
18 | + | ||
19 | +cd <your_noosfero_dir> | ||
20 | +./script/noosfero-plugins enable video | ||
21 | + | ||
22 | +Active Plugin | ||
23 | +------------- | ||
24 | + | ||
25 | +As a Noosfero administrator user, go to administrator panel: | ||
26 | + | ||
27 | +- Click on "Enable/disable plugins" option | ||
28 | +- Click on "Display Content Plugin" check-box | ||
29 | + | ||
30 | +Running Video tests | ||
31 | +-------------------- | ||
32 | + | ||
33 | +$ rake test:noosfero_plugins:video | ||
34 | + | ||
35 | + | ||
36 | +Get Involved | ||
37 | +============ | ||
38 | + | ||
39 | +If you find any bug and/or want to collaborate, please send an e-mail to leandronunes@gmail.com | ||
40 | + | ||
41 | +LICENSE | ||
42 | +======= | ||
43 | + | ||
44 | +Copyright (c) The Author developers. | ||
45 | + | ||
46 | +See Noosfero license. | ||
47 | + | ||
48 | + | ||
49 | +AUTHORS | ||
50 | +======= | ||
51 | + | ||
52 | + Leandro Nunes dos Santos (leandronunes at gmail.com) (Video Block) | ||
53 | + Evandro Magalhães Leite Júnior (evandrojr at gmail.com) (Video Gallery & Video Content) | ||
54 | + | ||
55 | +ACKNOWLEDGMENTS | ||
56 | +=============== | ||
57 | + | ||
58 | +The authors have been supported by Serpro |
@@ -0,0 +1,31 @@ | @@ -0,0 +1,31 @@ | ||
1 | +require_dependency 'article' | ||
2 | + | ||
3 | +class Article | ||
4 | + | ||
5 | + scope :video_gallery, :conditions => ["articles.type = 'VideoPlugin::VideoGallery'"] | ||
6 | + | ||
7 | + #FIXME This should be done via hotspot | ||
8 | + def self.folder_types_with_video | ||
9 | + self.folder_types_without_video << 'VideoPlugin::VideoGallery' | ||
10 | + end | ||
11 | + | ||
12 | + #FIXME This should be done via hotspot | ||
13 | + class << self | ||
14 | + alias_method_chain :folder_types, :video | ||
15 | + end | ||
16 | + | ||
17 | + def self.owner_video_galleries(owner) | ||
18 | + conditions = owner.kind_of?(Environment) ? [] : ["profile_id = ?", owner.id] | ||
19 | + result = Article.video_gallery.find( | ||
20 | + :all, | ||
21 | + :order => 'created_at desc', | ||
22 | + :conditions => conditions) | ||
23 | + end | ||
24 | + | ||
25 | +end | ||
26 | + | ||
27 | + | ||
28 | + | ||
29 | + | ||
30 | + | ||
31 | + |
@@ -0,0 +1,42 @@ | @@ -0,0 +1,42 @@ | ||
1 | +class VideoPlugin < Noosfero::Plugin | ||
2 | + | ||
3 | + def self.plugin_name | ||
4 | + "Video Content type, Video Block and Video Gallery Plugin" | ||
5 | + end | ||
6 | + | ||
7 | + def self.plugin_description | ||
8 | + _("A plugin that adds a block where you can add videos from youtube, vimeo and html5.") | ||
9 | + end | ||
10 | + | ||
11 | + def self.extra_blocks | ||
12 | + { VideoPlugin::VideoBlock => {}, VideoPlugin::VideoGalleryBlock => {:position=>['1']} } | ||
13 | + end | ||
14 | + | ||
15 | + def stylesheet? | ||
16 | + true | ||
17 | + end | ||
18 | + | ||
19 | + def content_types | ||
20 | + [VideoPlugin::VideoGallery, VideoPlugin::Video] | ||
21 | + end | ||
22 | + | ||
23 | + def content_remove_new(content) | ||
24 | + if content.kind_of?(VideoPlugin::VideoGallery) or content.kind_of?(VideoPlugin::Video) | ||
25 | + true | ||
26 | + end | ||
27 | + end | ||
28 | + | ||
29 | + def content_remove_upload(content) | ||
30 | + if content.kind_of?(VideoPlugin::VideoGallery) or content.kind_of?(VideoPlugin::Video) | ||
31 | + true | ||
32 | + end | ||
33 | + end | ||
34 | + | ||
35 | + def article_extra_toolbar_buttons(content) | ||
36 | + if content.kind_of?(VideoPlugin::VideoGallery) | ||
37 | + url = url_for(:action => 'new', :type=>'VideoPlugin::Video', :controller=>'cms', :parent_id => content.id) | ||
38 | + {:title => _('New Video'), :url => url, :icon => 'button with-text icon-new'} | ||
39 | + end | ||
40 | + end | ||
41 | + | ||
42 | +end |
@@ -0,0 +1,180 @@ | @@ -0,0 +1,180 @@ | ||
1 | +require 'noosfero/translatable_content' | ||
2 | +require 'application_helper' | ||
3 | +require 'net/http' | ||
4 | + | ||
5 | +class VideoPlugin::Video < Article | ||
6 | + | ||
7 | + settings_items :video_url, :type => :string, :default => 'http://' | ||
8 | + settings_items :video_width, :type => :integer, :default => 499 | ||
9 | + settings_items :video_height, :type => :integer, :default => 353 | ||
10 | + #Video Providers are: youtube, vimeo, file | ||
11 | + settings_items :video_provider, :type => :string | ||
12 | + settings_items :video_format, :type => :string | ||
13 | + settings_items :video_id, :type => :string | ||
14 | + settings_items :video_thumbnail_url, :type => :string, :default => '/plugins/video/images/video_generic_thumbnail.jpg' | ||
15 | + settings_items :video_thumbnail_width, :type=> :integer | ||
16 | + settings_items :video_thumbnail_height, :type=> :integer | ||
17 | + settings_items :video_duration, :type=> :integer, :default => 0 | ||
18 | + | ||
19 | + attr_accessible :video_url | ||
20 | + | ||
21 | + before_save :fill_video_properties | ||
22 | + | ||
23 | + def self.type_name | ||
24 | + _('Video') | ||
25 | + end | ||
26 | + | ||
27 | + def can_display_versions? | ||
28 | + true | ||
29 | + end | ||
30 | + | ||
31 | + def self.short_description | ||
32 | + _('Embedded Video') | ||
33 | + end | ||
34 | + | ||
35 | + def self.description | ||
36 | + _('Display embedded videos.') | ||
37 | + end | ||
38 | + | ||
39 | + def is_youtube? | ||
40 | + VideoPlugin::Video.is_youtube?(self.video_url) | ||
41 | + end | ||
42 | + | ||
43 | + def is_vimeo? | ||
44 | + VideoPlugin::Video.is_vimeo?(self.video_url) | ||
45 | + end | ||
46 | + | ||
47 | + include ActionView::Helpers::TagHelper | ||
48 | + def to_html(options={}) | ||
49 | + article = self | ||
50 | + proc do | ||
51 | + render :partial => 'content_viewer/video_plugin/video', :locals => {:article => article} | ||
52 | + end | ||
53 | + end | ||
54 | + | ||
55 | + def fitted_width | ||
56 | + 499 | ||
57 | + end | ||
58 | + | ||
59 | + def fitted_height | ||
60 | + ((fitted_width * self.video_height) / self.video_width).to_i | ||
61 | + end | ||
62 | + | ||
63 | + def thumbnail_fitted_width | ||
64 | + 80 | ||
65 | + end | ||
66 | + | ||
67 | + def thumbnail_fitted_height | ||
68 | + ((thumbnail_fitted_width * self.video_thumbnail_height) / self.video_thumbnail_width).to_i | ||
69 | + end | ||
70 | + | ||
71 | + def no_browser_support_message | ||
72 | + '<p class="vjs-no-js">To view this video please enable JavaScript, and consider upgrading to a web browser that <a href="http://videojs.com/html5-video-support/" target="_blank">supports HTML5 video</a></p>' | ||
73 | + end | ||
74 | + | ||
75 | + def self.is_youtube?(video_url) | ||
76 | + video_url.match(/.*(youtube.com.*v=[#{YOUTUBE_ID_FORMAT}]+|youtu.be\/[#{YOUTUBE_ID_FORMAT}]+).*/) ? true : false | ||
77 | + end | ||
78 | + | ||
79 | + def self.is_vimeo?(video_url) | ||
80 | + video_url.match(/^(http[s]?:\/\/)?(www.)?(vimeo.com|player.vimeo.com\/video)\/([A-z]|\/)*[[:digit:]]+/) ? true : false | ||
81 | + end | ||
82 | + | ||
83 | + def self.is_video_file?(video_url) | ||
84 | + video_url.match(/\.(mp4|ogg|ogv|webm)/) ? true : false | ||
85 | + end | ||
86 | + | ||
87 | + def self.format_embed_video_url_for_youtube(video_url) | ||
88 | + "//www.youtube-nocookie.com/embed/#{extract_youtube_id(video_url)}?rel=0&wmode=transparent" if is_youtube?(video_url) | ||
89 | + end | ||
90 | + | ||
91 | + def self.format_embed_video_url_for_vimeo(video_url) | ||
92 | + "//player.vimeo.com/video/#{extract_vimeo_id(video_url)}" if is_vimeo?(video_url) | ||
93 | + end | ||
94 | + | ||
95 | + def format_embed_video_url_for_youtube | ||
96 | + VideoPlugin::Video.format_embed_video_url_for_youtube(self.video_url) | ||
97 | + end | ||
98 | + | ||
99 | + def format_embed_video_url_for_vimeo | ||
100 | + VideoPlugin::Video.format_embed_video_url_for_vimeo(self.video_url) | ||
101 | + end | ||
102 | + | ||
103 | + def self.extract_youtube_id(video_url) | ||
104 | + return nil unless self.is_youtube?(video_url) | ||
105 | + youtube_match = video_url.match("v=([#{YOUTUBE_ID_FORMAT}]*)") | ||
106 | + youtube_match ||= video_url.match("youtu.be\/([#{YOUTUBE_ID_FORMAT}]*)") | ||
107 | + youtube_match[1] unless youtube_match.nil? | ||
108 | + end | ||
109 | + | ||
110 | + def self.extract_vimeo_id(video_url) | ||
111 | + return nil unless self.is_vimeo?(video_url) | ||
112 | + vimeo_match = video_url.match('([[:digit:]]*)$') | ||
113 | + vimeo_match[1] unless vimeo_match.nil? | ||
114 | + end | ||
115 | + | ||
116 | + private | ||
117 | + | ||
118 | + YOUTUBE_ID_FORMAT = '\w-' | ||
119 | + | ||
120 | + def fill_video_properties | ||
121 | + if is_youtube? | ||
122 | + fill_youtube_video_properties | ||
123 | + elsif is_vimeo? | ||
124 | + fill_vimeo_video_properties | ||
125 | + elsif true | ||
126 | + self.video_format = detect_file_format | ||
127 | + self.video_provider = 'file' | ||
128 | + end | ||
129 | + end | ||
130 | + | ||
131 | + def fill_youtube_video_properties | ||
132 | + self.video_provider = 'youtube' | ||
133 | + self.video_id = extract_youtube_id | ||
134 | + url = "http://www.youtube.com/oembed?url=http%3A//www.youtube.com/watch?v%3D#{self.video_id}&format=json" | ||
135 | + resp = Net::HTTP.get_response(URI.parse(url)) | ||
136 | + buffer = resp.body | ||
137 | + vid = JSON.parse(buffer) | ||
138 | + self.video_thumbnail_url = vid['thumbnail_url'] | ||
139 | + self.video_width = vid['width'] | ||
140 | + self.video_height = vid['height'] | ||
141 | + self.video_thumbnail_width = vid['thumbnail_width'] | ||
142 | + self.video_thumbnail_height = vid['thumbnail_height'] | ||
143 | + end | ||
144 | + | ||
145 | + def fill_vimeo_video_properties | ||
146 | + self.video_provider = 'vimeo' | ||
147 | + self.video_id = extract_vimeo_id | ||
148 | + url = "http://vimeo.com/api/v2/video/#{self.video_id}.json" | ||
149 | + resp = Net::HTTP.get_response(URI.parse(url)) | ||
150 | + buffer = resp.body | ||
151 | + vid = JSON.parse(buffer) | ||
152 | + vid = vid[0] | ||
153 | + self.video_thumbnail_url = vid['thumbnail_large'] | ||
154 | + self.video_width = vid['width'] | ||
155 | + self.video_height = vid['height'] | ||
156 | + self.video_thumbnail_width = 640 | ||
157 | + self.video_thumbnail_height = 360 | ||
158 | + end | ||
159 | + | ||
160 | + def detect_file_format | ||
161 | + video_type = 'video/unknown' | ||
162 | + if /.mp4/i =~ self.video_url or /.mov/i =~ self.video_url | ||
163 | + video_type='video/mp4' | ||
164 | + elsif /.webm/i =~ self.video_url | ||
165 | + video_type='video/webm' | ||
166 | + elsif /.og[vg]/i =~ self.video_url | ||
167 | + video_type='video/ogg' | ||
168 | + end | ||
169 | + video_type | ||
170 | + end | ||
171 | + | ||
172 | + def extract_youtube_id | ||
173 | + VideoPlugin::Video.extract_youtube_id(self.video_url) | ||
174 | + end | ||
175 | + | ||
176 | + def extract_vimeo_id | ||
177 | + VideoPlugin::Video.extract_vimeo_id(self.video_url) | ||
178 | + end | ||
179 | + | ||
180 | +end |
@@ -0,0 +1,57 @@ | @@ -0,0 +1,57 @@ | ||
1 | +class VideoPlugin::VideoBlock < Block | ||
2 | + | ||
3 | + attr_accessible :url, :width, :height | ||
4 | + | ||
5 | + settings_items :url, :type => :string, :default => "" | ||
6 | + settings_items :width, :type => :integer, :default => 400 | ||
7 | + settings_items :height, :type => :integer, :default => 315 | ||
8 | + | ||
9 | + YOUTUBE_ID_FORMAT = '\w-' | ||
10 | + | ||
11 | + def is_youtube? | ||
12 | + VideoPlugin::Video.is_youtube?(url) | ||
13 | + end | ||
14 | + | ||
15 | + def is_vimeo? | ||
16 | + VideoPlugin::Video.is_vimeo?(url) | ||
17 | + end | ||
18 | + | ||
19 | + def is_video_file? | ||
20 | + url.match(/.*(mp4|ogg|ogv|webm)$/) ? true : false | ||
21 | + end | ||
22 | + | ||
23 | + def format_embed_video_url_for_youtube | ||
24 | + VideoPlugin::Video.format_embed_video_url_for_youtube(url) | ||
25 | + end | ||
26 | + | ||
27 | + def format_embed_video_url_for_vimeo | ||
28 | + VideoPlugin::Video.format_embed_video_url_for_vimeo(url) | ||
29 | + end | ||
30 | + | ||
31 | + def self.description | ||
32 | + _('Display a Video') | ||
33 | + end | ||
34 | + | ||
35 | + def help | ||
36 | + _('This block presents a video from youtube, vimeo and some video formats (mp4, ogg, ogv and webm)') | ||
37 | + end | ||
38 | + | ||
39 | + def content(args={}) | ||
40 | + block = self | ||
41 | + | ||
42 | + proc do | ||
43 | + render :file => 'video_block', :locals => { :block => block } | ||
44 | + end | ||
45 | + end | ||
46 | + | ||
47 | + private | ||
48 | + | ||
49 | + def extract_youtube_id | ||
50 | + VideoPlugin::Video.extract_youtube_id(url) | ||
51 | + end | ||
52 | + | ||
53 | + def extract_vimeo_id | ||
54 | + VideoPlugin::Video.extract_vimeo_id(url) | ||
55 | + end | ||
56 | + | ||
57 | +end |
@@ -0,0 +1,63 @@ | @@ -0,0 +1,63 @@ | ||
1 | +class VideoPlugin::VideoGallery < Folder | ||
2 | + | ||
3 | + def self.type_name | ||
4 | + _('Video Gallery') | ||
5 | + end | ||
6 | + | ||
7 | + settings_items :thumbnail_width, :type => :integer, :default => 50 | ||
8 | + settings_items :thumbnail_height, :type => :integer, :default => 50 | ||
9 | + settings_items :videos_per_row, :type => :integer, :default => 5 | ||
10 | + | ||
11 | + validate :not_belong_to_blog | ||
12 | + | ||
13 | + def not_belong_to_blog | ||
14 | + errors.add(:parent, "A video gallery should not belong to a blog.") if parent && parent.blog? | ||
15 | + end | ||
16 | + | ||
17 | + acts_as_having_settings :field => :setting | ||
18 | + | ||
19 | + xss_terminate :only => [ :body ], :with => 'white_list', :on => 'validation' | ||
20 | + | ||
21 | + include WhiteListFilter | ||
22 | + filter_iframes :body | ||
23 | + def iframe_whitelist | ||
24 | + profile && profile.environment && profile.environment.trusted_sites_for_iframe | ||
25 | + end | ||
26 | + | ||
27 | + def self.short_description | ||
28 | + _('Video Gallery') | ||
29 | + end | ||
30 | + | ||
31 | + def self.description | ||
32 | + _('A gallery of link to videos that are hosted elsewhere.') | ||
33 | + end | ||
34 | + | ||
35 | + include ActionView::Helpers::TagHelper | ||
36 | + def to_html(options = {}) | ||
37 | + video_gallery = self | ||
38 | + proc do | ||
39 | + render :partial => 'content_viewer/video_plugin/video_gallery', :locals => {:video_gallery => video_gallery} | ||
40 | + end | ||
41 | + end | ||
42 | + | ||
43 | + def video_gallery? | ||
44 | + true | ||
45 | + end | ||
46 | + | ||
47 | + def can_display_hits? | ||
48 | + false | ||
49 | + end | ||
50 | + | ||
51 | + def accept_comments? | ||
52 | + false | ||
53 | + end | ||
54 | + | ||
55 | + def self.icon_name(article = nil) | ||
56 | + 'Video gallery' | ||
57 | + end | ||
58 | + | ||
59 | + def news(limit = 30, highlight = false) | ||
60 | + profile.recent_documents(limit, ["articles.type != ? AND articles.highlighted = ? AND articles.parent_id = ?", 'Folder', highlight, id]) | ||
61 | + end | ||
62 | + | ||
63 | +end |
@@ -0,0 +1,31 @@ | @@ -0,0 +1,31 @@ | ||
1 | +class VideoPlugin::VideoGalleryBlock < Block | ||
2 | + | ||
3 | + settings_items :video_gallery_id, :type => :integer | ||
4 | + attr_accessible :video_gallery_id | ||
5 | + | ||
6 | + include ActionView::Helpers | ||
7 | + include Rails.application.routes.url_helpers | ||
8 | + | ||
9 | + def self.description | ||
10 | + _('Display a Video Gallery') | ||
11 | + end | ||
12 | + | ||
13 | + def help | ||
14 | + _('This block presents a video gallery') | ||
15 | + end | ||
16 | + | ||
17 | + def content(args={}) | ||
18 | + block = self | ||
19 | + if video_gallery_id.present? | ||
20 | + video_gallery = VideoPlugin::VideoGallery.find(video_gallery_id) | ||
21 | + proc do | ||
22 | + render :partial => 'content_viewer/video_plugin/video_gallery', :locals => {:video_gallery => video_gallery} | ||
23 | + end | ||
24 | + end | ||
25 | + end | ||
26 | + | ||
27 | + def list_my_galleries | ||
28 | + Article.owner_video_galleries(owner) | ||
29 | + end | ||
30 | + | ||
31 | +end |
@@ -0,0 +1,18 @@ | @@ -0,0 +1,18 @@ | ||
1 | +module VideoPlugin::VideoGalleryHelper | ||
2 | + | ||
3 | + def list_videos(configure={}) | ||
4 | + configure[:recursive] ||= false | ||
5 | + configure[:list_type] ||= :folder | ||
6 | + if !configure[:contents].blank? | ||
7 | + configure[:contents] = configure[:contents].paginate( | ||
8 | + :order => "updated_at DESC", | ||
9 | + :per_page => 17, | ||
10 | + :page => params[:npage] | ||
11 | + ) | ||
12 | + render :file => 'shared/video_list', :locals => configure | ||
13 | + else | ||
14 | + content_tag('em', _('(empty folder)')) | ||
15 | + end | ||
16 | + end | ||
17 | + | ||
18 | +end |
@@ -0,0 +1,49 @@ | @@ -0,0 +1,49 @@ | ||
1 | +# translation of noosfero.po to | ||
2 | +# Krishnamurti Lelis Lima Vieira Nunes <krishna@colivre.coop.br>, 2007. | ||
3 | +# noosfero - Brazilian Portuguese translation | ||
4 | +# Copyright (C) 2007, | ||
5 | +# Forum Brasileiro de Economia Solidaria <http://www.fbes.org.br/> | ||
6 | +# Copyright (C) 2007, | ||
7 | +# Ynternet.org Foundation <http://www.ynternet.org/> | ||
8 | +# This file is distributed under the same license as noosfero itself. | ||
9 | +# Joenio Costa <joenio@colivre.coop.br>, 2008. | ||
10 | +# | ||
11 | +# | ||
12 | +msgid "" | ||
13 | +msgstr "" | ||
14 | +"Project-Id-Version: 1.3~rc2-1-ga15645d\n" | ||
15 | +"POT-Creation-Date: 2015-10-30 16:35-0300\n" | ||
16 | +"PO-Revision-Date: 2014-12-18 18:40-0200\n" | ||
17 | +"Last-Translator: Luciano Prestes Cavalcanti <lucianopcbr@gmail.com>\n" | ||
18 | +"Language-Team: Portuguese <https://hosted.weblate.org/projects/noosfero/" | ||
19 | +"noosfero/pt/>\n" | ||
20 | +"Language: pt\n" | ||
21 | +"MIME-Version: 1.0\n" | ||
22 | +"Content-Type: text/plain; charset=UTF-8\n" | ||
23 | +"Content-Transfer-Encoding: 8bit\n" | ||
24 | +"Plural-Forms: nplurals=2; plural=n != 1;\n" | ||
25 | +"X-Generator: Weblate 2.0\n" | ||
26 | + | ||
27 | +#: plugins/video/lib/video_block.rb:32 | ||
28 | +msgid "Display a Video" | ||
29 | +msgstr "Mostrar um Vídeo" | ||
30 | + | ||
31 | +#: plugins/video/lib/video_block.rb:36 | ||
32 | +msgid "" | ||
33 | +"This block presents a video from youtube, vimeo and some video formats (mp4, " | ||
34 | +"ogg, ogv and webm)" | ||
35 | +msgstr "" | ||
36 | +"Esse bloco apresenta um vídeo do youtube, vimeo e alguns formatos de video " | ||
37 | +"(mp4, ogg, ogv e webm)" | ||
38 | + | ||
39 | +#: plugins/video/lib/video_plugin.rb:10 | ||
40 | +msgid "" | ||
41 | +"A plugin that adds a block where you can add videos from youtube, vimeo and " | ||
42 | +"html5." | ||
43 | +msgstr "" | ||
44 | +"Um plugin que adiciona um bloco onde você pode adicionar vídeos do youtube, " | ||
45 | +"vimeo e html5." | ||
46 | + | ||
47 | +#: plugins/video/views/video_block.html.erb:18 | ||
48 | +msgid "Register a valid url (Vimeo, Youtube, video files)" | ||
49 | +msgstr "Registre uma url válida (Vimeo, Youtube, arquivo de vídeo)" |
@@ -0,0 +1,38 @@ | @@ -0,0 +1,38 @@ | ||
1 | +# SOME DESCRIPTIVE TITLE. | ||
2 | +# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER | ||
3 | +# This file is distributed under the same license as the PACKAGE package. | ||
4 | +# FIRST AUTHOR <EMAIL@ADDRESS>, YEAR. | ||
5 | +# | ||
6 | +#, fuzzy | ||
7 | +msgid "" | ||
8 | +msgstr "" | ||
9 | +"Project-Id-Version: 1.3~rc2-1-ga15645d\n" | ||
10 | +"POT-Creation-Date: 2015-10-30 16:35-0300\n" | ||
11 | +"PO-Revision-Date: 2015-08-06 17:21-0300\n" | ||
12 | +"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n" | ||
13 | +"Language-Team: LANGUAGE <LL@li.org>\n" | ||
14 | +"Language: \n" | ||
15 | +"MIME-Version: 1.0\n" | ||
16 | +"Content-Type: text/plain; charset=UTF-8\n" | ||
17 | +"Content-Transfer-Encoding: 8bit\n" | ||
18 | +"Plural-Forms: nplurals=INTEGER; plural=EXPRESSION;\n" | ||
19 | + | ||
20 | +#: plugins/video/lib/video_block.rb:32 | ||
21 | +msgid "Display a Video" | ||
22 | +msgstr "" | ||
23 | + | ||
24 | +#: plugins/video/lib/video_block.rb:36 | ||
25 | +msgid "" | ||
26 | +"This block presents a video from youtube, vimeo and some video formats (mp4, " | ||
27 | +"ogg, ogv and webm)" | ||
28 | +msgstr "" | ||
29 | + | ||
30 | +#: plugins/video/lib/video_plugin.rb:10 | ||
31 | +msgid "" | ||
32 | +"A plugin that adds a block where you can add videos from youtube, vimeo and " | ||
33 | +"html5." | ||
34 | +msgstr "" | ||
35 | + | ||
36 | +#: plugins/video/views/video_block.html.erb:18 | ||
37 | +msgid "Register a valid url (Vimeo, Youtube, video files)" | ||
38 | +msgstr "" |
4.49 KB
@@ -0,0 +1,66 @@ | @@ -0,0 +1,66 @@ | ||
1 | +.video-gallery-thumbnail { | ||
2 | + position: relative; | ||
3 | + display: inline-block; | ||
4 | + width: 95px; | ||
5 | + height: 115px; | ||
6 | + margin: 1em; | ||
7 | + border: solid #F0F0F0 1px; | ||
8 | + vertical-align: top; | ||
9 | + text-align: left; | ||
10 | + overflow: hidden; | ||
11 | + padding-top: 7px; | ||
12 | + margin-botton: 10px; | ||
13 | + text-overflow: ellipsis; | ||
14 | +} | ||
15 | + | ||
16 | +.video-gallery-top-box{ | ||
17 | + height: 73px; | ||
18 | +} | ||
19 | + | ||
20 | +.video-duration{ | ||
21 | + position: absolute; | ||
22 | + bottom: 0px; | ||
23 | + background-color: black; | ||
24 | + font-size: 1em; | ||
25 | + text-color: white; | ||
26 | +} | ||
27 | + | ||
28 | +.video-title{ | ||
29 | + width: 100%; | ||
30 | + overflow: hidden; | ||
31 | + text-overflow: ellipsis; | ||
32 | +} | ||
33 | + | ||
34 | +.video-author{ | ||
35 | + display: none; | ||
36 | + overflow: hidden; | ||
37 | + text-overflow: ellipsis; | ||
38 | +} | ||
39 | + | ||
40 | +.video-gallery-thumbnail:hover div{ | ||
41 | + display: inline-block; | ||
42 | +} | ||
43 | + | ||
44 | +.video-gallery-table-big{ | ||
45 | + width: 100%; | ||
46 | + overflow: hidden; | ||
47 | +} | ||
48 | + | ||
49 | +.video-gallery-left-column-big{ | ||
50 | + width: 350px; | ||
51 | + float: left; | ||
52 | +} | ||
53 | + | ||
54 | +.video-gallery-right-column-big{ | ||
55 | + margin-left: 370px; | ||
56 | +} | ||
57 | + | ||
58 | +.video-title-big{ | ||
59 | + font-size: 2em; | ||
60 | +} | ||
61 | + | ||
62 | +.video-block-center{ | ||
63 | + width: 100%; | ||
64 | + margin-left: auto; | ||
65 | + margin-right: auto; | ||
66 | +} | ||
0 | \ No newline at end of file | 67 | \ No newline at end of file |
plugins/video/test/functional/video_plugin_environment_design_controller_test.rb
0 → 100644
@@ -0,0 +1,127 @@ | @@ -0,0 +1,127 @@ | ||
1 | +require_relative '../test_helper' | ||
2 | + | ||
3 | +class EnvironmentDesignControllerTest < ActionController::TestCase | ||
4 | + | ||
5 | + def setup | ||
6 | + @controller = EnvironmentDesignController.new | ||
7 | + @request = ActionController::TestRequest.new | ||
8 | + @response = ActionController::TestResponse.new | ||
9 | + | ||
10 | + Environment.delete_all | ||
11 | + User.delete_all | ||
12 | + @environment = Environment.create!(defaults_for_environment.merge(:is_default => true)) | ||
13 | + user = create_user('testinguser') | ||
14 | + login_as(user.person.identifier) | ||
15 | + @environment.add_admin(user.person) | ||
16 | + @environment.save! | ||
17 | + | ||
18 | + @environment.enabled_plugins = ['VideoPlugin'] | ||
19 | + @environment.save! | ||
20 | + | ||
21 | + VideoPlugin::VideoBlock.delete_all | ||
22 | + | ||
23 | + @block = VideoPlugin::VideoBlock.new | ||
24 | + @block.box = @environment.boxes.first | ||
25 | + @block.save! | ||
26 | + end | ||
27 | + | ||
28 | + attr_accessor :environment, :block | ||
29 | + | ||
30 | + should 'display video-block-data class in profile block edition' do | ||
31 | + block.url='youtube.com/?v=XXXXX' | ||
32 | + block.save! | ||
33 | + get :index | ||
34 | + | ||
35 | + assert_tag :div, :attributes => {:class => 'video-block-data'} | ||
36 | + end | ||
37 | + | ||
38 | + should "display iframe tag in profile block edition on youtube url's" do | ||
39 | + block.url='youtube.com/?v=XXXXX' | ||
40 | + block.save | ||
41 | + get :index | ||
42 | + | ||
43 | + assert_tag :tag => 'iframe' | ||
44 | + end | ||
45 | + | ||
46 | + should "the width in iframe tag be defined on youtube url's" do | ||
47 | + block.url='youtube.com/?v=XXXXX' | ||
48 | + block.save | ||
49 | + get :index | ||
50 | + | ||
51 | + assert_tag :tag => 'iframe', :attributes => {:width => '400px'} | ||
52 | + end | ||
53 | + | ||
54 | + should "display iframe tag in profile block edition on vimeo url's" do | ||
55 | + block.url='http://vimeo.com/98979' | ||
56 | + block.save | ||
57 | + get :index | ||
58 | + | ||
59 | + assert_tag :tag => 'iframe' | ||
60 | + end | ||
61 | + | ||
62 | + should "the width in iframe tag be defined on vimeo url's" do | ||
63 | + block.url='http://vimeo.com/98979' | ||
64 | + block.save | ||
65 | + get :index | ||
66 | + | ||
67 | + assert_tag :tag => 'iframe', :attributes => {:width => '400px'} | ||
68 | + end | ||
69 | + | ||
70 | + should "display video tag in profile block edition for any video url" do | ||
71 | + block.url='http://www.vmsd.com/98979.mp4' | ||
72 | + block.save | ||
73 | + get :index | ||
74 | + | ||
75 | + assert_tag :tag => 'video' | ||
76 | + end | ||
77 | + | ||
78 | + should "the width in video tag be defined for any video url" do | ||
79 | + block.url='http://www.vmsd.com/98979.mp4' | ||
80 | + block.save | ||
81 | + get :index | ||
82 | + | ||
83 | + assert_tag :tag => 'video', :attributes => {:width => '400px'} | ||
84 | + end | ||
85 | + | ||
86 | + should 'the heigth in iframe tag be defined' do | ||
87 | + block.url='youtube.com/?v=XXXXX' | ||
88 | + block.save | ||
89 | + get :index | ||
90 | + | ||
91 | + assert_tag :tag => 'iframe', :attributes => {:height => '315px'} | ||
92 | + end | ||
93 | + | ||
94 | + should 'display youtube videos' do | ||
95 | + block.url='youtube.com/?v=XXXXX' | ||
96 | + block.save | ||
97 | + get :index | ||
98 | + | ||
99 | + assert_tag :tag => 'div', :attributes => {:class => 'video-block-data'}, :descendant => { :tag => 'div', :attributes => {:class => 'youtube'} } | ||
100 | + end | ||
101 | + | ||
102 | + should 'display vimeo videos' do | ||
103 | + block.url='http://vimeo.com/98979' | ||
104 | + block.save | ||
105 | + get :index | ||
106 | + | ||
107 | + assert_tag :tag => 'div', :attributes => {:class => 'video-block-data'}, :descendant => { :tag => 'div', :attributes => {:class => 'vimeo'} } | ||
108 | + end | ||
109 | + | ||
110 | + should 'display other videos' do | ||
111 | + block.url='http://www.vmsd.com/98979.mp4' | ||
112 | + block.save | ||
113 | + get :index | ||
114 | + | ||
115 | + assert_tag :tag => 'div', :attributes => {:class => 'video-block-data'}, :descendant => { :tag => 'div', :attributes => {:class => 'video'} } | ||
116 | + end | ||
117 | + | ||
118 | + should 'display a message to register a new url' do | ||
119 | + block.url='http://www.vmsd.com/test.pdf' | ||
120 | + block.save | ||
121 | + get :index | ||
122 | + | ||
123 | + assert_tag :tag => 'div', :attributes => {:class => 'video-block-data'}, :descendant => { :tag => 'span', :attributes => {:class => 'alert-block'} } | ||
124 | + end | ||
125 | + | ||
126 | + | ||
127 | +end |
plugins/video/test/functional/video_plugin_profile_design_controller_test.rb
0 → 100644
@@ -0,0 +1,129 @@ | @@ -0,0 +1,129 @@ | ||
1 | +require_relative '../test_helper' | ||
2 | + | ||
3 | +class ProfileDesignControllerTest < ActionController::TestCase | ||
4 | + | ||
5 | + def setup | ||
6 | + @controller = ProfileDesignController.new | ||
7 | + @request = ActionController::TestRequest.new | ||
8 | + @response = ActionController::TestResponse.new | ||
9 | + | ||
10 | + user = create_user('testinguser') | ||
11 | + login_as(user.login) | ||
12 | + @profile = user.person | ||
13 | + @environment = @profile.environment | ||
14 | + | ||
15 | + @environment.enabled_plugins = ['VideoPlugin'] | ||
16 | + @environment.save! | ||
17 | + | ||
18 | + VideoPlugin::VideoBlock.delete_all | ||
19 | + @box1 = Box.create!(:owner => @profile) | ||
20 | + @profile.boxes = [@box1] | ||
21 | + | ||
22 | + @block = VideoPlugin::VideoBlock.new | ||
23 | + @block.box = @box1 | ||
24 | + @block.save! | ||
25 | + | ||
26 | + @profile.blocks<<@block | ||
27 | + @profile.save! | ||
28 | + end | ||
29 | + | ||
30 | + attr_accessor :profile, :block | ||
31 | + | ||
32 | + should 'display video-block-data class in profile block edition' do | ||
33 | + block.url='youtube.com/?v=XXXXX' | ||
34 | + block.save | ||
35 | + get :index, :profile => profile.identifier | ||
36 | + | ||
37 | + assert_tag :div, :attributes => {:class => 'video-block-data'} | ||
38 | + end | ||
39 | + | ||
40 | + should "display iframe tag in profile block edition on youtube url's" do | ||
41 | + block.url='youtube.com/?v=XXXXX' | ||
42 | + block.save | ||
43 | + get :index, :profile => profile.identifier | ||
44 | + | ||
45 | + assert_tag :tag => 'iframe' | ||
46 | + end | ||
47 | + | ||
48 | + should "the width in iframe tag be defined on youtube url's" do | ||
49 | + block.url='youtube.com/?v=XXXXX' | ||
50 | + block.save | ||
51 | + get :index, :profile => profile.identifier | ||
52 | + | ||
53 | + assert_tag :tag => 'iframe', :attributes => {:width => '400px'} | ||
54 | + end | ||
55 | + | ||
56 | + should "display iframe tag in profile block edition on vimeo url's" do | ||
57 | + block.url='http://vimeo.com/98979' | ||
58 | + block.save | ||
59 | + get :index, :profile => profile.identifier | ||
60 | + | ||
61 | + assert_tag :tag => 'iframe' | ||
62 | + end | ||
63 | + | ||
64 | + should "the width in iframe tag be defined on vimeo url's" do | ||
65 | + block.url='http://vimeo.com/98979' | ||
66 | + block.save | ||
67 | + get :index, :profile => profile.identifier | ||
68 | + | ||
69 | + assert_tag :tag => 'iframe', :attributes => {:width => '400px'} | ||
70 | + end | ||
71 | + | ||
72 | + should "display video tag in profile block edition for any video url" do | ||
73 | + block.url='http://www.vmsd.com/98979.mp4' | ||
74 | + block.save | ||
75 | + get :index, :profile => profile.identifier | ||
76 | + | ||
77 | + assert_tag :tag => 'video' | ||
78 | + end | ||
79 | + | ||
80 | + should "the width in video tag be defined for any video url" do | ||
81 | + block.url='http://www.vmsd.com/98979.mp4' | ||
82 | + block.save | ||
83 | + get :index, :profile => profile.identifier | ||
84 | + | ||
85 | + assert_tag :tag => 'video', :attributes => {:width => '400px'} | ||
86 | + end | ||
87 | + | ||
88 | + should 'the heigth in iframe tag be defined' do | ||
89 | + block.url='youtube.com/?v=XXXXX' | ||
90 | + block.save | ||
91 | + get :index, :profile => profile.identifier | ||
92 | + | ||
93 | + assert_tag :tag => 'iframe', :attributes => {:height => '315px'} | ||
94 | + end | ||
95 | + | ||
96 | + should 'display youtube videos' do | ||
97 | + block.url='youtube.com/?v=XXXXX' | ||
98 | + block.save | ||
99 | + get :index, :profile => profile.identifier | ||
100 | + | ||
101 | + assert_tag :tag => 'div', :attributes => {:class => 'video-block-data'}, :descendant => { :tag => 'div', :attributes => {:class => 'youtube'} } | ||
102 | + end | ||
103 | + | ||
104 | + should 'display vimeo videos' do | ||
105 | + block.url='http://vimeo.com/98979' | ||
106 | + block.save | ||
107 | + get :index, :profile => profile.identifier | ||
108 | + | ||
109 | + assert_tag :tag => 'div', :attributes => {:class => 'video-block-data'}, :descendant => { :tag => 'div', :attributes => {:class => 'vimeo'} } | ||
110 | + end | ||
111 | + | ||
112 | + should 'display other videos' do | ||
113 | + block.url='http://www.vmsd.com/98979.mp4' | ||
114 | + block.save | ||
115 | + get :index, :profile => profile.identifier | ||
116 | + | ||
117 | + assert_tag :tag => 'div', :attributes => {:class => 'video-block-data'}, :descendant => { :tag => 'div', :attributes => {:class => 'video'} } | ||
118 | + end | ||
119 | + | ||
120 | + should 'display a messagem to register a new url' do | ||
121 | + block.url='http://www.vmsd.com/test.pdf' | ||
122 | + block.save | ||
123 | + get :index, :profile => profile.identifier | ||
124 | + | ||
125 | + assert_tag :tag => 'div', :attributes => {:class => 'video-block-data'}, :descendant => { :tag => 'span', :attributes => {:class => 'alert-block'} } | ||
126 | + end | ||
127 | + | ||
128 | + | ||
129 | +end |
@@ -0,0 +1 @@ | @@ -0,0 +1 @@ | ||
1 | +require 'test_helper' |
@@ -0,0 +1,219 @@ | @@ -0,0 +1,219 @@ | ||
1 | +require_relative '../test_helper' | ||
2 | +class VideoBlockTest < ActiveSupport::TestCase | ||
3 | + | ||
4 | + ### Tests for YouTube | ||
5 | + | ||
6 | + should "is_youtube return true when the url contains http://youtube.com" do | ||
7 | + block = VideoPlugin::VideoBlock.new | ||
8 | + block.url = "http://youtube.com/?v=XXXXX" | ||
9 | + assert block.is_youtube? | ||
10 | + end | ||
11 | + | ||
12 | + should "is_youtube return true when the url contains https://youtube.com" do | ||
13 | + block = VideoPlugin::VideoBlock.new | ||
14 | + block.url = "https://youtube.com/?v=XXXXX" | ||
15 | + assert block.is_youtube? | ||
16 | + end | ||
17 | + | ||
18 | + should "is_youtube return true when the url contains www.youtube.com" do | ||
19 | + block = VideoPlugin::VideoBlock.new | ||
20 | + block.url = "www.youtube.com/?v=XXXXX" | ||
21 | + assert block.is_youtube? | ||
22 | + end | ||
23 | + | ||
24 | + should "is_youtube return true when the url contains youtube.com" do | ||
25 | + block = VideoPlugin::VideoBlock.new | ||
26 | + block.url = "youtube.com/?v=XXXXX" | ||
27 | + assert block.is_youtube? | ||
28 | + end | ||
29 | + | ||
30 | + should "is_youtube return false when the url not contains youtube video ID" do | ||
31 | + block = VideoPlugin::VideoBlock.new | ||
32 | + block.url = "youtube.com/" | ||
33 | + refute block.is_youtube? | ||
34 | + end | ||
35 | + | ||
36 | + should "is_youtube return false when the url contains empty youtube video ID" do | ||
37 | + block = VideoPlugin::VideoBlock.new | ||
38 | + block.url = "youtube.com/?v=" | ||
39 | + refute block.is_youtube? | ||
40 | + end | ||
41 | + | ||
42 | + should "is_youtube return false when the url contains an invalid youtube link" do | ||
43 | + block = VideoPlugin::VideoBlock.new | ||
44 | + block.url = "http://www.yt.com/?v=XXXXX" | ||
45 | + refute block.is_youtube? | ||
46 | + end | ||
47 | + | ||
48 | + should "format embed video for youtube videos" do | ||
49 | + block = VideoPlugin::VideoBlock.new | ||
50 | + block.url = "youtube.com/?v=XXXXX" | ||
51 | + assert_match /\/\/www.youtube-nocookie.com\/embed/, block.format_embed_video_url_for_youtube | ||
52 | + end | ||
53 | + | ||
54 | + should "format embed video return nil if is not a youtube url" do | ||
55 | + block = VideoPlugin::VideoBlock.new | ||
56 | + block.url = "http://www.yt.com/?v=XXXXX" | ||
57 | + assert_nil block.format_embed_video_url_for_youtube | ||
58 | + end | ||
59 | + | ||
60 | + should "extract youtube id from youtube video url's if it's a valid youtube full url" do | ||
61 | + block = VideoPlugin::VideoBlock.new | ||
62 | + id = 'oi43jre2d2' | ||
63 | + block.url = "youtube.com/?v=#{id}" | ||
64 | + assert_equal id, block.send('extract_youtube_id') | ||
65 | + end | ||
66 | + | ||
67 | + should "extract youtube id from youtube video url's if it has underline and hyphen" do | ||
68 | + block = VideoPlugin::VideoBlock.new | ||
69 | + id = 'oi43_re-d2' | ||
70 | + block.url = "youtube.com/?v=#{id}" | ||
71 | + assert_equal id, block.send('extract_youtube_id') | ||
72 | + end | ||
73 | + | ||
74 | + should "extract youtube id from youtube video url's if it's a valid youtube short url" do | ||
75 | + block = VideoPlugin::VideoBlock.new | ||
76 | + id = 'oi43jre2d2' | ||
77 | + block.url = "youtu.be/#{id}" | ||
78 | + assert_equal id, block.send('extract_youtube_id') | ||
79 | + end | ||
80 | + | ||
81 | + should "extract_youtube_id return nil if the url it's not a valid youtube url" do | ||
82 | + block = VideoPlugin::VideoBlock.new | ||
83 | + block.url = "http://www.yt.com/?v=XXXXX" | ||
84 | + assert_nil block.send('extract_youtube_id') | ||
85 | + end | ||
86 | + | ||
87 | + should "extract_youtube_id return nil if youtue url there is no id" do | ||
88 | + block = VideoPlugin::VideoBlock.new | ||
89 | + block.url = "youtube.com/" | ||
90 | + assert_nil block.send('extract_youtube_id') | ||
91 | + end | ||
92 | + | ||
93 | + #### Tests for Vimeo Videos | ||
94 | + | ||
95 | + should "is_vimeo return true when the url contains http://vimeo.com" do | ||
96 | + block = VideoPlugin::VideoBlock.new | ||
97 | + block.url = "http://vimeo.com/98979" | ||
98 | + assert block.is_vimeo? | ||
99 | + end | ||
100 | + | ||
101 | + should "is_vimeo return true when the url contains https://vimeo.com" do | ||
102 | + block = VideoPlugin::VideoBlock.new | ||
103 | + block.url = "https://vimeo.com/989798" | ||
104 | + assert block.is_vimeo? | ||
105 | + end | ||
106 | + | ||
107 | + should "is_vimeo return true when the url contains https://www.vimeo.com" do | ||
108 | + block = VideoPlugin::VideoBlock.new | ||
109 | + block.url = "https://www.vimeo.com/98987" | ||
110 | + assert block.is_vimeo? | ||
111 | + end | ||
112 | + | ||
113 | + should "is_vimeo return true when the url contains www.vimeo.com" do | ||
114 | + block = VideoPlugin::VideoBlock.new | ||
115 | + block.url = "www.vimeo.com/989798" | ||
116 | + assert block.is_vimeo? | ||
117 | + end | ||
118 | + | ||
119 | + should "is_vimeo return true when the url contains vimeo.com" do | ||
120 | + block = VideoPlugin::VideoBlock.new | ||
121 | + block.url = "vimeo.com/09898" | ||
122 | + assert block.is_vimeo? | ||
123 | + end | ||
124 | + | ||
125 | + should "is_vimeo return false when the url not contains vimeo video ID" do | ||
126 | + block = VideoPlugin::VideoBlock.new | ||
127 | + block.url = "vimeo.com/home" | ||
128 | + refute block.is_vimeo? | ||
129 | + end | ||
130 | + | ||
131 | + should "is_vimeo return false when the url contains empty vimeo video ID" do | ||
132 | + block = VideoPlugin::VideoBlock.new | ||
133 | + block.url = "vimeo.com/" | ||
134 | + refute block.is_vimeo? | ||
135 | + end | ||
136 | + | ||
137 | + should "is_vimeo return false when the url contains an invalid vimeo link" do | ||
138 | + block = VideoPlugin::VideoBlock.new | ||
139 | + block.url = "http://www.vmsd.com/98979" | ||
140 | + refute block.is_vimeo? | ||
141 | + end | ||
142 | + | ||
143 | + should "format embed video for vimeo videos" do | ||
144 | + block = VideoPlugin::VideoBlock.new | ||
145 | + block.url = "vimeo.com/09898" | ||
146 | + assert_match /\/\/player.vimeo.com\/video\/[[:digit:]]+/, block.format_embed_video_url_for_vimeo | ||
147 | + end | ||
148 | + | ||
149 | + should "format embed video return nil if is not a vimeo url" do | ||
150 | + block = VideoPlugin::VideoBlock.new | ||
151 | + block.url = "http://www.yt.com/?v=XXXXX" | ||
152 | + assert_nil block.format_embed_video_url_for_vimeo | ||
153 | + end | ||
154 | + | ||
155 | + should "extract vimeo id from vimeo video url's if it's a valid vimeo url" do | ||
156 | + block = VideoPlugin::VideoBlock.new | ||
157 | + id = '23048239432' | ||
158 | + block.url = "vimeo.com/#{id}" | ||
159 | + assert_equal id, block.send('extract_vimeo_id') | ||
160 | + end | ||
161 | + | ||
162 | + should "extract_vimeo_id return nil if the url it's not a valid vimeo url" do | ||
163 | + block = VideoPlugin::VideoBlock.new | ||
164 | + block.url = "http://www.yt.com/XXXXX" | ||
165 | + assert_nil block.send('extract_vimeo_id') | ||
166 | + end | ||
167 | + | ||
168 | + should "extract_vimeo_id return nil if vimeo url there is no id" do | ||
169 | + block = VideoPlugin::VideoBlock.new | ||
170 | + block.url = "vimeo.com/" | ||
171 | + assert_nil block.send('extract_youtube_id') | ||
172 | + end | ||
173 | + | ||
174 | + # Other video formats | ||
175 | + should "is_video return true if url ends with mp4" do | ||
176 | + block = VideoPlugin::VideoBlock.new | ||
177 | + block.url = "http://www.vmsd.com/98979.mp4" | ||
178 | + assert block.is_video_file? | ||
179 | + end | ||
180 | + | ||
181 | + should "is_video return true if url ends with ogg" do | ||
182 | + block = VideoPlugin::VideoBlock.new | ||
183 | + block.url = "http://www.vmsd.com/98979.ogg" | ||
184 | + assert block.is_video_file? | ||
185 | + end | ||
186 | + | ||
187 | + should "is_video return true if url ends with ogv" do | ||
188 | + block = VideoPlugin::VideoBlock.new | ||
189 | + block.url = "http://www.vmsd.com/98979.ogv" | ||
190 | + assert block.is_video_file? | ||
191 | + end | ||
192 | + | ||
193 | + should "is_video return true if url ends with webm" do | ||
194 | + block = VideoPlugin::VideoBlock.new | ||
195 | + block.url = "http://www.vmsd.com/98979.webm" | ||
196 | + assert block.is_video_file? | ||
197 | + end | ||
198 | + | ||
199 | + should "is_video return false if url ends without mp4, ogg, ogv, webm" do | ||
200 | + block = VideoPlugin::VideoBlock.new | ||
201 | + block.url = "http://www.vmsd.com/98979.mp4r" | ||
202 | + refute block.is_video_file? | ||
203 | + block.url = "http://www.vmsd.com/98979.oggr" | ||
204 | + refute block.is_video_file? | ||
205 | + block.url = "http://www.vmsd.com/98979.ogvr" | ||
206 | + refute block.is_video_file? | ||
207 | + block.url = "http://www.vmsd.com/98979.webmr" | ||
208 | + refute block.is_video_file? | ||
209 | + end | ||
210 | + | ||
211 | + should 'display video block partial' do | ||
212 | + block = VideoPlugin::VideoBlock.new | ||
213 | + self.expects(:render).with(:file => 'video_block', :locals => { | ||
214 | + :block => block | ||
215 | + }) | ||
216 | + instance_eval(& block.content) | ||
217 | + end | ||
218 | + | ||
219 | +end |
@@ -0,0 +1,12 @@ | @@ -0,0 +1,12 @@ | ||
1 | +require File.dirname(__FILE__) + '/../test_helper' | ||
2 | +class VideoGaleryBlockTest < ActiveSupport::TestCase | ||
3 | + | ||
4 | + should "define its description" do | ||
5 | + assert_equal VideoPlugin::VideoGalleryBlock.description, _('Display a Video Gallery') | ||
6 | + end | ||
7 | + | ||
8 | + should "define its help description" do | ||
9 | + assert_equal VideoPlugin::VideoGalleryBlock.new.help, _('This block presents a video gallery') | ||
10 | + end | ||
11 | + | ||
12 | +end |
@@ -0,0 +1,16 @@ | @@ -0,0 +1,16 @@ | ||
1 | +require File.dirname(__FILE__) + '/../test_helper' | ||
2 | +class VideoGaleryTest < ActiveSupport::TestCase | ||
3 | + | ||
4 | + should "define its type_name as Video Gallery" do | ||
5 | + assert_equal VideoPlugin::VideoGallery.type_name, _('Video Gallery') | ||
6 | + end | ||
7 | + | ||
8 | + should "define its short_description" do | ||
9 | + assert_equal VideoPlugin::VideoGallery.short_description, _('Video Gallery') | ||
10 | + end | ||
11 | + | ||
12 | + should "define its description" do | ||
13 | + assert_equal VideoPlugin::VideoGallery.description, _('A gallery of link to videos that are hosted elsewhere.') | ||
14 | + end | ||
15 | + | ||
16 | +end |
@@ -0,0 +1,90 @@ | @@ -0,0 +1,90 @@ | ||
1 | +require File.dirname(__FILE__) + '/../test_helper' | ||
2 | +class VideoTest < ActiveSupport::TestCase | ||
3 | + | ||
4 | + include AuthenticatedTestHelper | ||
5 | + fixtures :users, :environments | ||
6 | + | ||
7 | + def setup | ||
8 | + @video = VideoPlugin::Video.new | ||
9 | + end | ||
10 | + | ||
11 | + should "define its type_name as video" do | ||
12 | + assert_equal VideoPlugin::Video.type_name, _('Video') | ||
13 | + end | ||
14 | + | ||
15 | + should "display version" do | ||
16 | + assert @video.can_display_versions? | ||
17 | + end | ||
18 | + | ||
19 | + should "define its short_description" do | ||
20 | + assert_equal VideoPlugin::Video.short_description, _('Embedded Video') | ||
21 | + end | ||
22 | + | ||
23 | + should "define its description" do | ||
24 | + assert_equal VideoPlugin::Video.description, _('Display embedded videos.') | ||
25 | + end | ||
26 | + | ||
27 | + should "define a fitted_width" do | ||
28 | + assert_equal @video.fitted_width, 499 | ||
29 | + end | ||
30 | + | ||
31 | + should "eval a fitted_height" do | ||
32 | + @video.video_height = 1000 | ||
33 | + @video.video_width = 2000 | ||
34 | + fitted_height = ((@video.fitted_width * @video.video_height) / @video.video_width).to_i | ||
35 | + assert_equal fitted_height, @video.fitted_height | ||
36 | + end | ||
37 | + | ||
38 | + should "define a thumbnail_fitted_width" do | ||
39 | + assert_equal @video.thumbnail_fitted_width, 80 | ||
40 | + end | ||
41 | + | ||
42 | + should "eval a thumbnail_fitted_height" do | ||
43 | + @video.video_thumbnail_height = 60 | ||
44 | + @video.video_thumbnail_width = 30 | ||
45 | + thumbnail_fitted_height = ((@video.thumbnail_fitted_width * @video.video_thumbnail_height) / @video.video_thumbnail_width).to_i | ||
46 | + assert_equal thumbnail_fitted_height, @video.thumbnail_fitted_height | ||
47 | + end | ||
48 | + | ||
49 | + should "show a no_browser_support_message" do | ||
50 | + assert_equal @video.no_browser_support_message, '<p class="vjs-no-js">To view this video please enable JavaScript, and consider upgrading to a web browser that <a href="http://videojs.com/html5-video-support/" target="_blank">supports HTML5 video</a></p>' | ||
51 | + end | ||
52 | + | ||
53 | + | ||
54 | + ### Tests for YouTube | ||
55 | + | ||
56 | + should "is_youtube return true when the url contains http://youtube.com" do | ||
57 | + @video.video_url = "http://youtube.com/?v=XXXXX" | ||
58 | + assert @video.is_youtube? | ||
59 | + end | ||
60 | + | ||
61 | + should "is_youtube return true when the url contains https://youtube.com" do | ||
62 | + @video.video_url = "https://youtube.com/?v=XXXXX" | ||
63 | + assert @video.is_youtube? | ||
64 | + end | ||
65 | + | ||
66 | + should "is_youtube return false when the url contains an invalid youtube link" do | ||
67 | + @video.video_url = "http://www.yt.com/?v=XXXXX" | ||
68 | + assert !@video.is_youtube? | ||
69 | + end | ||
70 | + | ||
71 | + ### Tests for vimeo | ||
72 | + | ||
73 | + should "is_vimeo return true when the url contains vimeo.com" do | ||
74 | + @video.video_url = "vimeo.com/09898" | ||
75 | + assert @video.is_vimeo? | ||
76 | + end | ||
77 | + | ||
78 | + should "is_vimeo return false when the url not contains vimeo video ID" do | ||
79 | + @video.video_url = "vimeo.com/home" | ||
80 | + assert !@video.is_vimeo? | ||
81 | + end | ||
82 | + | ||
83 | + should "is_vimeo return true for https://vimeo.com/channels/staffpicks/XXXXXXXXXX" do | ||
84 | + @video.video_url = "https://vimeo.com/channels/staffpicks/122325664" | ||
85 | + assert @video.is_vimeo? | ||
86 | + end | ||
87 | + | ||
88 | + | ||
89 | + | ||
90 | +end |
plugins/video/views/box_organizer/_html5_video_block.html.erb
0 → 100644
plugins/video/views/box_organizer/_iframe_video_block.html.erb
0 → 100644
plugins/video/views/box_organizer/video_plugin/_video_block.html.erb
0 → 100644
@@ -0,0 +1,11 @@ | @@ -0,0 +1,11 @@ | ||
1 | +<label for="url" class="formlabel"> Video URL: </label> | ||
2 | + | ||
3 | +<div class="formfield type-text"> | ||
4 | + <%= text_field_tag 'block[url]', @block.url, :class => 'video-url', :maxlength => 255 %> | ||
5 | +</div> | ||
6 | +<div class="formfield type-text"> | ||
7 | + <label for="width" class="formlabel"> Width: </label> | ||
8 | + <%= text_field_tag 'block[width]', @block.width, :size => 7, :class => 'video-width', :maxlength => 5 %> | ||
9 | + <label for="height" class="formlabel"> Height: </label> | ||
10 | + <%= text_field_tag 'block[height]', @block.height, :size => 7, :class => 'video-height', :maxlength => 5 %> | ||
11 | +</div> |
plugins/video/views/box_organizer/video_plugin/_video_gallery_block.html.erb
0 → 100644
@@ -0,0 +1,12 @@ | @@ -0,0 +1,12 @@ | ||
1 | +<%= required_fields_message %> | ||
2 | + | ||
3 | +<div> | ||
4 | +<%= required f.text_field('name', :size => '64', :maxlength => 150) %> | ||
5 | +<%= required labelled_form_field _('URL of the video'), text_field(:article, :video_url, :size => 80) %> | ||
6 | +<%= labelled_form_field(_('Description:'), text_area(:article, :body, :rows => 3, :cols => 64)) %> | ||
7 | +<%= render :partial => 'general_fields' %> | ||
8 | +<%= render :partial => 'translatable' %> | ||
9 | +</div> | ||
10 | + | ||
11 | + | ||
12 | + |
plugins/video/views/cms/video_plugin/_video_gallery.html.erb
0 → 100644
plugins/video/views/content_viewer/video_plugin/_video.html.erb
0 → 100644
@@ -0,0 +1,14 @@ | @@ -0,0 +1,14 @@ | ||
1 | +<div> | ||
2 | +<%if @page.video_provider=='youtube' %> | ||
3 | + <iframe class="video-block-center" width='<%="#{@page.fitted_width}px"%>' height='<%="#{@page.fitted_height}px"%>' src='<%= "#{@page.format_embed_video_url_for_youtube}" %>' frameborder="0" allowfullscreen></iframe> | ||
4 | +<% elsif @page.video_provider=='vimeo' %> | ||
5 | + <iframe class="video-block-center" width='<%="#{@page.fitted_width}px"%>' height='<%="#{@page.fitted_height}px"%>' src='<%= "#{@page.format_embed_video_url_for_vimeo}" %>' frameborder="0" allowfullscreen></iframe> | ||
6 | +<% elsif @page.video_provider=='file' %> | ||
7 | + <video class="video-block-center" controls preload="auto" height="353" width="499" type='<%= @page.video_format %>'> | ||
8 | + <source src=<%= "#{@page.video_url}" %>> | ||
9 | + </video> | ||
10 | +<% end %> | ||
11 | +<br style="clear:both" /> | ||
12 | +</div> | ||
13 | +<% _("Description:") %> | ||
14 | +<%= @page.body %> |
plugins/video/views/content_viewer/video_plugin/_video_gallery.html.erb
0 → 100644
@@ -0,0 +1,14 @@ | @@ -0,0 +1,14 @@ | ||
1 | +<% extend VideoPlugin::VideoGalleryHelper %> | ||
2 | + | ||
3 | +<% unless video_gallery.body.blank? %> | ||
4 | + <div> | ||
5 | + <%= video_gallery.body %> | ||
6 | + </div> | ||
7 | + <hr/> | ||
8 | +<% end %> | ||
9 | + | ||
10 | +<% if video_gallery.children.empty? %> | ||
11 | + <em><%= _('(empty video gallery)') %></em> | ||
12 | +<% else %> | ||
13 | + <%= list_videos(:contents=>video_gallery.children) %> | ||
14 | +<% end %> | ||
0 | \ No newline at end of file | 15 | \ No newline at end of file |
@@ -0,0 +1,40 @@ | @@ -0,0 +1,40 @@ | ||
1 | +<div> | ||
2 | + <% | ||
3 | + first_video = contents[0] | ||
4 | + first_video_arr = Array.new | ||
5 | + first_video_arr.push(first_video) | ||
6 | + other_videos = contents - first_video_arr %> | ||
7 | + <% if first_video.display_to?(user) %> | ||
8 | + <div class="video-gallery-table-big"> | ||
9 | + <div class="video-gallery-left-column-big"> | ||
10 | + <%= link_to first_video.view_url do %> | ||
11 | + <img width="320" height="320" src='<%= first_video.video_thumbnail_url %>' class="disable-zoom"/> | ||
12 | + <% end %> | ||
13 | + </div> | ||
14 | + <div class="video-gallery-right-column-big"> | ||
15 | + <div class="video-title-big"><%= first_video.title %></div> | ||
16 | + <div class="video-author-big"> | ||
17 | + <%= _("by") %> <%= first_video.author_name %> <%= _("updated at") %> <%= time_ago_in_words(first_video.updated_at) %> | ||
18 | + </div> | ||
19 | + </div> | ||
20 | + </div> | ||
21 | + <% end %> | ||
22 | + <% other_videos.each do |content| %> | ||
23 | + <% if content.display_to?(user) %> | ||
24 | + <div class="video-gallery-thumbnail"> | ||
25 | + <div class="video-gallery-top-box"> | ||
26 | + <%= link_to content.view_url do %> | ||
27 | + <img width="<%= content.thumbnail_fitted_width %>" height="<%= content.thumbnail_fitted_height %>" src='<%= content.video_thumbnail_url %>' class="disable-zoom"/> | ||
28 | + <% end %> | ||
29 | + </div> | ||
30 | + <div class="video-gallery-botton-box"> | ||
31 | + <div class="video-author"> | ||
32 | + <%= _("by") %> <%= content.author_name %> <%= _("updated at") %> <%= time_ago_in_words(content.updated_at) %> | ||
33 | + </div> | ||
34 | + <div class="video-title"><%= content.title %></div> | ||
35 | + </div> | ||
36 | + </div> | ||
37 | + <% end %> | ||
38 | + <% end %> | ||
39 | +<p><%= pagination_links contents, :param_name => 'npage', :page_links => true %></p> | ||
40 | +</div> |
@@ -0,0 +1,21 @@ | @@ -0,0 +1,21 @@ | ||
1 | +<h3 class="block-title"> | ||
2 | + <span><%=block.title%></span> | ||
3 | +</h3> | ||
4 | +<div class="video-block-data"> | ||
5 | + <% if block.is_youtube? %> | ||
6 | + <div class='youtube'> | ||
7 | + <%= render :partial => 'box_organizer/iframe_video_block', :locals => { :url => block.format_embed_video_url_for_youtube, :width => block.width, :height => block.height }%> | ||
8 | + </div> | ||
9 | + <% elsif block.is_vimeo? %> | ||
10 | + <div class='vimeo'> | ||
11 | + <%= render :partial => 'box_organizer/iframe_video_block', :locals => { :url => block.format_embed_video_url_for_vimeo, :width => block.width, :height => block.height }%> | ||
12 | + </div> | ||
13 | + <% elsif block.is_video_file? %> | ||
14 | + <div class='video'> | ||
15 | + <%= render :partial => 'box_organizer/html5_video_block', :locals => { :url => block.url, :width => block.width, :height => block.height }%> | ||
16 | + </div> | ||
17 | + <% else %> | ||
18 | + <span class='alert-block'><%= _("Register a valid url (Vimeo, Youtube, video files)") %></span> | ||
19 | + <% end %> | ||
20 | + | ||
21 | +</div> |