Commit b0d542fef9017de7339f98d0bf13a9cc92ebd3aa

Authored by Rafael Reggiani Manzo
1 parent a994ce63

Undo block rendering workaround

Plugins still relied on HTML generation from within the model. This has
been refactored in terms of helpers and views requiring workaround for
thoses plugins in order to work properly.
app/helpers/boxes_helper.rb
@@ -99,15 +99,10 @@ module BoxesHelper @@ -99,15 +99,10 @@ module BoxesHelper
99 end 99 end
100 100
101 def render_block_content block 101 def render_block_content block
102 - # FIXME: this conditional should be removed after all  
103 - # block footer from plugins methods get refactored into helpers and views.  
104 - # They are a failsafe until all of them are done.  
105 - return block.content if block.method(:content).owner != Block  
106 render_block block 102 render_block block
107 end 103 end
108 104
109 def render_block_footer block 105 def render_block_footer block
110 - return block.footer if block.method(:footer).owner != Block  
111 render_block block, 'footers/' 106 render_block block, 'footers/'
112 end 107 end
113 108
app/models/block.rb
@@ -181,30 +181,6 @@ class Block < ApplicationRecord @@ -181,30 +181,6 @@ class Block < ApplicationRecord
181 "/images/block_preview.png" 181 "/images/block_preview.png"
182 end 182 end
183 183
184 - # Returns the content to be used for this block.  
185 - #  
186 - # This method can return several types of objects:  
187 - #  
188 - # * <tt>String</tt>: if the string starts with <tt>http://</tt> or <tt>https://</tt>, then it is assumed to be address of an IFRAME. Otherwise it's is used as regular HTML.  
189 - # * <tt>Hash</tt>: the hash is used to build an URL that is used as the address for a IFRAME.  
190 - # * <tt>Proc</tt>: the Proc is evaluated in the scope of BoxesHelper. The  
191 - # block can then use <tt>render</tt>, <tt>link_to</tt>, etc.  
192 - #  
193 - # The method can also return <tt>nil</tt>, which means "no content".  
194 - #  
195 - # See BoxesHelper#extract_block_content for implementation details.  
196 - def content(args={})  
197 - "This is block number %d" % self.id  
198 - end  
199 -  
200 - # A footer to be appended to the end of the block. Returns <tt>nil</tt>.  
201 - #  
202 - # Override in your subclasses. You can return the same types supported by  
203 - # #content.  
204 - def footer  
205 - nil  
206 - end  
207 -  
208 # Is this block editable? (Default to <tt>true</tt>) 184 # Is this block editable? (Default to <tt>true</tt>)
209 def editable?(user=nil) 185 def editable?(user=nil)
210 self.edit_modes == "all" 186 self.edit_modes == "all"
test/unit/block_test.rb
@@ -23,10 +23,6 @@ class BlockTest &lt; ActiveSupport::TestCase @@ -23,10 +23,6 @@ class BlockTest &lt; ActiveSupport::TestCase
23 assert_nil Block.new.owner 23 assert_nil Block.new.owner
24 end 24 end
25 25
26 - should 'provide no footer by default' do  
27 - assert_nil Block.new.footer  
28 - end  
29 -  
30 should 'provide an empty default title' do 26 should 'provide an empty default title' do
31 assert_equal '', Block.new.default_title 27 assert_equal '', Block.new.default_title
32 end 28 end