Commit d9620af256246be150d015390a6f2912c2bba1f9
1 parent
7eff9852
Exists in
master
and in
28 other branches
string-ext: convert class name to valid css class
Showing
8 changed files
with
23 additions
and
24 deletions
Show diff stats
app/helpers/boxes_helper.rb
... | ... | @@ -227,15 +227,11 @@ module BoxesHelper |
227 | 227 | |
228 | 228 | # DEPRECATED. Do not use this. |
229 | 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 | 231 | stylesheet_import(@blocks_css_files, options) |
232 | 232 | end |
233 | - | |
234 | - def block_css_class_name(block) | |
235 | - block.class.name.underscore.gsub('_', '-') | |
236 | - end | |
237 | 233 | def block_css_classes(block) |
238 | - classes = block_css_class_name(block) | |
234 | + classes = block.class.name.to_css_class | |
239 | 235 | classes += ' invisible-block' if block.display == 'never' |
240 | 236 | classes |
241 | 237 | end | ... | ... |
app/models/article.rb
app/models/box.rb
lib/noosfero/core_ext/string.rb
... | ... | @@ -80,6 +80,10 @@ class String |
80 | 80 | transliterate.downcase.gsub(/[^\w~\s:;+=_."'`-]/, '').gsub(/[\s:;+=_"'`-]+/, '-').gsub(/-$/, '').gsub(/^-/, '').to_s |
81 | 81 | end |
82 | 82 | |
83 | + def to_css_class | |
84 | + underscore.dasherize.gsub('/','_') | |
85 | + end | |
86 | + | |
83 | 87 | def fix_i18n |
84 | 88 | self.sub('{fn} ', '') |
85 | 89 | end | ... | ... |
plugins/container_block/public/style.css
1 | -#content .boxes .container-block-plugin/container-block .container_block_child, .container-block-plugin/container-block .block-outer { | |
1 | +#content .boxes .container-block-plugin_container-block .container_block_child, .container-block-plugin_container-block .block-outer { | |
2 | 2 | display: inline-block; |
3 | 3 | vertical-align: top; |
4 | 4 | margin-left: -2px; |
5 | 5 | margin-right: -2px; |
6 | 6 | } |
7 | 7 | |
8 | -.container-block-plugin/container-block .block-target { | |
8 | +.container-block-plugin_container-block .block-target { | |
9 | 9 | clear: both; |
10 | 10 | } |
11 | 11 | |
12 | -.container-block-plugin/container-block .block-target[id^='end-of-box-'] { | |
12 | +.container-block-plugin_container-block .block-target[id^='end-of-box-'] { | |
13 | 13 | display: none; |
14 | 14 | } |
15 | 15 | |
16 | -#content .boxes .container-block-plugin/container-block .block .icon-down, #content .boxes .container-block-plugin/container-block .block .icon-down-disabled { | |
16 | +#content .boxes .container-block-plugin_container-block .block .icon-down, #content .boxes .container-block-plugin_container-block .block .icon-down-disabled { | |
17 | 17 | background-image: url(/designs/icons/default/Tango/16x16/actions/go-next.png); |
18 | 18 | } |
19 | 19 | |
20 | -#content .boxes .container-block-plugin/container-block .block .icon-up, #content .boxes .container-block-plugin/container-block .block .icon-up-disabled { | |
20 | +#content .boxes .container-block-plugin_container-block .block .icon-up, #content .boxes .container-block-plugin_container-block .block .icon-up-disabled { | |
21 | 21 | background-image: url(/designs/icons/default/Tango/16x16/actions/go-previous.png); |
22 | 22 | } |
23 | 23 | |
24 | -#content .boxes .container-block-plugin/container-block .block { | |
24 | +#content .boxes .container-block-plugin_container-block .block { | |
25 | 25 | outline-offset: -2px; |
26 | 26 | } |
27 | 27 | |
28 | -#content .boxes .container-block-plugin/container-block .block .ui-resizable-handle { | |
28 | +#content .boxes .container-block-plugin_container-block .block .ui-resizable-handle { | |
29 | 29 | width: 10px; |
30 | 30 | height: 28px; |
31 | 31 | z-index: 0; |
32 | 32 | } |
33 | 33 | |
34 | -#content .boxes .container-block-plugin/container-block .block .ui-resizable-e { | |
34 | +#content .boxes .container-block-plugin_container-block .block .ui-resizable-e { | |
35 | 35 | right: -2px; |
36 | 36 | background-image: url(/plugins/container_block/images/handle_e.png); |
37 | 37 | } |
38 | 38 | |
39 | -#content .boxes .container-block-plugin/container-block .block .ui-resizable-w { | |
39 | +#content .boxes .container-block-plugin_container-block .block .ui-resizable-w { | |
40 | 40 | left: -2px; |
41 | 41 | background-image: url(/plugins/container_block/images/handle_w.png); |
42 | 42 | } |
43 | 43 | |
44 | -.container-block-plugin/container-block .button-bar .icon-resize { | |
44 | +.container-block-plugin_container-block .button-bar .icon-resize { | |
45 | 45 | background-image: url(/designs/icons/default/Tango/16x16/actions/view-fullscreen.png); |
46 | 46 | } | ... | ... |
plugins/container_block/test/functional/container_block_home_controller_test.rb
... | ... | @@ -28,7 +28,7 @@ class HomeControllerTest < ActionController::TestCase |
28 | 28 | |
29 | 29 | should 'display ContainerBlock' do |
30 | 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 | 32 | end |
33 | 33 | |
34 | 34 | should 'display container children' do | ... | ... |
test/unit/boxes_helper_test.rb
... | ... | @@ -96,11 +96,6 @@ class BoxesHelperTest < ActiveSupport::TestCase |
96 | 96 | assert_tag_in_string insert_boxes('main content'), :tag => "div", :attributes => { :id => 'profile-footer' }, :content => 'my custom footer' |
97 | 97 | end |
98 | 98 | |
99 | - should 'calculate CSS class names correctly' do | |
100 | - assert_equal 'slideshow-block', block_css_class_name(SlideshowBlock.new) | |
101 | - assert_equal 'main-block', block_css_class_name(MainBlock.new) | |
102 | - end | |
103 | - | |
104 | 99 | should 'add invisible CSS class name for invisible blocks' do |
105 | 100 | assert !block_css_classes(Block.new(:display => 'always')).split.any? { |item| item == 'invisible-block'} |
106 | 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 < ActiveSupport::TestCase |
33 | 33 | assert_equal 'aaaaaaAAAAAeeeeEEOOoocaaaiIIiuuyYnNcC', 'ªáàäâåÁÀÄÂÅéèëêÊËÖÔöôçäàâîÏÎïûüÿŸñÑçÇ'.transliterate |
34 | 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 | 40 | end | ... | ... |