Skip to content

Commit aa19644

Browse files
authored
Merge pull request #33 from aki360P/master
Redmine 5.0 compatible
2 parents 468d5f2 + 2cbd212 commit aa19644

9 files changed

+40
-63
lines changed

README.md

-17
Original file line numberDiff line numberDiff line change
@@ -20,23 +20,6 @@ rake redmine:plugins:migrate RAILS_ENV=production
2020
And restart your application server.
2121

2222

23-
## Compatibility
24-
25-
This current version on github is compatible with Redmine 2.1 - 4.2.
26-
27-
It has been imported from lp:redminelocalavatars
28-
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)
29-
30-
### Incompatibilities
31-
32-
As reported in [issue #12](https://github.com/ncoders/redmine_local_avatars/issues/12), the plugin "mega_calendar" ist not compatible with this plugin due to an issue with the provided users_controller_path.rb file.
33-
34-
### Old version on launchpad
35-
Tested on Redmine trunk r4388 (version 1.0.3). Should be compatible with
36-
all Redmine versions 1.0.x.
37-
38-
At the moment the plugin doesn't work when running in development mode.
39-
4023
## Authors
4124

4225
* A.Chaika wrote the original version:

init.rb

+10-23
Original file line numberDiff line numberDiff line change
@@ -23,34 +23,21 @@
2323
author 'Andrew Chaika and Luca Pireddu'
2424
author_url 'https://github.com/ncoders/redmine_local_avatars'
2525
description 'This plugin lets users upload avatars directly into Redmine'
26-
version '1.0.6'
26+
version '1.0.7'
27+
requires_redmine version_or_higher: '4.1'
2728
end
2829

2930
receiver = Object.const_defined?('ActiveSupport::Reloader') ? ActiveSupport::Reloader : ActionDispatch::Callbacks
30-
receiver.to_prepare do
31-
require_dependency 'project'
32-
require_dependency 'principal'
33-
require_dependency 'user'
3431

35-
helper_klass = ApplicationHelper.method_defined?(:avatar) ? ApplicationHelper : AvatarsHelper
36-
37-
AccountController.send(:include, LocalAvatarsPlugin::AccountControllerPatch)
38-
helper_klass.send(:include, LocalAvatarsPlugin::ApplicationAvatarPatch)
39-
MyController.send(:include, LocalAvatarsPlugin::MyControllerPatch)
40-
User.send(:include, LocalAvatarsPlugin::UsersAvatarPatch)
41-
UsersController.send(:include, LocalAvatarsPlugin::UsersControllerPatch)
42-
UsersHelper.send(:include, LocalAvatarsPlugin::UsersHelperPatch)
43-
end
44-
45-
require 'local_avatars'
32+
require File.expand_path('../lib/local_avatars', __FILE__)
4633

4734
# patches to Redmine
48-
require "account_controller_patch.rb"
49-
require "application_helper_avatar_patch.rb"
50-
require "my_controller_patch.rb"
51-
require "users_avatar_patch.rb" # User model
52-
require "users_controller_patch.rb"
53-
require "users_helper_avatar_patch.rb" # UsersHelper
35+
require File.expand_path('../lib/account_controller_patch', __FILE__)
36+
require File.expand_path('../lib/application_helper_avatar_patch', __FILE__)
37+
require File.expand_path('../lib/my_controller_patch', __FILE__)
38+
require File.expand_path('../lib/users_avatar_patch', __FILE__) # User model
39+
require File.expand_path('../lib/users_controller_patch', __FILE__)
40+
require File.expand_path('../lib/users_helper_avatar_patch', __FILE__) # UsersHelper
5441

5542
# hooks
56-
require 'redmine_local_avatars/hooks'
43+
require File.expand_path('../lib/redmine_local_avatars/hooks', __FILE__)

lib/account_controller_patch.rb

+5-3
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,9 @@
1616
# along with this program; if not, write to the Free Software
1717
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
1818

19-
require 'local_avatars'
2019

21-
module LocalAvatarsPlugin
20+
require File.expand_path('../local_avatars', __FILE__)
21+
2222
module AccountControllerPatch
2323

2424
def self.included(base) # :nodoc:
@@ -34,5 +34,7 @@ def get_avatar
3434
@user = User.find(params[:id])
3535
send_avatar(@user)
3636
end
37+
3738
end
38-
end
39+
40+
AccountController.include(AccountControllerPatch)

lib/application_helper_avatar_patch.rb

+8-5
Original file line numberDiff line numberDiff line change
@@ -16,28 +16,31 @@
1616
# along with this program; if not, write to the Free Software
1717
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
1818

19-
require 'local_avatars'
2019

21-
module LocalAvatarsPlugin
22-
module ApplicationAvatarPatch
20+
module ApplicationHelperAvatarPatch
21+
2322
def self.included(base) # :nodoc:
2423
base.class_eval do
2524
alias_method :avatar_without_local, :avatar
2625
alias_method :avatar, :avatar_with_local
2726
end
2827
end
2928

29+
3030
def avatar_with_local(user, options = { })
3131
if user.is_a?(User)then
3232
av = user.attachments.find_by_description 'avatar'
3333
if av then
3434
image_url = url_for :only_path => true, :controller => 'account', :action => 'get_avatar', :id => user
35-
options[:size] = "64" unless options[:size]
35+
options[:size] = "24" unless options[:size]
3636
title = "#{user.name}"
3737
return "<img class=\"gravatar\" title=\"#{title}\" width=\"#{options[:size]}\" height=\"#{options[:size]}\" src=\"#{image_url}\" />".html_safe
3838
end
3939
end
4040
avatar_without_local(user, options)
4141
end
42+
43+
4244
end
43-
end
45+
46+
AvatarsHelper.include(ApplicationHelperAvatarPatch)

lib/local_avatars.rb

+2-2
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
# along with this program; if not, write to the Free Software
1717
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
1818

19-
module LocalAvatarsPlugin
19+
2020
module LocalAvatars
2121
def send_avatar(user)
2222
av = user.attachments.find_by_description 'avatar'
@@ -49,4 +49,4 @@ def save_or_delete
4949
end
5050
end
5151
end
52-
end
52+

lib/my_controller_patch.rb

+3-3
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,8 @@
1616
# along with this program; if not, write to the Free Software
1717
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
1818

19-
require 'local_avatars'
19+
require File.expand_path('../local_avatars', __FILE__)
2020

21-
module LocalAvatarsPlugin
2221
module MyControllerPatch
2322
def self.included(base) # :nodoc:
2423
base.class_eval do
@@ -45,5 +44,6 @@ def save_avatar
4544
end
4645
end
4746
end
48-
end
4947

48+
49+
MyController.include(MyControllerPatch)

lib/users_avatar_patch.rb

+4-3
Original file line numberDiff line numberDiff line change
@@ -16,15 +16,16 @@
1616
# along with this program; if not, write to the Free Software
1717
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
1818

19-
require 'local_avatars'
2019

21-
module LocalAvatarsPlugin
20+
21+
2222
module UsersAvatarPatch
2323
def self.included(base) # :nodoc:
2424
base.class_eval do
2525
acts_as_attachable
2626
end
2727
end
2828
end
29-
end
3029

30+
31+
User.include(UsersAvatarPatch)

lib/users_controller_patch.rb

+3-3
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,9 @@
1616
# along with this program; if not, write to the Free Software
1717
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
1818

19-
require 'local_avatars'
2019

21-
module LocalAvatarsPlugin
20+
require File.expand_path('../local_avatars', __FILE__)
21+
2222
module UsersControllerPatch
2323

2424
def self.included(base) # :nodoc:
@@ -46,5 +46,5 @@ def save_avatar
4646
redirect_to :action => 'edit', :id => @user
4747
end
4848
end
49-
end
5049

50+
UsersController.include(UsersControllerPatch)

lib/users_helper_avatar_patch.rb

+5-4
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,10 @@
1616
# along with this program; if not, write to the Free Software
1717
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
1818

19-
require 'local_avatars'
2019

21-
module LocalAvatarsPlugin
22-
module UsersHelperPatch
20+
21+
22+
module UsersHelperAvatarPatch
2323
def self.included(base) # :nodoc:
2424
base.class_eval do
2525
alias_method :user_settings_tabs_without_avatar, :user_settings_tabs
@@ -32,5 +32,6 @@ def user_settings_tabs_with_avatar
3232
tabs << {:name => 'avatar', :partial => 'my/avatar', :label => :label_avatar}
3333
end
3434
end
35-
end
3635

36+
37+
UsersHelper.include(UsersHelperAvatarPatch)

0 commit comments

Comments
 (0)