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,4 +787,14 @@ module ApplicationHelper | ||
787 | end | 787 | end |
788 | end | 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 | end | 800 | end |
app/models/environment.rb
@@ -458,6 +458,13 @@ class Environment < ActiveRecord::Base | @@ -458,6 +458,13 @@ class Environment < ActiveRecord::Base | ||
458 | settings[:themes] = values.map(&:id) | 458 | settings[:themes] = values.map(&:id) |
459 | end | 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 | def layout_template | 468 | def layout_template |
462 | settings[:layout_template] || 'default' | 469 | settings[:layout_template] || 'default' |
463 | end | 470 | end |
app/views/layouts/application.rhtml
@@ -46,9 +46,7 @@ | @@ -46,9 +46,7 @@ | ||
46 | %> | 46 | %> |
47 | 47 | ||
48 | <%= template_stylesheet_tag %> | 48 | <%= template_stylesheet_tag %> |
49 | - | ||
50 | - <%# FIXME %> | ||
51 | - <%= stylesheet_link_tag '/designs/icons/default/style.css' %> | 49 | + <%= icon_theme_stylesheet_tag %> |
52 | 50 | ||
53 | <%= stylesheet_link_tag 'iepngfix/iepngfix.css' %> | 51 | <%= stylesheet_link_tag 'iepngfix/iepngfix.css' %> |
54 | <base href="<%= base_url %>"/> | 52 | <base href="<%= base_url %>"/> |
@@ -134,7 +132,7 @@ | @@ -134,7 +132,7 @@ | ||
134 | <%= render :file => 'shared/user_menu' %> | 132 | <%= render :file => 'shared/user_menu' %> |
135 | </div><!-- id='user_box' --> | 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 | title="<%= _('Turn help on/off') %>" | 136 | title="<%= _('Turn help on/off') %>" |
139 | onclick="mouseHelpOnOff(); return false"><span><%= _('Help') %></span></a> | 137 | onclick="mouseHelpOnOff(); return false"><span><%= _('Help') %></span></a> |
140 | 138 |
app/views/layouts/block.rhtml
@@ -11,7 +11,8 @@ | @@ -11,7 +11,8 @@ | ||
11 | 11 | ||
12 | <%# FIXME %> | 12 | <%# FIXME %> |
13 | <%= stylesheet_link_tag '/designs/templates/default/stylesheets/style.css' %> | 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 | <%= javascript_include_tag(:defaults) %> | 17 | <%= javascript_include_tag(:defaults) %> |
17 | 18 |
public/javascripts/noosfero-show-help.js
@@ -2,10 +2,10 @@ | @@ -2,10 +2,10 @@ | ||
2 | function mouseHelpOnOff() { | 2 | function mouseHelpOnOff() { |
3 | if ( pageHelp.info.updateBox ) { | 3 | if ( pageHelp.info.updateBox ) { |
4 | showMouseHelpOff() | 4 | showMouseHelpOff() |
5 | - $("btShowHelp").className = "icon-help32on help-on"; | 5 | + $("btShowHelp").className = "icon-help32on help-on icon-help-on"; |
6 | } else { | 6 | } else { |
7 | showMouseHelpOn() | 7 | showMouseHelpOn() |
8 | - $("btShowHelp").className = "icon-help32off help-off"; | 8 | + $("btShowHelp").className = "icon-help32off help-off icon-help-off"; |
9 | } | 9 | } |
10 | var date = new Date(); | 10 | var date = new Date(); |
11 | // open/close help on help button is remembed by one year: | 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,6 +446,13 @@ class ApplicationHelperTest < Test::Unit::TestCase | ||
446 | assert !ask_to_join? | 446 | assert !ask_to_join? |
447 | end | 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 | protected | 456 | protected |
450 | 457 | ||
451 | def url_for(args = {}) | 458 | def url_for(args = {}) |
@@ -463,5 +470,8 @@ class ApplicationHelperTest < Test::Unit::TestCase | @@ -463,5 +470,8 @@ class ApplicationHelperTest < Test::Unit::TestCase | ||
463 | def check_box_tag(name, value = 1, checked = false, options = {}) | 470 | def check_box_tag(name, value = 1, checked = false, options = {}) |
464 | name | 471 | name |
465 | end | 472 | end |
473 | + def stylesheet_link_tag(arg) | ||
474 | + arg | ||
475 | + end | ||
466 | 476 | ||
467 | end | 477 | end |
test/unit/environment_test.rb
@@ -701,4 +701,19 @@ class EnvironmentTest < Test::Unit::TestCase | @@ -701,4 +701,19 @@ class EnvironmentTest < Test::Unit::TestCase | ||
701 | end | 701 | end |
702 | end | 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 | end | 719 | end |