Commits

Antoni Segura Puimedon committed 14bdd15

Fixed name collision for hooks and added support for base_urls.

Comments (0)

Files changed (3)

 require 'redmine'
 require 'gravatar'
 require 'application_helper_gemavatar_patch.rb'
-require 'hooks'
+require 'gemavatar_hooks'
 
 Redmine::Plugin.register :redmine_gemavatar do
   name 'Ldap avatar plugin'

lib/application_helper_gemavatar_patch.rb

                 if Setting.gravatar_enabled?
                     options.merge!({:ssl => (defined?(request) && request.ssl?), :default => Setting.gravatar_default})
                     options[:size] = "64" unless options[:size]
-                    return "<img class=\"gravatar\" width=\"#{options[:size]}\" height=\"#{options[:size]}\" src=\"/gemavatar/show/#{user.id}\" />"
+                    base_url = Redmine::Utils.relative_url_root
+                    base_url = base_url + '/' if base_url[-1] != '/'
+                    return "<img class=\"gravatar\" width=\"#{options[:size]}\" height=\"#{options[:size]}\" src=\"#{base_url}gemavatar/show/#{user.id}\" />"
                 else
                     ''
                 end

lib/gemavatar_hooks.rb

+#    This file is part of Gemavatar.
+#
+#    Gemavatar is free software: you can redistribute it and/or modify
+#    it under the terms of the GNU General Public License as published by
+#    the Free Software Foundation, either version 3 of the License, or
+#    (at your option) any later version.
+#
+#    Gemavatar is distributed in the hope that it will be useful,
+#    but WITHOUT ANY WARRANTY; without even the implied warranty of
+#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+#    GNU General Public License for more details.
+#
+#    You should have received a copy of the GNU General Public License
+#    along with Gemavatar.  If not, see <http://www.gnu.org/licenses/>.
+
+module GemAvatarPlugin
+    class GemAvatarHooks < Redmine::Hook::ViewListener
+        render_on :view_my_account, :partial => 'hooks/reload'
+    end
+end