diff options
author | Stan Hu <stanhu@gmail.com> | 2015-08-09 22:42:07 +0000 |
---|---|---|
committer | Stan Hu <stanhu@gmail.com> | 2015-08-09 22:42:07 +0000 |
commit | 1a3283d4e871c518d131eb3c9a82dce33f4609f8 (patch) | |
tree | 29ec6b67703c09894d8ea08e477eaaee29bc25ff | |
parent | b833f208f3a31a6ac964dac422141249f2278fd9 (diff) | |
parent | 0f785bbc7ecf932e81c84ec98636ffd305994b47 (diff) | |
download | gitlab-ce-1a3283d4e871c518d131eb3c9a82dce33f4609f8.tar.gz |
Merge branch 'gravatar-host-link' into 'master'
link to configured gravatar host on profile page
This MR updates the profile page to display the correct address for the configured gravatar service. Previously this always showed gravatar.com even if gravatar.com was not being used as the gravatar service.
See merge request !1093
-rw-r--r-- | CHANGELOG | 1 | ||||
-rw-r--r-- | app/views/profiles/show.html.haml | 4 | ||||
-rw-r--r-- | config/initializers/1_settings.rb | 10 | ||||
-rw-r--r-- | features/profile/profile.feature | 2 | ||||
-rw-r--r-- | features/steps/profile/profile.rb | 4 |
5 files changed, 19 insertions, 2 deletions
diff --git a/CHANGELOG b/CHANGELOG index 3a8fcb7b785..ebffc0d90ab 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -38,6 +38,7 @@ v 7.14.0 (unreleased) - Tweak project page buttons. - Disabled autocapitalize and autocorrect on login field (Daryl Chan) - Mention group and project name in creation, update and deletion notices (Achilleas Pipinellis) + - Update gravatar link on profile page to link to configured gravatar host (Ben Bodenmiller) - Remove redis-store TTL monkey patch - Add support for CI skipped status - Fetch code from forks to refs/merge-requests/:id/head when merge request created diff --git a/app/views/profiles/show.html.haml b/app/views/profiles/show.html.haml index 37a3952635e..9fdeddfcc7a 100644 --- a/app/views/profiles/show.html.haml +++ b/app/views/profiles/show.html.haml @@ -82,12 +82,12 @@ You can change your avatar here - if Gitlab.config.gravatar.enabled %br - or remove the current avatar to revert to #{link_to "gravatar.com", "http://gravatar.com"} + or remove the current avatar to revert to #{link_to Gitlab.config.gravatar.host, "http://" + Gitlab.config.gravatar.host} - else You can upload an avatar here - if Gitlab.config.gravatar.enabled %br - or change it at #{link_to "gravatar.com", "http://gravatar.com"} + or change it at #{link_to Gitlab.config.gravatar.host, "http://" + Gitlab.config.gravatar.host} %hr %a.choose-btn.btn.btn-sm.js-choose-user-avatar-button %i.fa.fa-paperclip diff --git a/config/initializers/1_settings.rb b/config/initializers/1_settings.rb index bd76c918485..026c1a5792c 100644 --- a/config/initializers/1_settings.rb +++ b/config/initializers/1_settings.rb @@ -8,6 +8,15 @@ class Settings < Settingslogic def gitlab_on_standard_port? gitlab.port.to_i == (gitlab.https ? 443 : 80) end + + # get host without www, thanks to http://stackoverflow.com/a/6674363/1233435 + def get_host_without_www(url) + url = URI.encode(url) + uri = URI.parse(url) + uri = URI.parse("http://#{url}") if uri.scheme.nil? + host = uri.host.downcase + host.start_with?('www.') ? host[4..-1] : host + end private @@ -147,6 +156,7 @@ Settings['gravatar'] ||= Settingslogic.new({}) Settings.gravatar['enabled'] = true if Settings.gravatar['enabled'].nil? Settings.gravatar['plain_url'] ||= 'http://www.gravatar.com/avatar/%{hash}?s=%{size}&d=identicon' Settings.gravatar['ssl_url'] ||= 'https://secure.gravatar.com/avatar/%{hash}?s=%{size}&d=identicon' +Settings.gravatar['host'] = Settings.get_host_without_www(Settings.gravatar['plain_url']) # # GitLab Shell diff --git a/features/profile/profile.feature b/features/profile/profile.feature index 7a1345f2b37..27c0bde364e 100644 --- a/features/profile/profile.feature +++ b/features/profile/profile.feature @@ -35,6 +35,7 @@ Feature: Profile Then I change my avatar And I should see new avatar And I should see the "Remove avatar" button + And I should see the gravatar host link Scenario: I remove my avatar Given I visit profile page @@ -42,6 +43,7 @@ Feature: Profile When I remove my avatar Then I should see my gravatar And I should not see the "Remove avatar" button + And I should see the gravatar host link Scenario: My password is expired Given my password is expired diff --git a/features/steps/profile/profile.rb b/features/steps/profile/profile.rb index 2b6b8b167f6..8cf24705a5e 100644 --- a/features/steps/profile/profile.rb +++ b/features/steps/profile/profile.rb @@ -59,6 +59,10 @@ class Spinach::Features::Profile < Spinach::FeatureSteps step 'I should not see the "Remove avatar" button' do expect(page).not_to have_link("Remove avatar") end + + step 'I should see the gravatar host link' do + expect(page).to have_link("gravatar.com") + end step 'I try change my password w/o old one' do page.within '.update-password' do |