Defect #3935
closed
stylesheet_link_tag with plugin doesn't take into account relative_url_root
Added by Luca Pireddu about 15 years ago.
Updated about 14 years ago.
Description
When using the stylesheet_link_tag helper (and probably others) with :plugin to build URLs for plugin assets, this helper doesn't take into account the relative_url_root set through Redmine::Utils::relative_url_root
I think I've traced the problem to the method plugin_asset_path
in module Engines::RailsExtensions::AssetHelpers
, file vendor/plugins/engines/asset_helpers.rb
I guess that strictly speaking Engines is responsible for the bug and not Redmine. I'll leave it up to someone else to decide whether or not to resolve it in Redmine.
--- vendor/plugins/engines/lib/engines/rails_extensions/asset_helpers.rb~ 2010-08-02 17:40:47.000000000 +0200
+++ vendor/plugins/engines/lib/engines/rails_extensions/asset_helpers.rb 2010-08-02 17:40:47.000000000 +0200
@@ -109,7 +109,7 @@ module Engines::RailsExtensions::AssetHe
# Returns the publicly-addressable relative URI for the given asset, type and plugin
def self.plugin_asset_path(plugin_name, type, asset)
raise "No plugin called '#{plugin_name}' - please use the full name of a loaded plugin." if Engines.plugins[plugin_name].nil?
- "/#{Engines.plugins[plugin_name].public_asset_directory}/#{type}/#{asset}"
+ "#{ActionController::Base.relative_url_root}/#{Engines.plugins[plugin_name].public_asset_directory}/#{type}/#{asset}"
end
end
As a workaround, I used the following (more verbose) code (for example, in a hook):
class EventNotificationOverrideViewer < Redmine::Hook::ViewListener
def view_layouts_base_html_head(context = { })
javascript_include_tag "#{ActionController::Base.relative_url_root}/#{Engines.plugins['my_plugin'].public_asset_directory}/javascripts/somejs"
end
end
- Status changed from New to Resolved
- Target version set to 1.0.2
- Resolution set to Fixed
I have a fork of Engines now where I've added this fix to the plugin and also another fix that was floating around on Redmine. Fixed in r4094 for Redmine.
- Status changed from Resolved to Closed
Merged into 1.0-stable for release in 1.0.2
Also available in: Atom
PDF