2 |
<%= l(:label_avatar)%>
3 |
4 | <%= avatar(@user, :size => "128") %>
5 |
6 | <%= form_tag( { :action => 'save_avatar', :id => @user.id }, :multipart => true) do %>
7 | <%= file_field_tag "avatar" %>
8 | <%= submit_tag l(:button_save) %>
9 | <%= submit_tag l(:button_delete), :confirm => l(:are_you_sure_delete_avatar) %>
10 | <% end %>
11 |
12 |
13 | <% html_title(l(:label_avatar)) -%>
14 |
--------------------------------------------------------------------------------
/app/views/my/avatar.html.erb:
--------------------------------------------------------------------------------
1 | <%= render :partial => 'avatar' %>
--------------------------------------------------------------------------------
/config/locales/bg.yml:
--------------------------------------------------------------------------------
1 | # Bulgarian translation by Ivan Cenov
2 | # https://bugs.launchpad.net/redminelocalavatars/+bug/887451
3 | bg:
4 | label_avatar: "Аватар"
5 | message_avatar_uploaded: "Аватарът е зареден успешно"
6 | button_change_avatar: "Промяна на локален аватар"
7 | are_you_sure_delete_avatar: "Сигурен ли сте, че искате да изтриете Вашия аватар?"
8 | avatar_deleted: "Аватарът е изтрит"
9 | unable_to_delete_avatar: "Грешка при опит за изтриване на аватара"
10 |
--------------------------------------------------------------------------------
/config/locales/de.yml:
--------------------------------------------------------------------------------
1 | # German translation by cforce
2 | # https://bugs.launchpad.net/redminelocalavatars/+bug/680548
3 |
4 | de:
5 | label_avatar: "Avatar"
6 | message_avatar_uploaded: "Avatar erfolgreich hochgeladen"
7 | button_change_avatar: "Avatar anpassen"
8 | are_you_sure_delete_avatar: "Wollen Sie den Avatar entfernen?"
9 | avatar_deleted: "Avatar entfernt."
10 | unable_to_delete_avatar: "Leider ist beim Löschen des Avatars ein Problem aufgetreten!"
11 |
--------------------------------------------------------------------------------
/config/locales/en.yml:
--------------------------------------------------------------------------------
1 | # English strings go here
2 | en:
3 | label_avatar: "Avatar"
4 | message_avatar_uploaded: "Avatar uploaded successfully"
5 | button_change_avatar: "Change local avatar"
6 | are_you_sure_delete_avatar: "Are you sure you want to delete your avatar?"
7 | avatar_deleted: "Avatar deleted"
8 | unable_to_delete_avatar: "Sorry. There was an error deleting the avatar"
9 |
--------------------------------------------------------------------------------
/config/locales/es.yml:
--------------------------------------------------------------------------------
1 | # Spanish strings go here
2 | # Courtesy of Anibal Avelar
3 | # https://bugs.launchpad.net/redminelocalavatars/+bug/716663
4 | es:
5 | label_avatar: "Avatar"
6 | message_avatar_uploaded: "Avatar descargado exitosamente"
7 | button_change_avatar: "Cambiar avatar"
8 | are_you_sure_delete_avatar: "¿Estas seguro que quieres borrar tu avatar?"
9 | avatar_deleted: "Avatar borrado"
10 | unable_to_delete_avatar: "Lo sentimos. Hubo un error borrando el avatar"
11 |
--------------------------------------------------------------------------------
/config/locales/fr.yml:
--------------------------------------------------------------------------------
1 | # French translation courtesy of luigifab
2 | # https://bugs.launchpad.net/redminelocalavatars/+bug/692969
3 | fr:
4 | label_avatar: "Avatar"
5 | message_avatar_uploaded: "Avatar enregistré"
6 | button_change_avatar: "Modifier l'avatar"
7 | are_you_sure_delete_avatar: "Êtes-vous certain de vouloir supprimer votre avatar?"
8 | avatar_deleted: "Avatar supprimé"
9 | unable_to_delete_avatar: "Une erreur est survenue lors de la suppression de l'avatar."
10 |
--------------------------------------------------------------------------------
/config/locales/it.yml:
--------------------------------------------------------------------------------
1 | # Italian strings go here
2 | it:
3 | label_avatar: Immagine
4 | message_avatar_uploaded: Immagine salvata
5 | button_change_avatar: Cambia la tua immagine
6 | are_you_sure_delete_avatar: "Sicuro di volere eliminare l'immagine?"
7 | avatar_deleted: Immagine eliminata
8 | unable_to_delete_avatar: "Mi dispiace. C'è stato un error eliminando l'immagine"
9 |
--------------------------------------------------------------------------------
/config/locales/ja.yml:
--------------------------------------------------------------------------------
1 | # Japanese strings go here
2 | ja:
3 | label_avatar: "アバター"
4 | message_avatar_uploaded: "アバターのアップロードに成功しました。"
5 | button_change_avatar: "アバターの変更"
6 | are_you_sure_delete_avatar: "アバターを削除してもよろしいですか?"
7 | avatar_deleted: "アバターは削除されました。"
8 | unable_to_delete_avatar: "アバターの削除中にエラーが発生しました。"
9 |
--------------------------------------------------------------------------------
/config/locales/pt-BR.yml:
--------------------------------------------------------------------------------
1 | # Portugues Brazil strings go here
2 | # Courtesy of Felipe Pinheiro
3 | pt-BR:
4 | label_avatar: "Avatar"
5 | message_avatar_uploaded: "Avatar carregado com sucesso"
6 | button_change_avatar: "Mude sua imagem de exibição."
7 | are_you_sure_delete_avatar: "Você tem certeza que deseja apagar seu avatar?"
8 | avatar_deleted: "Avatar apagado"
9 | unable_to_delete_avatar: "Desculpe. Houve um erro apagando o avatar."
10 |
--------------------------------------------------------------------------------
/config/locales/pt.yml:
--------------------------------------------------------------------------------
1 | # Portugues strings go here
2 | # Courtesy of Felipe Pinheiro
3 | pt:
4 | label_avatar: "Avatar"
5 | message_avatar_uploaded: "Avatar carregado com sucesso"
6 | button_change_avatar: "Mude sua imagem de exibição."
7 | are_you_sure_delete_avatar: "Você tem certeza que deseja apagar seu avatar?"
8 | avatar_deleted: "Avatar apagado"
9 | unable_to_delete_avatar: "Desculpe. Houve um erro apagando o avatar."
10 |
--------------------------------------------------------------------------------
/config/locales/ru.yml:
--------------------------------------------------------------------------------
1 | ru:
2 | label_avatar: "Фотография"
3 | message_avatar_uploaded: "Фотография загружена на сервер"
4 | button_change_avatar: "Изменить фотографию"
5 | are_you_sure_delete_avatar: "Вы действительно хотите удалить свою фотографию?"
6 | avatar_deleted: "Фотография удалена"
7 | unable_to_delete_avatar: "При удалении фотографии произошла ошибка"
8 |
--------------------------------------------------------------------------------
/config/locales/tr.yml:
--------------------------------------------------------------------------------
1 | # Turkish strings go here
2 | tr:
3 | label_avatar: "Avatar"
4 | message_avatar_uploaded: "Avatar yüklendi"
5 | button_change_avatar: "Avatarımı değiştir"
6 | are_you_sure_delete_avatar: "Avatarınızı silmek istediğinize emin misiniz?"
7 | avatar_deleted: "Avatar silindi"
8 | unable_to_delete_avatar: "Üzgünüm. Avatar silinirken bir hata oldu"
9 |
--------------------------------------------------------------------------------
/config/locales/zh-TW.yml:
--------------------------------------------------------------------------------
1 | # Simplified Chinese strings go here
2 | zh-TW:
3 | label_avatar: "頭像"
4 | message_avatar_uploaded: "成功上傳頭像"
5 | button_change_avatar: "更改頭像"
6 | are_you_sure_delete_avatar: "確定刪除頭像嗎?"
7 | avatar_deleted: "頭像已刪除"
8 | unable_to_delete_avatar: "對不起,刪除頭像發生錯誤"
9 |
--------------------------------------------------------------------------------
/config/locales/zh.yml:
--------------------------------------------------------------------------------
1 | # Simplified Chinese strings go here
2 | zh:
3 | label_avatar: "头像"
4 | message_avatar_uploaded: "成功上传头像"
5 | button_change_avatar: "更改头像"
6 | are_you_sure_delete_avatar: "确定删除头像吗?"
7 | avatar_deleted: "头像已删除"
8 | unable_to_delete_avatar: "对不起,删除头像发生错误"
9 |
--------------------------------------------------------------------------------
/config/routes.rb:
--------------------------------------------------------------------------------
1 | Rails.application.routes.draw do
2 | match 'my/avatar', :to => 'my#avatar', :via => [:get, :post]
3 | match 'my/save_avatar/:id', :to => 'my#save_avatar', :via => [:get, :post]
4 | match 'account/get_avatar/:id', :to => 'account#get_avatar', :constraints => {:id=>/\d+/}, :via => [:get, :post]
5 | match 'users/save_avatar/:id', :to => 'users#save_avatar', :constraints => {:id=>/\d+/}, :via => [:get, :post]
6 | match 'users/get_avatar/:id', :to => 'users#get_avatar', :constraints => {:id=>/\d+/}, :via => [:get, :post]
7 | end
8 |
--------------------------------------------------------------------------------
/init.rb:
--------------------------------------------------------------------------------
1 | # Redmine Local Avatars plugin
2 | #
3 | # Copyright (C) 2010 Andrew Chaika, Luca Pireddu
4 | #
5 | # This program is free software; you can redistribute it and/or
6 | # modify it under the terms of the GNU General Public License
7 | # as published by the Free Software Foundation; either version 2
8 | # of the License, or (at your option) any later version.
9 | #
10 | # This program is distributed in the hope that it will be useful,
11 | # but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 | # GNU General Public License for more details.
14 | #
15 | # You should have received a copy of the GNU General Public License
16 | # along with this program; if not, write to the Free Software
17 | # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
18 |
19 | require 'redmine'
20 |
21 | Redmine::Plugin.register :redmine_local_avatars do
22 | name 'Redmine Local Avatars plugin'
23 | author 'Andrew Chaika and Luca Pireddu'
24 | author_url 'https://github.com/ncoders/redmine_local_avatars'
25 | description 'This plugin lets users upload avatars directly into Redmine'
26 | version '1.0.7'
27 | requires_redmine version_or_higher: '4.1'
28 | end
29 |
30 | receiver = Object.const_defined?('ActiveSupport::Reloader') ? ActiveSupport::Reloader : ActionDispatch::Callbacks
31 |
32 | require File.expand_path('../lib/local_avatars', __FILE__)
33 |
34 | # patches to Redmine
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
41 |
42 | # hooks
43 | require File.expand_path('../lib/redmine_local_avatars/hooks', __FILE__)
44 |
--------------------------------------------------------------------------------
/lib/account_controller_patch.rb:
--------------------------------------------------------------------------------
1 | # Redmine Local Avatars plugin
2 | #
3 | # Copyright (C) 2010 Andrew Chaika, Luca Pireddu
4 | #
5 | # This program is free software; you can redistribute it and/or
6 | # modify it under the terms of the GNU General Public License
7 | # as published by the Free Software Foundation; either version 2
8 | # of the License, or (at your option) any later version.
9 | #
10 | # This program is distributed in the hope that it will be useful,
11 | # but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 | # GNU General Public License for more details.
14 | #
15 | # You should have received a copy of the GNU General Public License
16 | # along with this program; if not, write to the Free Software
17 | # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
18 |
19 |
20 | require File.expand_path('../local_avatars', __FILE__)
21 |
22 | module AccountControllerPatch
23 |
24 | def self.included(base) # :nodoc:
25 | base.class_eval do
26 | helper :attachments
27 | include AttachmentsHelper
28 | end
29 | end
30 |
31 | include LocalAvatars
32 |
33 | def get_avatar
34 | @user = User.find(params[:id])
35 | send_avatar(@user)
36 | end
37 |
38 | end
39 |
40 | AccountController.include(AccountControllerPatch)
--------------------------------------------------------------------------------
/lib/application_helper_avatar_patch.rb:
--------------------------------------------------------------------------------
1 | # Redmine Local Avatars plugin
2 | #
3 | # Copyright (C) 2010 Andrew Chaika, Luca Pireddu
4 | #
5 | # This program is free software; you can redistribute it and/or
6 | # modify it under the terms of the GNU General Public License
7 | # as published by the Free Software Foundation; either version 2
8 | # of the License, or (at your option) any later version.
9 | #
10 | # This program is distributed in the hope that it will be useful,
11 | # but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 | # GNU General Public License for more details.
14 | #
15 | # You should have received a copy of the GNU General Public License
16 | # along with this program; if not, write to the Free Software
17 | # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
18 |
19 |
20 | module ApplicationHelperAvatarPatch
21 |
22 | def self.included(base) # :nodoc:
23 | base.class_eval do
24 | alias_method :avatar_without_local, :avatar
25 | alias_method :avatar, :avatar_with_local
26 | end
27 | end
28 |
29 |
30 | def avatar_with_local(user, options = { })
31 | if user.is_a?(User)then
32 | av = user.attachments.find_by_description 'avatar'
33 | if av then
34 | image_url = url_for :only_path => true, :controller => 'account', :action => 'get_avatar', :id => user
35 | options[:size] = "24" unless options[:size]
36 | title = "#{user.name}"
37 | return "