diff options
author | Jean-Philippe Lang <jp_lang@yahoo.fr> | 2012-04-28 09:10:46 +0000 |
---|---|---|
committer | Jean-Philippe Lang <jp_lang@yahoo.fr> | 2012-04-28 09:10:46 +0000 |
commit | 03335d014ceb42d8db670606e3960b5fd84cb7c3 (patch) | |
tree | 0ce368dfb2f336ada99dac6db73b8f17c73c875b /app | |
parent | f12942ff400878a407c3523e295fe0dbc65760b0 (diff) | |
download | redmine-03335d014ceb42d8db670606e3960b5fd84cb7c3.tar.gz redmine-03335d014ceb42d8db670606e3960b5fd84cb7c3.zip |
Restores support for :plugin support to stylesheet_link_tag and javascript_include_tag helpers.
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@9558 e93f8b46-1217-0410-a6f0-8f06a7374b81
Diffstat (limited to 'app')
-rw-r--r-- | app/helpers/application_helper.rb | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index 8310a4972..743bc34e3 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -1045,6 +1045,45 @@ module ApplicationHelper end end + # Overrides Rails' stylesheet_link_tag with themes and plugins support. + # Examples: + # stylesheet_link_tag('styles') # => picks styles.css from the current theme or defaults + # stylesheet_link_tag('styles', :plugin => 'foo) # => picks styles.css from plugin's assets + # + def stylesheet_link_tag(*sources) + options = sources.last.is_a?(Hash) ? sources.pop : {} + plugin = options.delete(:plugin) + sources = sources.map do |source| + if plugin + "/plugin_assets/#{plugin}/stylesheets/#{source}" + elsif current_theme && current_theme.stylesheets.include?(source) + current_theme.stylesheet_path(source) + else + source + end + end + super sources, options + end + + # Overrides Rails' javascript_include_tag with plugins support + # Examples: + # javascript_include_tag('scripts') # => picks scripts.js from defaults + # javascript_include_tag('scripts', :plugin => 'foo) # => picks scripts.js from plugin's assets + # + def javascript_include_tag(*sources) + options = sources.last.is_a?(Hash) ? sources.pop : {} + if plugin = options.delete(:plugin) + sources = sources.map do |source| + if plugin + "/plugin_assets/#{plugin}/javascripts/#{source}" + else + source + end + end + end + super sources, options + end + def content_for(name, content = nil, &block) @has_content ||= {} @has_content[name] = true |