From db52c350d5e2b3d21712e4c5622da7d641f19ea7 Mon Sep 17 00:00:00 2001 From: aki360P <34680805+aki360P@users.noreply.github.com> Date: Thu, 29 Jun 2023 15:52:02 +0900 Subject: [PATCH 1/3] Redmine5.0 compatible --- init.rb | 46 +++++++++++++------------- lib/account_controller_patch.rb | 8 +++-- lib/application_helper_avatar_patch.rb | 12 ++++--- lib/local_avatars.rb | 4 +-- lib/my_controller_patch.rb | 6 ++-- lib/users_avatar_patch.rb | 7 ++-- lib/users_controller_patch.rb | 6 ++-- lib/users_helper_avatar_patch.rb | 9 ++--- 8 files changed, 53 insertions(+), 45 deletions(-) diff --git a/init.rb b/init.rb index 0cedec9..4585919 100755 --- a/init.rb +++ b/init.rb @@ -23,34 +23,34 @@ 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.6' + version '1.0.7' end receiver = Object.const_defined?('ActiveSupport::Reloader') ? ActiveSupport::Reloader : ActionDispatch::Callbacks -receiver.to_prepare do - 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 +#receiver.to_prepare do +# 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' +require File.expand_path('../lib/local_avatars', __FILE__) # patches to Redmine -require "account_controller_patch.rb" -require "application_helper_avatar_patch.rb" -require "my_controller_patch.rb" -require "users_avatar_patch.rb" # User model -require "users_controller_patch.rb" -require "users_helper_avatar_patch.rb" # UsersHelper +require File.expand_path('../lib/account_controller_patch', __FILE__) +require File.expand_path('../lib/application_helper_avatar_patch', __FILE__) +require File.expand_path('../lib/my_controller_patch', __FILE__) +require File.expand_path('../lib/users_avatar_patch', __FILE__) # User model +require File.expand_path('../lib/users_controller_patch', __FILE__) +require File.expand_path('../lib/users_helper_avatar_patch', __FILE__) # UsersHelper # hooks -require 'redmine_local_avatars/hooks' +require File.expand_path('../lib/redmine_local_avatars/hooks', __FILE__) diff --git a/lib/account_controller_patch.rb b/lib/account_controller_patch.rb index 7c948b9..9ac8931 100644 --- a/lib/account_controller_patch.rb +++ b/lib/account_controller_patch.rb @@ -16,9 +16,9 @@ # along with this program; if not, write to the Free Software # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. -require 'local_avatars' -module LocalAvatarsPlugin +require File.expand_path('../local_avatars', __FILE__) + module AccountControllerPatch def self.included(base) # :nodoc: @@ -34,5 +34,7 @@ def get_avatar @user = User.find(params[:id]) send_avatar(@user) end + end -end + +AccountController.include(AccountControllerPatch) \ No newline at end of file diff --git a/lib/application_helper_avatar_patch.rb b/lib/application_helper_avatar_patch.rb index 0a954d0..7d81eda 100755 --- a/lib/application_helper_avatar_patch.rb +++ b/lib/application_helper_avatar_patch.rb @@ -16,10 +16,9 @@ # along with this program; if not, write to the Free Software # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. -require 'local_avatars' -module LocalAvatarsPlugin - module ApplicationAvatarPatch + module ApplicationHelperAvatarPatch + def self.included(base) # :nodoc: base.class_eval do alias_method :avatar_without_local, :avatar @@ -27,7 +26,9 @@ def self.included(base) # :nodoc: end end + def avatar_with_local(user, options = { }) + puts '--------' if user.is_a?(User)then av = user.attachments.find_by_description 'avatar' if av then @@ -39,5 +40,8 @@ def avatar_with_local(user, options = { }) end avatar_without_local(user, options) end + + end -end + +AvatarsHelper.include(ApplicationHelperAvatarPatch) \ No newline at end of file diff --git a/lib/local_avatars.rb b/lib/local_avatars.rb index 772b38f..8978558 100644 --- a/lib/local_avatars.rb +++ b/lib/local_avatars.rb @@ -16,7 +16,7 @@ # along with this program; if not, write to the Free Software # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. -module LocalAvatarsPlugin + module LocalAvatars def send_avatar(user) av = user.attachments.find_by_description 'avatar' @@ -49,4 +49,4 @@ def save_or_delete end end end -end + diff --git a/lib/my_controller_patch.rb b/lib/my_controller_patch.rb index 3c358b9..e781887 100644 --- a/lib/my_controller_patch.rb +++ b/lib/my_controller_patch.rb @@ -16,9 +16,8 @@ # along with this program; if not, write to the Free Software # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. -require 'local_avatars' +require File.expand_path('../local_avatars', __FILE__) -module LocalAvatarsPlugin module MyControllerPatch def self.included(base) # :nodoc: base.class_eval do @@ -45,5 +44,6 @@ def save_avatar end end end -end + +MyController.include(MyControllerPatch) \ No newline at end of file diff --git a/lib/users_avatar_patch.rb b/lib/users_avatar_patch.rb index b31c5e2..ae02762 100644 --- a/lib/users_avatar_patch.rb +++ b/lib/users_avatar_patch.rb @@ -16,9 +16,9 @@ # along with this program; if not, write to the Free Software # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. -require 'local_avatars' -module LocalAvatarsPlugin + + module UsersAvatarPatch def self.included(base) # :nodoc: base.class_eval do @@ -26,5 +26,6 @@ def self.included(base) # :nodoc: end end end -end + +User.include(UsersAvatarPatch) \ No newline at end of file diff --git a/lib/users_controller_patch.rb b/lib/users_controller_patch.rb index be8934c..2fab429 100644 --- a/lib/users_controller_patch.rb +++ b/lib/users_controller_patch.rb @@ -16,9 +16,9 @@ # along with this program; if not, write to the Free Software # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. -require 'local_avatars' -module LocalAvatarsPlugin +require File.expand_path('../local_avatars', __FILE__) + module UsersControllerPatch def self.included(base) # :nodoc: @@ -46,5 +46,5 @@ def save_avatar redirect_to :action => 'edit', :id => @user end end -end +UsersController.include(UsersControllerPatch) diff --git a/lib/users_helper_avatar_patch.rb b/lib/users_helper_avatar_patch.rb index 40291a1..d7acb4f 100755 --- a/lib/users_helper_avatar_patch.rb +++ b/lib/users_helper_avatar_patch.rb @@ -16,10 +16,10 @@ # along with this program; if not, write to the Free Software # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. -require 'local_avatars' -module LocalAvatarsPlugin - module UsersHelperPatch + + + module UsersHelperAvatarPatch def self.included(base) # :nodoc: base.class_eval do alias_method :user_settings_tabs_without_avatar, :user_settings_tabs @@ -32,5 +32,6 @@ def user_settings_tabs_with_avatar tabs << {:name => 'avatar', :partial => 'my/avatar', :label => :label_avatar} end end -end + +UsersHelper.include(UsersHelperAvatarPatch) \ No newline at end of file From 16dff02b4afd21a35971efec0e7e769cd19dcc04 Mon Sep 17 00:00:00 2001 From: aki360P <34680805+aki360P@users.noreply.github.com> Date: Sat, 8 Jul 2023 17:56:59 +0900 Subject: [PATCH 2/3] adjust picture size --- lib/application_helper_avatar_patch.rb | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/lib/application_helper_avatar_patch.rb b/lib/application_helper_avatar_patch.rb index 7d81eda..48295c4 100755 --- a/lib/application_helper_avatar_patch.rb +++ b/lib/application_helper_avatar_patch.rb @@ -28,12 +28,11 @@ def self.included(base) # :nodoc: def avatar_with_local(user, options = { }) - puts '--------' if user.is_a?(User)then av = user.attachments.find_by_description 'avatar' if av then image_url = url_for :only_path => true, :controller => 'account', :action => 'get_avatar', :id => user - options[:size] = "64" unless options[:size] + options[:size] = "24" unless options[:size] title = "#{user.name}" return "".html_safe end From 2cbd212fc3fa7baa280256f5841fec898d118037 Mon Sep 17 00:00:00 2001 From: aki360P <34680805+aki360P@users.noreply.github.com> Date: Sat, 8 Jul 2023 19:43:28 +0900 Subject: [PATCH 3/3] update Readme --- README.md | 17 ----------------- init.rb | 15 +-------------- 2 files changed, 1 insertion(+), 31 deletions(-) diff --git a/README.md b/README.md index fb2aedf..f3e7209 100644 --- a/README.md +++ b/README.md @@ -20,23 +20,6 @@ rake redmine:plugins:migrate RAILS_ENV=production And restart your application server. -## Compatibility - -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) - -### Incompatibilities - -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. - -### Old version on launchpad -Tested on Redmine trunk r4388 (version 1.0.3). Should be compatible with -all Redmine versions 1.0.x. - -At the moment the plugin doesn't work when running in development mode. - ## Authors * A.Chaika wrote the original version: diff --git a/init.rb b/init.rb index 4585919..295d2b4 100755 --- a/init.rb +++ b/init.rb @@ -24,23 +24,10 @@ author_url 'https://github.com/ncoders/redmine_local_avatars' description 'This plugin lets users upload avatars directly into Redmine' version '1.0.7' + requires_redmine version_or_higher: '4.1' end receiver = Object.const_defined?('ActiveSupport::Reloader') ? ActiveSupport::Reloader : ActionDispatch::Callbacks -#receiver.to_prepare do -# 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 File.expand_path('../lib/local_avatars', __FILE__)