From 03335d014ceb42d8db670606e3960b5fd84cb7c3 Mon Sep 17 00:00:00 2001 From: Jean-Philippe Lang Date: Sat, 28 Apr 2012 09:10:46 +0000 Subject: 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 --- app/helpers/application_helper.rb | 39 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) (limited to 'app') 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 -- cgit v1.2.3