Commit ce5d736e0181e5a57b8f1de53bce576ede6afb3d

Authored by Rodrigo Souto
2 parents db6f0f77 ccb1b6ef

Merge branch 'container-block' of gitlab.com:diguliu/noosfero into container-block

Conflicts:
	app/helpers/boxes_helper.rb
	test/unit/boxes_helper_test.rb
app/helpers/boxes_helper.rb
@@ -227,15 +227,11 @@ module BoxesHelper @@ -227,15 +227,11 @@ module BoxesHelper
227 227
228 # DEPRECATED. Do not use this. 228 # DEPRECATED. Do not use this.
229 def import_blocks_stylesheets(options = {}) 229 def import_blocks_stylesheets(options = {})
230 - @blocks_css_files ||= current_blocks.map{|b|'blocks/' + block_css_class_name(b)}.uniq 230 + @blocks_css_files ||= current_blocks.map{|b|'blocks/' + block.class.name.to_css_class}.uniq
231 stylesheet_import(@blocks_css_files, options) 231 stylesheet_import(@blocks_css_files, options)
232 end 232 end
233 -  
234 - def block_css_class_name(block)  
235 - block.class.name.underscore.gsub('_', '-').gsub('/','_')  
236 - end  
237 def block_css_classes(block) 233 def block_css_classes(block)
238 - classes = block_css_class_name(block) 234 + classes = block.class.name.to_css_class
239 classes += ' invisible-block' if block.display == 'never' 235 classes += ' invisible-block' if block.display == 'never'
240 classes 236 classes
241 end 237 end
app/models/article.rb
@@ -157,7 +157,7 @@ class Article < ActiveRecord::Base @@ -157,7 +157,7 @@ class Article < ActiveRecord::Base
157 end 157 end
158 158
159 def css_class_list 159 def css_class_list
160 - [self.class.name.underscore.dasherize] 160 + [self.class.name.to_css_class]
161 end 161 end
162 162
163 def css_class_name 163 def css_class_name
app/models/box.rb
@@ -78,7 +78,7 @@ class Box < ActiveRecord::Base @@ -78,7 +78,7 @@ class Box < ActiveRecord::Base
78 private 78 private
79 79
80 def to_css_class_name(blocks) 80 def to_css_class_name(blocks)
81 - blocks.map{ |block| block.to_s.underscore.tr('_', '-') } 81 + blocks.map{ |block| block.class.name.to_css_class }
82 end 82 end
83 83
84 end 84 end
lib/noosfero/core_ext/string.rb
@@ -80,6 +80,10 @@ class String @@ -80,6 +80,10 @@ class String
80 transliterate.downcase.gsub(/[^\w~\s:;+=_."'`-]/, '').gsub(/[\s:;+=_"'`-]+/, '-').gsub(/-$/, '').gsub(/^-/, '').to_s 80 transliterate.downcase.gsub(/[^\w~\s:;+=_."'`-]/, '').gsub(/[\s:;+=_"'`-]+/, '-').gsub(/-$/, '').gsub(/^-/, '').to_s
81 end 81 end
82 82
  83 + def to_css_class
  84 + underscore.dasherize.gsub('/','_')
  85 + end
  86 +
