[Git][noosfero/noosfero][master] 2 commits: Remove HTML generation from container_block plugin

Rodrigo Souto gitlab at mg.gitlab.com
Tue Mar 29 16:21:29 BRT 2016


Rodrigo Souto pushed to branch master at Noosfero / noosfero


Commits:
1ffd3768 by Rafael Reggiani Manzo at 2016-03-25T21:45:50-03:00
Remove HTML generation from container_block plugin

It now uses BoxesHelper logic instead of HTML generation within the
model violating MVC.

As it is a class within a module
(`ContainerBlockPlugin::ContainerBlock`) `BoxesHelper` required fixes to
handle the module prefix when searching for the proper view to render.
Previously it would wrongly search for
`blocks/container_block_plugin/container.html.erb` instead of
`blocks/container.html.erb`.

- - - - -
8f6d44ea by Rodrigo Souto at 2016-03-29T19:21:02+00:00
Merge branch 'refactor_container_block_plugin_html_generation' into 'master'

Remove HTML generation from container_block plugin

It now uses BoxesHelper logic instead of HTML generation within the
model violating MVC.

As it is a class within a module
(`ContainerBlockPlugin::ContainerBlock`) `BoxesHelper` required fixes to
handle the module prefix when searching for the proper view to render.
Previously it would wrongly search for
`blocks/container_block_plugin/container.html.erb` instead of
`blocks/container.html.erb`.

In case gitlab build does not start, here is the Travis build: https://travis-ci.org/rafamanzo/noosfero/builds/118607978

See merge request !827
- - - - -


2 changed files:

- app/helpers/boxes_helper.rb
- plugins/container_block/lib/container_block_plugin/container_block.rb


Changes:

=====================================
app/helpers/boxes_helper.rb
=====================================
--- a/app/helpers/boxes_helper.rb
+++ b/app/helpers/boxes_helper.rb
@@ -88,7 +88,7 @@ module BoxesHelper
   end
 
   def render_block block, prefix = nil, klass = block.class
-    template_name = klass.name.underscore.sub '_block', ''
+    template_name = klass.name.demodulize.underscore.sub '_block', ''
     begin
       render template: "blocks/#{prefix}#{template_name}", locals: { block: block }
     rescue ActionView::MissingTemplate


=====================================
plugins/container_block/lib/container_block_plugin/container_block.rb
=====================================
--- a/plugins/container_block/lib/container_block_plugin/container_block.rb
+++ b/plugins/container_block/lib/container_block_plugin/container_block.rb
@@ -66,13 +66,6 @@ class ContainerBlockPlugin::ContainerBlock < Block
     children_settings[child_id][:width] if children_settings[child_id]
   end
 
-  def content(args={})
-    block = self
-    proc do
-      render :file => 'blocks/container', :locals => {:block => block}
-    end
-  end
-
   def copy_from_with_container(block)
     copy_from_without_container(block)
     children_settings = block.children_settings



View it on GitLab: https://gitlab.com/noosfero/noosfero/compare/81971fd5e11cbe933efbf2ce48c6e1668047a36b...8f6d44eab6185ed80f714f08e452510ec94a0dc8
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://listas.softwarelivre.org/pipermail/noosfero-dev/attachments/20160329/2664b7c4/attachment-0001.html>


More information about the Noosfero-dev mailing list