From 837a8ef9d25a80b9c5aa408ff72d80d0f8fee869 Mon Sep 17 00:00:00 2001 From: Evandro Junior Date: Mon, 9 Feb 2015 16:11:50 -0300 Subject: [PATCH] before removeing trailing spaces --- plugins/video/lib/ext/article.rb | 30 +++++++----------------------- plugins/video/lib/video_plugin/video_gallery_block.rb | 31 +++++++++++++++++++++++++++++++ plugins/video/views/box_organizer/video_plugin/_video_gallery_block.html.erb | 3 +++ plugins/video/views/shared/video_plugin/apagar_video_block.html.erb | 21 --------------------- plugins/video/views/video_gallery_block.html.erb | 7 +++++++ 5 files changed, 48 insertions(+), 44 deletions(-) create mode 100644 plugins/video/lib/video_plugin/video_gallery_block.rb create mode 100644 plugins/video/views/box_organizer/video_plugin/_video_gallery_block.html.erb delete mode 100644 plugins/video/views/shared/video_plugin/apagar_video_block.html.erb create mode 100644 plugins/video/views/video_gallery_block.html.erb diff --git a/plugins/video/lib/ext/article.rb b/plugins/video/lib/ext/article.rb index a870126..8e97c3b 100644 --- a/plugins/video/lib/ext/article.rb +++ b/plugins/video/lib/ext/article.rb @@ -2,8 +2,8 @@ require_dependency 'article' class Article - scope :video_gallery, :conditions => ["articles.type == 'VideoGallery'"] - + scope :video_gallery, :conditions => ["articles.type = 'VideoPlugin::VideoGallery'"] + #FIXME This should be done via hotspot def self.folder_types_with_video self.folder_types_without_video << 'VideoPlugin::VideoGallery' @@ -13,31 +13,15 @@ class Article class << self alias_method_chain :folder_types, :video end - - -# def self.articles_columns -# Article.column_names.map {|c| "articles.#{c}"} .join(",") -# end -# -# def self.most_accessed(owner, limit = nil) -# conditions = owner.kind_of?(Environment) ? ["hits > 0"] : ["profile_id = ? and hits > 0", owner.id] -# result = Article.relevant_content.find( -# :all, -# :order => 'hits desc', -# :limit => limit, -# :conditions => conditions) -# result.paginate({:page => 1, :per_page => limit}) -# end - - def self.can_be_listed - conditions = owner.kind_of?(Environment) ? ["hits > 0"] : ["profile_id = ? and hits > 0", owner.id] + + def self.owner_video_galleries(owner) + conditions = owner.kind_of?(Environment) ? [] : ["profile_id = ?", owner.id] result = Article.video_gallery.find( :all, - :order => 'hits desc', + :order => 'created_at desc', :conditions => conditions) end - - + end diff --git a/plugins/video/lib/video_plugin/video_gallery_block.rb b/plugins/video/lib/video_plugin/video_gallery_block.rb new file mode 100644 index 0000000..60a21ab --- /dev/null +++ b/plugins/video/lib/video_plugin/video_gallery_block.rb @@ -0,0 +1,31 @@ +class VideoPlugin::VideoGalleryBlock < Block + + settings_items :video_gallery_id, :type => :integer + attr_accessible :video_gallery_id + + include ActionView::Helpers + include Rails.application.routes.url_helpers + + def self.description + _('Display a Video Gallery') + end + + def help + _('This block presents a video gallery') + end + + def content(args={}) + block = self + if video_gallery_id.present? + video_gallery = VideoPlugin::VideoGallery.find(video_gallery_id) + proc do + render :partial => 'content_viewer/video_plugin/video_gallery', :locals => {:video_gallery => video_gallery} + end + end + end + + def list_my_galleries + Article.owner_video_galleries(owner) + end + +end diff --git a/plugins/video/views/box_organizer/video_plugin/_video_gallery_block.html.erb b/plugins/video/views/box_organizer/video_plugin/_video_gallery_block.html.erb new file mode 100644 index 0000000..dfe6449 --- /dev/null +++ b/plugins/video/views/box_organizer/video_plugin/_video_gallery_block.html.erb @@ -0,0 +1,3 @@ + \ No newline at end of file diff --git a/plugins/video/views/shared/video_plugin/apagar_video_block.html.erb b/plugins/video/views/shared/video_plugin/apagar_video_block.html.erb deleted file mode 100644 index 0bfbf68..0000000 --- a/plugins/video/views/shared/video_plugin/apagar_video_block.html.erb +++ /dev/null @@ -1,21 +0,0 @@ -

- <%=block.title%> -

-
- <% if block.is_youtube? %> -
- <%= render :partial => 'box_organizer/iframe_video_block', :locals => { :url => block.format_embed_video_url_for_youtube, :width => block.width, :height => block.height }%> -
- <% elsif block.is_vimeo? %> -
- <%= render :partial => 'box_organizer/iframe_video_block', :locals => { :url => block.format_embed_video_url_for_vimeo, :width => block.width, :height => block.height }%> -
- <% elsif block.is_video_file? %> -
- <%= render :partial => 'box_organizer/html5_video_block', :locals => { :url => block.url, :width => block.width, :height => block.height }%> -
- <% else %> - <%= _("Register a valid url (Vimeo, Youtube, video files)") %> - <% end %> - -
diff --git a/plugins/video/views/video_gallery_block.html.erb b/plugins/video/views/video_gallery_block.html.erb new file mode 100644 index 0000000..f71b82c --- /dev/null +++ b/plugins/video/views/video_gallery_block.html.erb @@ -0,0 +1,7 @@ +<%# +# To change this license header, choose License Headers in Project Properties. +# To change this template file, choose Tools | Templates +# and open the template in the editor. +%> + +<%= "video_gallery_block.html" %> -- libgit2 0.21.2