Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
1
Merge Requests
1
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
gitlab-ce
Commits
0aa7f79c
Commit
0aa7f79c
authored
Dec 07, 2012
by
Sergey Linnik
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
allow customize gravatar url
parent
2c37fa38
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
36 additions
and
2 deletions
+36
-2
app/helpers/application_helper.rb
app/helpers/application_helper.rb
+3
-2
config/gitlab.yml.example
config/gitlab.yml.example
+2
-0
config/initializers/1_settings.rb
config/initializers/1_settings.rb
+9
-0
spec/helpers/application_helper_spec.rb
spec/helpers/application_helper_spec.rb
+22
-0
No files found.
app/helpers/application_helper.rb
View file @
0aa7f79c
require
'digest/md5'
require
'uri'
module
ApplicationHelper
...
...
@@ -36,9 +37,9 @@ module ApplicationHelper
if
Gitlab
.
config
.
disable_gravatar?
||
user_email
.
blank?
'no_avatar.png'
else
gravatar_
prefix
=
request
.
ssl?
?
"https://secure"
:
"http://www"
gravatar_
url
=
request
.
ssl?
?
Gitlab
.
config
.
gravatar_ssl_url
:
Gitlab
.
config
.
gravatar_url
user_email
.
strip!
"
#{
gravatar_prefix
}
.gravatar.com/avatar/
#{
Digest
::
MD5
.
hexdigest
(
user_email
.
downcase
)
}
?s=
#{
size
}
&d=mm"
sprintf
(
gravatar_url
,
{
:hash
=>
Digest
::
MD5
.
hexdigest
(
user_email
.
downcase
),
:email
=>
URI
.
escape
(
user_email
),
:size
=>
size
})
end
end
...
...
config/gitlab.yml.example
View file @
0aa7f79c
...
...
@@ -24,6 +24,8 @@ app:
# backup_path: "/vol/backups" # default: Rails.root + backups/
# backup_keep_time: 604800 # default: 0 (forever) (in seconds)
# disable_gravatar: true # default: false - Disable user avatars from Gravatar.com
# gravatar_url: "http://" # default: http://www.gravatar.com/avatar/%{hash}?s=%{size}&d=mm
# gravatar_ssl_url: "https://" # default: https://secure.gravatar.com/avatar/%{hash}?s=%{size}&d=mm
#
...
...
config/initializers/1_settings.rb
View file @
0aa7f79c
...
...
@@ -145,5 +145,14 @@ class Settings < Settingslogic
def
disable_gravatar?
app
[
'disable_gravatar'
]
||
false
end
def
gravatar_url
app
[
'gravatar_url'
]
||
'http://www.gravatar.com/avatar/%{hash}?s=%{size}&d=mm'
end
def
gravatar_ssl_url
app
[
'gravatar_ssl_url'
]
||
'https://secure.gravatar.com/avatar/%{hash}?s=%{size}&d=mm'
end
end
end
spec/helpers/application_helper_spec.rb
View file @
0aa7f79c
...
...
@@ -51,14 +51,36 @@ describe ApplicationHelper do
gravatar_icon
(
''
).
should
==
'no_avatar.png'
end
it
"should return default gravatar url"
do
stub!
(
:request
).
and_return
(
double
(
:ssl?
=>
false
))
gravatar_icon
(
user_email
).
should
match
(
'http://www.gravatar.com/avatar/b58c6f14d292556214bd64909bcdb118'
)
end
it
"should use SSL when appropriate"
do
stub!
(
:request
).
and_return
(
double
(
:ssl?
=>
true
))
gravatar_icon
(
user_email
).
should
match
(
'https://secure.gravatar.com'
)
end
it
"should return custom gravatar path when gravatar_url is set"
do
stub!
(
:request
).
and_return
(
double
(
:ssl?
=>
false
))
Gitlab
.
config
.
stub
(
:gravatar_url
).
and_return
(
'http://example.local/?s=%{size}&hash=%{hash}'
)
gravatar_icon
(
user_email
,
20
).
should
==
'http://example.local/?s=20&hash=b58c6f14d292556214bd64909bcdb118'
end
it
"should accept a custom size"
do
stub!
(
:request
).
and_return
(
double
(
:ssl?
=>
false
))
gravatar_icon
(
user_email
,
64
).
should
match
(
/\?s=64/
)
end
it
"should use default size when size is wrong"
do
stub!
(
:request
).
and_return
(
double
(
:ssl?
=>
false
))
gravatar_icon
(
user_email
,
nil
).
should
match
(
/\?s=40/
)
end
it
"should be case insensitive"
do
stub!
(
:request
).
and_return
(
double
(
:ssl?
=>
false
))
gravatar_icon
(
user_email
).
should
==
gravatar_icon
(
user_email
.
upcase
+
" "
)
end
end
end
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment