From 6cc31ce6b554e278dbfe2ccc1df4cced5d37c1e1 Mon Sep 17 00:00:00 2001 From: AntonioTerceiro Date: Sat, 9 Feb 2008 20:05:20 +0000 Subject: [PATCH] ActionItem154: adding a optional footer for blocks --- app/helpers/boxes_helper.rb | 3 ++- app/models/block.rb | 8 ++++++++ test/unit/block_test.rb | 4 ++++ 3 files changed, 14 insertions(+), 1 deletion(-) diff --git a/app/helpers/boxes_helper.rb b/app/helpers/boxes_helper.rb index dce741a..f7d4c48 100644 --- a/app/helpers/boxes_helper.rb +++ b/app/helpers/boxes_helper.rb @@ -42,10 +42,11 @@ module BoxesHelper def display_block(block, main_content = nil) content = block.main? ? main_content : block.content result = extract_block_content(content) + footer = extract_block_content(footer) classes = ['block', block.css_class_name ].uniq.join(' ') - 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) + 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) end def extract_block_content(content) diff --git a/app/models/block.rb b/app/models/block.rb index 5f53a9d..334005b 100644 --- a/app/models/block.rb +++ b/app/models/block.rb @@ -49,4 +49,12 @@ class Block < ActiveRecord::Base self.class.name.underscore.gsub('_', '-') end + # A footer to be appended to the end of the block. Returns an empty string. + # + # Override in your subclasses. You can return the same types supported by + # #content. + def footer + '' + end + end diff --git a/test/unit/block_test.rb b/test/unit/block_test.rb index 3dd80df..5b4905f 100644 --- a/test/unit/block_test.rb +++ b/test/unit/block_test.rb @@ -28,4 +28,8 @@ class BlockTest < Test::Unit::TestCase assert_equal 'something-block', block.css_class_name end + should 'provide an empty footer by default' do + assert_equal '', Block.new.footer + end + end -- libgit2 0.21.2