Feature #9112 » avatar_service_url_configuration-v4.patch
app/helpers/application_helper.rb | ||
---|---|---|
1507 | 1507 |
# Returns a link to edit user's avatar if avatars are enabled |
1508 | 1508 |
def avatar_edit_link(user, options={}) |
1509 | 1509 |
if Setting.gravatar_enabled? |
1510 |
url = "https://gravatar.com"
|
|
1510 |
url = Redmine::Configuration['avatar_server_url']
|
|
1511 | 1511 |
link_to avatar(user, {:title => l(:button_edit)}.merge(options)), url, :target => '_blank' |
1512 | 1512 |
end |
1513 | 1513 |
end |
app/views/settings/_display.html.erb | ||
---|---|---|
19 | 19 | |
20 | 20 |
<p><%= setting_select :user_format, @options[:user_format] %></p> |
21 | 21 | |
22 |
<p><%= setting_check_box :gravatar_enabled, :data => {:enables => '#settings_gravatar_default'} %></p> |
|
22 |
<p><%= setting_check_box :gravatar_enabled, :data => {:enables => '#settings_gravatar_default'} %> |
|
23 |
<em class="info"><%= t(:text_avatar_server_config_html, :url => Redmine::Configuration['avatar_server_url']) %></em></p> |
|
23 | 24 | |
24 | 25 |
<p><%= setting_select :gravatar_default, gravatar_default_setting_options, :blank => :label_none %></p> |
25 | 26 |
config/configuration.yml.example | ||
---|---|---|
209 | 209 |
# allowed values: :memory, :file, :memcache |
210 | 210 |
#openid_authentication_store: :memory |
211 | 211 | |
212 |
# URL of the avatar service |
|
213 |
# |
|
214 |
# By default, Redmine uses Gravatar as the avatar service for displaying |
|
215 |
# the user's icon. You can swich to another Gravatar-compatible service |
|
216 |
# such as Libravatar. |
|
217 |
# |
|
218 |
# URL of each avatar is: #{avatar_server_url}/avatar/#{hash} |
|
219 |
# |
|
220 |
# Examples: |
|
221 |
# avatar_server_url: https://www.gravatar.com # default |
|
222 |
# avatar_server_url: https://seccdn.libravatar.org |
|
223 |
avatar_server_url: |
|
224 | ||
212 | 225 |
# specific configuration options for production environment |
213 | 226 |
# that overrides the default ones |
214 | 227 |
production: |
config/locales/en.yml | ||
---|---|---|
1202 | 1202 |
text_project_closed: This project is closed and read-only. |
1203 | 1203 |
text_turning_multiple_off: "If you disable multiple values, multiple values will be removed in order to preserve only one value per item." |
1204 | 1204 |
text_select_apply_tracker: "Select tracker" |
1205 |
text_avatar_server_config_html: The current avatar server is <a href="%{url}">%{url}</a>. You can configure it in config/configuration.yml. |
|
1206 | ||
1205 | 1207 | |
1206 | 1208 |
default_role_manager: Manager |
1207 | 1209 |
default_role_developer: Developer |
lib/plugins/gravatar/lib/gravatar.rb | ||
---|---|---|
63 | 63 | |
64 | 64 |
# Returns the base Gravatar URL for the given email hash |
65 | 65 |
def gravatar_api_url(hash) |
66 |
'https://www.gravatar.com/avatar/' + hash.to_s
|
|
66 |
+"#{Redmine::Configuration['avatar_server_url']}/avatar/#{hash}"
|
|
67 | 67 |
end |
68 | 68 | |
69 | 69 |
# Return the gravatar URL for the given email address. |
lib/redmine/configuration.rb | ||
---|---|---|
22 | 22 | |
23 | 23 |
# Configuration default values |
24 | 24 |
@defaults = { |
25 |
'avatar_server_url' => 'https://www.gravatar.com', |
|
25 | 26 |
'email_delivery' => nil, |
26 | 27 |
'max_concurrent_ajax_uploads' => 2 |
27 | 28 |
} |
test/functional/my_controller_test.rb | ||
---|---|---|
365 | 365 | |
366 | 366 |
def test_my_account_with_avatar_enabled_should_link_to_edit_avatar |
367 | 367 |
with_settings :gravatar_enabled => '1' do |
368 |
get :account |
|
369 |
assert_response :success |
|
370 |
assert_select 'a[href=?] img.gravatar', 'https://gravatar.com' |
|
368 |
Redmine::Configuration.with 'avatar_server_url' => 'https://gravatar.com' do |
|
369 |
get :account |
|
370 |
assert_response :success |
|
371 |
assert_select 'a[href=?] img.gravatar', 'https://gravatar.com' |
|
372 |
end |
|
371 | 373 |
end |
372 | 374 |
end |
373 | 375 |
test/helpers/application_helper_test.rb | ||
---|---|---|
1529 | 1529 |
end |
1530 | 1530 |
end |
1531 | 1531 | |
1532 |
def test_avatar_server_url |
|
1533 |
to_test = { |
|
1534 |
'https://www.gravatar.com' => %r|https://www.gravatar.com/avatar/\h{32}|, |
|
1535 |
'https://seccdn.libravatar.org' => %r|https://seccdn.libravatar.org/avatar/\h{32}|, |
|
1536 |
'http://localhost:8080' => %r|http://localhost:8080/avatar/\h{32}|, |
|
1537 |
} |
|
1538 |
with_settings :gravatar_enabled => '1' do |
|
1539 |
to_test.each do |url, expected| |
|
1540 |
Redmine::Configuration.with 'avatar_server_url' => url do |
|
1541 |
assert_match expected, avatar('<jsmith@somenet.foo>') |
|
1542 |
end |
|
1543 |
end |
|
1544 |
end |
|
1545 |
end |
|
1546 | ||
1532 | 1547 |
def test_link_to_user |
1533 | 1548 |
user = User.find(2) |
1534 | 1549 |
result = link_to("John Smith", "/users/2", :class => "user active") |
- « Previous
- 1
- …
- 3
- 4
- 5
- Next »