ogom / redmine_sidekiq

Sidekiq plugin for Redmine
21 stars 29 forks source link

Top menu link is broken for installations into a sub directory #5

Closed niosHD closed 10 years ago

niosHD commented 10 years ago

I just installed you plugin to use it with the redmine_git_hosting plugin [1] and found a small problem.

My redmine is installed into a subdirectory (mydomain.org/redmine). The sidekiq link in the top menu points now to mydomain.org/sidekiq instead of mydomain.org/redmine/sidekiq.

The correct host name and path is set in the general redmine settings but it seems like this is not honored. Any chance that this can be easily fixed? Anyway, thanks for the plugin and your work!

Regards, niosHD

[1] https://github.com/jbox-web/redmine_git_hosting

ogom commented 10 years ago

Your problem is solved by changing path?

diff --git a/config/routes.rb b/config/routes.rb
-  mount Sidekiq::Web => '/sidekiq', :constraints => RedmineSidekiq::AdminConstraint.new
+  mount Sidekiq::Web => '/redmine/sidekiq', :constraints => RedmineSidekiq::AdminConstraint.new

diff --git a/init.rb b/init.rb
-  menu :top_menu, :sidekiq, '/sidekiq', :if => Proc.new {User.current.admin}
+  menu :top_menu, :sidekiq, '/redmine/sidekiq', :if => Proc.new {User.current.admin}
niosHD commented 10 years ago

Hi! Yes the problem is solved when I change the path. It is actually enough to change the path in the init.rb file. The routing already works without the change.

I did some research and it looks to me like passenger sets the a environment variable (ENV['RAILS_RELATIVE_URL_ROOT']) when a rails project is deployed to a subdirectory. I haven't checked it though. Rails seems to honor this variable and routes everything correctly.

The only problem is that the link itself is not translated to this subdirectory. I already searched quite a bit for some helper method which could be used for this translation but was unsuccessful so far. My rails knowledge is simply not comprehensive enough...

It is actually not a big deal and I can stick with the simple patch you proposed. It would just be nicer to have a generic solution which abstracts such deploy specifics.