Commit a1fc3c496176ea326c0de57d30d49c04db011935
Committed by
Antonio Terceiro
1 parent
747cb827
Exists in
master
and in
28 other branches
configuration for environment icon theme
Showing
7 changed files
with
48 additions
and
7 deletions
Show diff stats
app/helpers/application_helper.rb
... | ... | @@ -787,4 +787,14 @@ module ApplicationHelper |
787 | 787 | end |
788 | 788 | end |
789 | 789 | |
790 | + def icon_theme_stylesheet_tag | |
791 | + theme_path = "/designs/icons/#{environment.icon_theme}/style.css" | |
792 | + if File.exists?(File.join(RAILS_ROOT, 'public', theme_path)) | |
793 | + stylesheet_link_tag theme_path | |
794 | + else | |
795 | + "<!-- Not included: #{stylesheet_link_tag theme_path} -->\n" + | |
796 | + stylesheet_link_tag("/designs/icons/default/style.css") | |
797 | + end | |
798 | + end | |
799 | + | |
790 | 800 | end | ... | ... |
app/models/environment.rb
... | ... | @@ -458,6 +458,13 @@ class Environment < ActiveRecord::Base |
458 | 458 | settings[:themes] = values.map(&:id) |
459 | 459 | end |
460 | 460 | |
461 | + def icon_theme | |
462 | + settings[:icon_theme] || 'default' | |
463 | + end | |
464 | + def icon_theme=(theme) | |
465 | + settings[:icon_theme] = theme | |
466 | + end | |
467 | + | |
461 | 468 | def layout_template |
462 | 469 | settings[:layout_template] || 'default' |
463 | 470 | end | ... | ... |
app/views/layouts/application.rhtml
... | ... | @@ -46,9 +46,7 @@ |
46 | 46 | %> |
47 | 47 | |
48 | 48 | <%= template_stylesheet_tag %> |
49 | - | |
50 | - <%# FIXME %> | |
51 | - <%= stylesheet_link_tag '/designs/icons/default/style.css' %> | |
49 | + <%= icon_theme_stylesheet_tag %> | |
52 | 50 | |
53 | 51 | <%= stylesheet_link_tag 'iepngfix/iepngfix.css' %> |
54 | 52 | <base href="<%= base_url %>"/> |
... | ... | @@ -134,7 +132,7 @@ |
134 | 132 | <%= render :file => 'shared/user_menu' %> |
135 | 133 | </div><!-- id='user_box' --> |
136 | 134 | |
137 | - <a href="#" id="btShowHelp" class="icon-help32on help-on" | |
135 | + <a href="#" id="btShowHelp" class="icon-help32on help-on icon-help-on" | |
138 | 136 | title="<%= _('Turn help on/off') %>" |
139 | 137 | onclick="mouseHelpOnOff(); return false"><span><%= _('Help') %></span></a> |
140 | 138 | ... | ... |
app/views/layouts/block.rhtml
... | ... | @@ -11,7 +11,8 @@ |
11 | 11 | |
12 | 12 | <%# FIXME %> |
13 | 13 | <%= stylesheet_link_tag '/designs/templates/default/stylesheets/style.css' %> |
14 | - <%= stylesheet_link_tag '/designs/icons/default/style.css' %> | |
14 | + | |
15 | + <%= icon_theme_stylesheet_tag %> | |
15 | 16 | |
16 | 17 | <%= javascript_include_tag(:defaults) %> |
17 | 18 | ... | ... |
public/javascripts/noosfero-show-help.js
... | ... | @@ -2,10 +2,10 @@ |
2 | 2 | function mouseHelpOnOff() { |
3 | 3 | if ( pageHelp.info.updateBox ) { |
4 | 4 | showMouseHelpOff() |
5 | - $("btShowHelp").className = "icon-help32on help-on"; | |
5 | + $("btShowHelp").className = "icon-help32on help-on icon-help-on"; | |
6 | 6 | } else { |
7 | 7 | showMouseHelpOn() |
8 | - $("btShowHelp").className = "icon-help32off help-off"; | |
8 | + $("btShowHelp").className = "icon-help32off help-off icon-help-off"; | |
9 | 9 | } |
10 | 10 | var date = new Date(); |
11 | 11 | // open/close help on help button is remembed by one year: | ... | ... |
test/unit/application_helper_test.rb
... | ... | @@ -446,6 +446,13 @@ class ApplicationHelperTest < Test::Unit::TestCase |
446 | 446 | assert !ask_to_join? |
447 | 447 | end |
448 | 448 | |
449 | + should 'give default icon theme when no exists stylesheet file' do | |
450 | + e = Environment.default | |
451 | + e.icon_theme = 'something-very-unlikely' | |
452 | + stubs(:environment).returns(e) | |
453 | + assert_equal "<!-- Not included: /designs/icons/something-very-unlikely/style.css -->\n/designs/icons/default/style.css", icon_theme_stylesheet_tag | |
454 | + end | |
455 | + | |
449 | 456 | protected |
450 | 457 | |
451 | 458 | def url_for(args = {}) |
... | ... | @@ -463,5 +470,8 @@ class ApplicationHelperTest < Test::Unit::TestCase |
463 | 470 | def check_box_tag(name, value = 1, checked = false, options = {}) |
464 | 471 | name |
465 | 472 | end |
473 | + def stylesheet_link_tag(arg) | |
474 | + arg | |
475 | + end | |
466 | 476 | |
467 | 477 | end | ... | ... |
test/unit/environment_test.rb
... | ... | @@ -701,4 +701,19 @@ class EnvironmentTest < Test::Unit::TestCase |
701 | 701 | end |
702 | 702 | end |
703 | 703 | |
704 | + should 'provide icon theme' do | |
705 | + assert_equal 'my-icons-theme', Environment.new(:icon_theme => 'my-icons-theme').icon_theme | |
706 | + end | |
707 | + | |
708 | + should 'give default icon theme' do | |
709 | + assert_equal 'default', Environment.new.icon_theme | |
710 | + end | |
711 | + | |
712 | + should 'modify icon theme' do | |
713 | + e = Environment.new | |
714 | + assert_equal 'default', e.icon_theme | |
715 | + e.icon_theme = 'non-default' | |
716 | + assert_not_equal 'default', e.icon_theme | |
717 | + end | |
718 | + | |
704 | 719 | end | ... | ... |