Commit 6cc31ce6b554e278dbfe2ccc1df4cced5d37c1e1

Authored by AntonioTerceiro
1 parent 82426f9f

ActionItem154: adding a optional footer for blocks


git-svn-id: https://svn.colivre.coop.br/svn/noosfero/trunk@1345 3f533792-8f58-4932-b0fe-aaf55b0a4547
app/helpers/boxes_helper.rb
... ... @@ -42,10 +42,11 @@ module BoxesHelper
42 42 def display_block(block, main_content = nil)
43 43 content = block.main? ? main_content : block.content
44 44 result = extract_block_content(content)
  45 + footer = extract_block_content(footer)
45 46  
46 47 classes = ['block', block.css_class_name ].uniq.join(' ')
47 48  
48   - box_decorator.block_target(block.box, block) + content_tag('div', result + box_decorator.block_edit_buttons(block), :class => classes, :id => "block-#{block.id}") + box_decorator.block_handle(block)
  49 + box_decorator.block_target(block.box, block) + content_tag('div', result + footer + box_decorator.block_edit_buttons(block), :class => classes, :id => "block-#{block.id}") + box_decorator.block_handle(block)
49 50 end
50 51  
51 52 def extract_block_content(content)
... ...
app/models/block.rb
... ... @@ -49,4 +49,12 @@ class Block < ActiveRecord::Base
49 49 self.class.name.underscore.gsub('_', '-')
50 50 end
51 51  
  52 + # A footer to be appended to the end of the block. Returns an empty string.
  53 + #
  54 + # Override in your subclasses. You can return the same types supported by
  55 + # #content.
  56 + def footer
  57 + ''
  58 + end
  59 +
52 60 end
... ...
test/unit/block_test.rb
... ... @@ -28,4 +28,8 @@ class BlockTest < Test::Unit::TestCase
28 28 assert_equal 'something-block', block.css_class_name
29 29 end
30 30  
  31 + should 'provide an empty footer by default' do
  32 + assert_equal '', Block.new.footer
  33 + end
  34 +
31 35 end
... ...