Project

General

Profile

Actions

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.

Status:
Closed
Priority:
Normal
Assignee:
Category:
Plugin API
Target version:
Start date:
2009-09-28
Due date:
% Done:

0%

Estimated time:
Resolution:
Fixed
Affected version:

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.


Related issues

Has duplicate Redmine - Defect #5021: stylesheet_link_tag does not honor Redmine running out of a sub-uri if it is called from a pluginClosed2010-03-09

Actions
Has duplicate Redmine - Defect #3753: Plugin asset URLs not correctly generated for sub-URI deploymentsClosedEric Davis2009-08-18

Actions
Actions #1

Updated by Jérémie Delaitre over 14 years ago

This duplicates #5021

Actions #2

Updated by Daniel S over 14 years ago

--- 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
Actions #3

Updated by Nick Bolton over 14 years ago

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
Actions #4

Updated by Go MAEDA about 14 years ago

Daniel S's patch works fine with Redmine 1.0.1 (deployed in a subdirectory) and Projects Tree View plugin (http://github.com/MischaTheEvil/projects_tree_view).

I wish this issue would be fixed in 1.0.2.

Actions #5

Updated by Jérémie Delaitre about 14 years ago

I just tried Daniel S's patch on a bitnami stack (redmine 1.0.1) and the redmine_time_tracker plugin (http://github.com/delaitre/redmine_time_tracker (master branch)) and it works fine too.

Actions #6

Updated by Eric Davis about 14 years ago

  • 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.

Actions #7

Updated by Eric Davis about 14 years ago

  • Status changed from Resolved to Closed

Merged into 1.0-stable for release in 1.0.2

Actions

Also available in: Atom PDF