From a1fc3c496176ea326c0de57d30d49c04db011935 Mon Sep 17 00:00:00 2001 From: Joenio Costa Date: Thu, 9 Apr 2009 11:18:20 -0300 Subject: [PATCH] configuration for environment icon theme --- app/helpers/application_helper.rb | 10 ++++++++++ app/models/environment.rb | 7 +++++++ app/views/layouts/application.rhtml | 6 ++---- app/views/layouts/block.rhtml | 3 ++- public/javascripts/noosfero-show-help.js | 4 ++-- test/unit/application_helper_test.rb | 10 ++++++++++ test/unit/environment_test.rb | 15 +++++++++++++++ 7 files changed, 48 insertions(+), 7 deletions(-) diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index e1c2f9e..f6f5efd 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -787,4 +787,14 @@ module ApplicationHelper end end + def icon_theme_stylesheet_tag + theme_path = "/designs/icons/#{environment.icon_theme}/style.css" + if File.exists?(File.join(RAILS_ROOT, 'public', theme_path)) + stylesheet_link_tag theme_path + else + "\n" + + stylesheet_link_tag("/designs/icons/default/style.css") + end + end + end diff --git a/app/models/environment.rb b/app/models/environment.rb index d59db80..f543ef5 100644 --- a/app/models/environment.rb +++ b/app/models/environment.rb @@ -458,6 +458,13 @@ class Environment < ActiveRecord::Base settings[:themes] = values.map(&:id) end + def icon_theme + settings[:icon_theme] || 'default' + end + def icon_theme=(theme) + settings[:icon_theme] = theme + end + def layout_template settings[:layout_template] || 'default' end diff --git a/app/views/layouts/application.rhtml b/app/views/layouts/application.rhtml index cfc5bd9..4a185ea 100644 --- a/app/views/layouts/application.rhtml +++ b/app/views/layouts/application.rhtml @@ -46,9 +46,7 @@ %> <%= template_stylesheet_tag %> - - <%# FIXME %> - <%= stylesheet_link_tag '/designs/icons/default/style.css' %> + <%= icon_theme_stylesheet_tag %> <%= stylesheet_link_tag 'iepngfix/iepngfix.css' %> @@ -134,7 +132,7 @@ <%= render :file => 'shared/user_menu' %> - <%= _('Help') %> diff --git a/app/views/layouts/block.rhtml b/app/views/layouts/block.rhtml index f1e1fea..8988291 100644 --- a/app/views/layouts/block.rhtml +++ b/app/views/layouts/block.rhtml @@ -11,7 +11,8 @@ <%# FIXME %> <%= stylesheet_link_tag '/designs/templates/default/stylesheets/style.css' %> - <%= stylesheet_link_tag '/designs/icons/default/style.css' %> + + <%= icon_theme_stylesheet_tag %> <%= javascript_include_tag(:defaults) %> diff --git a/public/javascripts/noosfero-show-help.js b/public/javascripts/noosfero-show-help.js index a9ff65c..b3927ad 100644 --- a/public/javascripts/noosfero-show-help.js +++ b/public/javascripts/noosfero-show-help.js @@ -2,10 +2,10 @@ function mouseHelpOnOff() { if ( pageHelp.info.updateBox ) { showMouseHelpOff() - $("btShowHelp").className = "icon-help32on help-on"; + $("btShowHelp").className = "icon-help32on help-on icon-help-on"; } else { showMouseHelpOn() - $("btShowHelp").className = "icon-help32off help-off"; + $("btShowHelp").className = "icon-help32off help-off icon-help-off"; } var date = new Date(); // open/close help on help button is remembed by one year: diff --git a/test/unit/application_helper_test.rb b/test/unit/application_helper_test.rb index c85e635..abceb36 100644 --- a/test/unit/application_helper_test.rb +++ b/test/unit/application_helper_test.rb @@ -446,6 +446,13 @@ class ApplicationHelperTest < Test::Unit::TestCase assert !ask_to_join? end + should 'give default icon theme when no exists stylesheet file' do + e = Environment.default + e.icon_theme = 'something-very-unlikely' + stubs(:environment).returns(e) + assert_equal "\n/designs/icons/default/style.css", icon_theme_stylesheet_tag + end + protected def url_for(args = {}) @@ -463,5 +470,8 @@ class ApplicationHelperTest < Test::Unit::TestCase def check_box_tag(name, value = 1, checked = false, options = {}) name end + def stylesheet_link_tag(arg) + arg + end end diff --git a/test/unit/environment_test.rb b/test/unit/environment_test.rb index 32f8072..954cab9 100644 --- a/test/unit/environment_test.rb +++ b/test/unit/environment_test.rb @@ -701,4 +701,19 @@ class EnvironmentTest < Test::Unit::TestCase end end + should 'provide icon theme' do + assert_equal 'my-icons-theme', Environment.new(:icon_theme => 'my-icons-theme').icon_theme + end + + should 'give default icon theme' do + assert_equal 'default', Environment.new.icon_theme + end + + should 'modify icon theme' do + e = Environment.new + assert_equal 'default', e.icon_theme + e.icon_theme = 'non-default' + assert_not_equal 'default', e.icon_theme + end + end -- libgit2 0.21.2