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 /config | |
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
Diffstat (limited to 'config')
-rw-r--r-- | config/initializers/1_settings.rb | 10 |
1 files changed, 10 insertions, 0 deletions
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 |