83 def fix_i18n 87 def fix_i18n
84 self.sub('{fn} ', '') 88 self.sub('{fn} ', '')
85 end 89 end
plugins/container_block/test/functional/container_block_home_controller_test.rb
@@ -28,7 +28,7 @@ class HomeControllerTest < ActionController::TestCase @@ -28,7 +28,7 @@ class HomeControllerTest < ActionController::TestCase
28 28
29 should 'display ContainerBlock' do 29 should 'display ContainerBlock' do
30 get :index 30 get :index
31 - assert_tag :div, :attributes => { :class => 'block container-block-plugin/container-block' } 31 + assert_tag :div, :attributes => { :class => 'block container-block-plugin_container-block' }
32 end 32 end
33 33
34 should 'display container children' do 34 should 'display container children' do
plugins/container_block/views/blocks/container.rhtml
@@ -16,10 +16,10 @@ @@ -16,10 +16,10 @@
16 16
17 <% if edit_mode %> 17 <% if edit_mode %>
18 <div class="button-bar"> 18 <div class="button-bar">
19 - <a href="#" onclick="toggleMoveContainerChildren(<%= block.id %>, <%= block.container_box.id %>); return false;" class="button icon-resize"></a> 19 + <a href="#" onclick="toggleMoveContainerChildren(<%= block.id %>, <%= block.container_box.id %>); return false;" class="button icon-resize" title=<%= _('Resize blocks').to_json %>></a>
20 <%= link_to_remote '', :url => { :controller => @controller.boxes_holder.kind_of?(Environment) ? 'container_block_plugin_admin' : 'container_block_plugin_myprofile', :action => 'saveWidths', :id => block.id }, 20 <%= link_to_remote '', :url => { :controller => @controller.boxes_holder.kind_of?(Environment) ? 'container_block_plugin_admin' : 'container_block_plugin_myprofile', :action => 'saveWidths', :id => block.id },
21 :with => "containerChildrenWidth(#{block.id}, #{block.container_box.id})", 21 :with => "containerChildrenWidth(#{block.id}, #{block.container_box.id})",
22 - :html => {:class => "button icon-save container_block_save", :id => "container_block_save_#{block.id}" }, 22 + :html => {:class => "button icon-save container_block_save", :id => "container_block_save_#{block.id}", :title => _('Save') },
23 :loading => "open_loading(DEFAULT_LOADING_MESSAGE);", 23 :loading => "open_loading(DEFAULT_LOADING_MESSAGE);",
24 :loaded => "close_loading();", 24 :loaded => "close_loading();",
25 :complete => "display_notice(request.responseText);"%> 25 :complete => "display_notice(request.responseText);"%>
plugins/container_block/views/box_organizer/_container_block.rhtml
@@ -1,14 +0,0 @@ @@ -1,14 +0,0 @@
1 -<br/>  
2 -<ul id="links">  
3 - <% @block.blocks.each do |block| %>  
4 - <li>  
5 - <%= block.class.name %>  
6 - </li>  
7 - <% end %>  
8 -</ul>  
9 -  
10 -<%= link_to_function(_('New block'), nil, :class => 'button icon-add with-text') { |page|  
11 - page.insert_html :bottom, 'links', content_tag('li',select_tag('block[block_classes][]',  
12 - options_for_select( @controller.available_blocks.each_with_index.map {|b,i| [b.name, b.name] } ))) } %>  
13 -  
14 -<br/><br/>  
test/unit/boxes_helper_test.rb
@@ -96,13 +96,6 @@ class BoxesHelperTest &lt; ActiveSupport::TestCase @@ -96,13 +96,6 @@ class BoxesHelperTest &lt; ActiveSupport::TestCase
96 assert_tag_in_string insert_boxes('main content'), :tag => "div", :attributes => { :id => 'profile-footer' }, :content => 'my custom footer' 96 assert_tag_in_string insert_boxes('main content'), :tag => "div", :attributes => { :id => 'profile-footer' }, :content => 'my custom footer'
97 end 97 end
98 98
99 - should 'calculate CSS class names correctly' do  
100 - class NamespacedBlock < Block; end  
101 - assert_equal 'slideshow-block', block_css_class_name(SlideshowBlock.new)  
102 - assert_equal 'main-block', block_css_class_name(MainBlock.new)  
103 - assert_equal 'boxes-helper-test_namespaced-block', block_css_class_name(NamespacedBlock.new)  
104 - end  
105 -  
106 should 'add invisible CSS class name for invisible blocks' do 99 should 'add invisible CSS class name for invisible blocks' do
107 assert !block_css_classes(Block.new(:display => 'always')).split.any? { |item| item == 'invisible-block'} 100 assert !block_css_classes(Block.new(:display => 'always')).split.any? { |item| item == 'invisible-block'}
108 assert block_css_classes(Block.new(:display => 'never')).split.any? { |item| item == 'invisible-block'} 101 assert block_css_classes(Block.new(:display => 'never')).split.any? { |item| item == 'invisible-block'}
test/unit/string_core_ext_test.rb
@@ -33,4 +33,8 @@ class StringCoreExtTest &lt; ActiveSupport::TestCase @@ -33,4 +33,8 @@ class StringCoreExtTest &lt; ActiveSupport::TestCase
33 assert_equal 'aaaaaaAAAAAeeeeEEOOoocaaaiIIiuuyYnNcC', 'ªáàäâåÁÀÄÂÅéèëêÊËÖÔöôçäàâîÏÎïûüÿŸñÑçÇ'.transliterate 33 assert_equal 'aaaaaaAAAAAeeeeEEOOoocaaaiIIiuuyYnNcC', 'ªáàäâåÁÀÄÂÅéèëêÊËÖÔöôçäàâîÏÎïûüÿŸñÑçÇ'.transliterate
34 end 34 end
35 35
  36 + should 'convert to css class' do
  37 + assert_equal 'spaceship-propulsion_warp-core', "SpaceshipPropulsion::WarpCore".to_css_class
  38 + end
  39 +
36 end 40 end