Skip to content

Commit

Permalink
Merge pull request #28 from ncoders/redmine-4.2-compatibility
Browse files Browse the repository at this point in the history
Redmine 4.2 compatibility
  • Loading branch information
dup2 authored Jan 19, 2022
2 parents 3ca713e + a7ab591 commit 468d5f2
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 13 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ And restart your application server.

## Compatibility

This current version on github is compatible with Redmine 2.1 - 4.0.
This current version on github is compatible with Redmine 2.1 - 4.2.

It has been imported from lp:redminelocalavatars
incorporating the patch for 2.1 from chrisy at [https://bugs.launchpad.net/redminelocalavatars/+bug/1069808/comments/4](https://bugs.launchpad.net/redminelocalavatars/+bug/1069808/comments/4)
Expand Down
25 changes: 14 additions & 11 deletions init.rb
Original file line number Diff line number Diff line change
Expand Up @@ -21,22 +21,25 @@
Redmine::Plugin.register :redmine_local_avatars do
name 'Redmine Local Avatars plugin'
author 'Andrew Chaika and Luca Pireddu'
author_url 'https://github.com/ncoders/redmine_local_avatars'
description 'This plugin lets users upload avatars directly into Redmine'
version '1.0.5'
version '1.0.6'
end

receiver = Object.const_defined?('ActiveSupport::Reloader') ? ActiveSupport::Reloader : ActionDispatch::Callbacks
receiver.to_prepare do
require_dependency 'project'
require_dependency 'principal'
require_dependency 'user'

AccountController.send(:include, LocalAvatarsPlugin::AccountControllerPatch)
ApplicationHelper.send(:include, LocalAvatarsPlugin::ApplicationAvatarPatch)
MyController.send(:include, LocalAvatarsPlugin::MyControllerPatch)
User.send(:include, LocalAvatarsPlugin::UsersAvatarPatch)
UsersController.send(:include, LocalAvatarsPlugin::UsersControllerPatch)
UsersHelper.send(:include, LocalAvatarsPlugin::UsersHelperPatch)
require_dependency 'project'
require_dependency 'principal'
require_dependency 'user'

helper_klass = ApplicationHelper.method_defined?(:avatar) ? ApplicationHelper : AvatarsHelper

AccountController.send(:include, LocalAvatarsPlugin::AccountControllerPatch)
helper_klass.send(:include, LocalAvatarsPlugin::ApplicationAvatarPatch)
MyController.send(:include, LocalAvatarsPlugin::MyControllerPatch)
User.send(:include, LocalAvatarsPlugin::UsersAvatarPatch)
UsersController.send(:include, LocalAvatarsPlugin::UsersControllerPatch)
UsersHelper.send(:include, LocalAvatarsPlugin::UsersHelperPatch)
end

require 'local_avatars'
Expand Down
3 changes: 2 additions & 1 deletion lib/application_helper_avatar_patch.rb
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,8 @@ def avatar_with_local(user, options = { })
if av then
image_url = url_for :only_path => true, :controller => 'account', :action => 'get_avatar', :id => user
options[:size] = "64" unless options[:size]
return "<img class=\"gravatar\" width=\"#{options[:size]}\" height=\"#{options[:size]}\" src=\"#{image_url}\" />".html_safe
title = "#{user.name}"
return "<img class=\"gravatar\" title=\"#{title}\" width=\"#{options[:size]}\" height=\"#{options[:size]}\" src=\"#{image_url}\" />".html_safe
end
end
avatar_without_local(user, options)
Expand Down

0 comments on commit 468d5f2

Please # to comment.