diff options
author | Chris Stephan <cstephan@squaremouth.com> | 2013-08-28 22:59:08 -0400 |
---|---|---|
committer | Chris Stephan <cstephan@squaremouth.com> | 2013-09-01 00:11:12 -0400 |
commit | 39e76e123c3023b93bb35d944e9c25c79c20714a (patch) | |
tree | cb435ff3850c6ab6bb362544d787cccf8cae1ab7 /app/helpers | |
parent | b4e7679174e9a1fe6b047e7571ddfadd148e7a78 (diff) | |
download | gitlab-ci-39e76e123c3023b93bb35d944e9c25c79c20714a.tar.gz |
Change gravatar_icon helper to handle ssl
This commit refactors the gravatar_icon helper method to handle ssl.
This is because when running gitlab-ci with ssl enabled, it gives a
warning because portions of the page are not secure. In addition to
refactoring this method, it also adds some configuration values to the
application.yml.example file that are needed for the gravatar_icon
helper method. It also adds default values for settings relating to
gitlab_ci and gravatar. This is because the values will need defaults
if they aren't specified in the application.yml. It also adds the
no_avatar.png since it is being used in the gravatar_icon helper
method. Finally, this commit adds spec tests to cover the
refactored method.
Diffstat (limited to 'app/helpers')
-rw-r--r-- | app/helpers/application_helper.rb | 16 |
1 files changed, 11 insertions, 5 deletions
diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index be1aa00..6be339e 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -3,12 +3,18 @@ module ApplicationHelper image_tag 'loader.gif' end - def gravatar_icon(user_email = '', size = 40) - gravatar_url = 'https://www.gravatar.com/avatar/%{hash}?s=%{size}&d=mm' - user_email.strip! - sprintf gravatar_url, hash: Digest::MD5.hexdigest(user_email.downcase), size: size - end + def gravatar_icon(user_email = '', size = nil) + size = 40 if size.nil? || size <= 0 + + if !GitlabCi.config.gravatar.enabled || user_email.blank? + 'no_avatar.png' + else + gravatar_url = request.ssl? || GitlabCi.config.gitlab_ci.https.enabled ? GitlabCi.config.gravatar.ssl_url : GitlabCi.config.gravatar.plain_url + user_email.strip! + sprintf gravatar_url, hash: Digest::MD5.hexdigest(user_email.downcase), size: size + end + end # Navigation link helper # # Returns an `li` element with an 'active' class if the supplied |