diff --git a/plugins/context_content/lib/context_content_plugin/context_content_block.rb b/plugins/context_content/lib/context_content_plugin/context_content_block.rb
index bf3d081..4d9d947 100644
--- a/plugins/context_content/lib/context_content_plugin/context_content_block.rb
+++ b/plugins/context_content/lib/context_content_plugin/context_content_block.rb
@@ -6,6 +6,8 @@ class ContextContentPlugin::ContextContentBlock < Block
settings_items :types, :type => Array, :default => ['UploadedFile']
settings_items :limit, :type => :integer, :default => 6
+ attr_accessible :show_image, :show_name, :show_parent_content, :types
+
alias :profile :owner
include Noosfero::Plugin::HotSpot
@@ -42,7 +44,7 @@ class ContextContentPlugin::ContextContentBlock < Block
def content_image(content)
block = self
- lambda do
+ proc do
if content.image?
image_tag(content.public_filename(:thumb))
else
@@ -65,7 +67,7 @@ class ContextContentPlugin::ContextContentBlock < Block
def footer
block = self
- lambda do
+ proc do
contents = block.contents(@page)
if contents
content_tag('div',
@@ -78,7 +80,7 @@ class ContextContentPlugin::ContextContentBlock < Block
def content(args={})
block = self
- lambda do
+ proc do
contents = block.contents(@page)
if !contents.blank?
block_title(block.title) + content_tag('div',
diff --git a/plugins/context_content/test/functional/content_viewer_controller_test.rb b/plugins/context_content/test/functional/content_viewer_controller_test.rb
index a20b37d..010fd28 100644
--- a/plugins/context_content/test/functional/content_viewer_controller_test.rb
+++ b/plugins/context_content/test/functional/content_viewer_controller_test.rb
@@ -14,7 +14,7 @@ class ContentViewerControllerTest < ActionController::TestCase
@page = fast_create(Folder, :profile_id => @profile.id)
box = Box.create!(:owner => @profile)
- @block = ContextContentPlugin::ContextContentBlock.new(:box => box)
+ @block = ContextContentPlugin::ContextContentBlock.new(:box_id => box.id)
@block.types = ['TinyMceArticle']
@block.limit = 1
@block.save!
diff --git a/plugins/context_content/test/functional/profile_design_controller_test.rb b/plugins/context_content/test/functional/profile_design_controller_test.rb
index 9f3b44e..2345c21 100644
--- a/plugins/context_content/test/functional/profile_design_controller_test.rb
+++ b/plugins/context_content/test/functional/profile_design_controller_test.rb
@@ -19,7 +19,7 @@ class ProfileDesignControllerTest < ActionController::TestCase
@page = fast_create(Folder, :profile_id => @profile.id)
box = Box.create!(:owner => @profile)
- @block = ContextContentPlugin::ContextContentBlock.new(:box => box)
+ @block = ContextContentPlugin::ContextContentBlock.new(:box_id => box.id)
@block.types = ['TinyMceArticle']
@block.limit = 1
@block.save!
@@ -35,7 +35,7 @@ class ProfileDesignControllerTest < ActionController::TestCase
assert_tag :tag => 'input', :attributes => { :id => 'block_show_image' }
assert_tag :tag => 'input', :attributes => { :id => 'block_show_name' }
assert_tag :tag => 'input', :attributes => { :id => 'block_show_parent_content' }
- assert_tag :tag => 'input', :attributes => { :id => 'block_types' }
+ assert_tag :tag => 'input', :attributes => { :name => 'block[types][]' }
end
should 'be able to save TrackListBlock' do
diff --git a/plugins/context_content/test/unit/context_content_block_test.rb b/plugins/context_content/test/unit/context_content_block_test.rb
index fa27cd4..a003921 100644
--- a/plugins/context_content/test/unit/context_content_block_test.rb
+++ b/plugins/context_content/test/unit/context_content_block_test.rb
@@ -163,14 +163,14 @@ class ContextContentBlockTest < ActiveSupport::TestCase
article2 = fast_create(TinyMceArticle, :parent_id => @page.id)
article3 = fast_create(TinyMceArticle, :parent_id => @page.id)
expects(:content_tag).once
- expects(:render).with(:partial => 'blocks/more', :locals => {:block => @block, :contents => [article1, article2], :article_id => @page.id}).once
+ expects(:render).with(has_entry(:partial => 'blocks/more'))
instance_eval(&@block.footer)
end
should 'return box owner on profile method call' do
profile = fast_create(Community)
- box = Box.create(:owner_type => 'Profile', :owner_id => profile.id)
- block = ContextContentPlugin::ContextContentBlock.create!(:box => box)
+ box = Box.create!(:owner => profile)
+ block = ContextContentPlugin::ContextContentBlock.create!(:box_id => box.id)
assert_equal profile, block.profile
end
diff --git a/plugins/context_content/views/blocks/_more.html.erb b/plugins/context_content/views/blocks/_more.html.erb
new file mode 100644
index 0000000..971556b
--- /dev/null
+++ b/plugins/context_content/views/blocks/_more.html.erb
@@ -0,0 +1,4 @@
+<% if contents.total_pages > 1 %>
+ <%= link_to_remote(nil, :url => {:id => block.id, :controller => 'context_content_plugin_profile', :action => 'view_content', :page => contents.previous_page, :article_id => article_id }, :html => {:class => "button icon-button icon-left #{contents.previous_page ? '':'disabled'}".strip}, :condition => "#{!contents.previous_page.nil?}", :success => "jQuery('#context_content_#{block.id}').effect('slide', {direction: 'left'});" )%>
+ <%= link_to_remote(nil, :url => {:id => block.id, :controller => 'context_content_plugin_profile', :action => 'view_content', :page => contents.next_page, :article_id => article_id }, :html => {:class => "button icon-button icon-right #{contents.next_page ? '':'disabled'}".strip}, :condition => "#{!contents.next_page.nil?}", :success => "jQuery('#context_content_#{block.id}').effect('slide', {direction: 'right'});" )%>
+<% end %>
diff --git a/plugins/context_content/views/blocks/_more.rhtml b/plugins/context_content/views/blocks/_more.rhtml
deleted file mode 100644
index 971556b..0000000
--- a/plugins/context_content/views/blocks/_more.rhtml
+++ /dev/null
@@ -1,4 +0,0 @@
-<% if contents.total_pages > 1 %>
- <%= link_to_remote(nil, :url => {:id => block.id, :controller => 'context_content_plugin_profile', :action => 'view_content', :page => contents.previous_page, :article_id => article_id }, :html => {:class => "button icon-button icon-left #{contents.previous_page ? '':'disabled'}".strip}, :condition => "#{!contents.previous_page.nil?}", :success => "jQuery('#context_content_#{block.id}').effect('slide', {direction: 'left'});" )%>
- <%= link_to_remote(nil, :url => {:id => block.id, :controller => 'context_content_plugin_profile', :action => 'view_content', :page => contents.next_page, :article_id => article_id }, :html => {:class => "button icon-button icon-right #{contents.next_page ? '':'disabled'}".strip}, :condition => "#{!contents.next_page.nil?}", :success => "jQuery('#context_content_#{block.id}').effect('slide', {direction: 'right'});" )%>
-<% end %>
diff --git a/plugins/context_content/views/blocks/context_content.html.erb b/plugins/context_content/views/blocks/context_content.html.erb
new file mode 100644
index 0000000..88c8f60
--- /dev/null
+++ b/plugins/context_content/views/blocks/context_content.html.erb
@@ -0,0 +1,13 @@
+<% contents.each do |content| %>
+ <% content = FilePresenter.for(content) %>
+
+
+