Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
李少辉-开发者
gitlab-foss
提交
dcd002a1
G
gitlab-foss
项目概览
李少辉-开发者
/
gitlab-foss
通知
15
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
G
gitlab-foss
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
前往新版Gitcode,体验更适合开发者的 AI 搜索 >>
提交
dcd002a1
编写于
5月 26, 2017
作者:
D
Douwe Maan
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Add username parameter to gravatar URL
上级
bd259d6b
变更
6
隐藏空白更改
内联
并排
Showing
6 changed file
with
41 addition
and
12 deletion
+41
-12
app/models/user.rb
app/models/user.rb
+1
-1
app/services/gravatar_service.rb
app/services/gravatar_service.rb
+13
-8
changelogs/unreleased/dm-gravatar-username.yml
changelogs/unreleased/dm-gravatar-username.yml
+4
-0
config/gitlab.yml.example
config/gitlab.yml.example
+1
-1
doc/customization/libravatar.md
doc/customization/libravatar.md
+2
-2
spec/services/gravatar_service_spec.rb
spec/services/gravatar_service_spec.rb
+20
-0
未找到文件。
app/models/user.rb
浏览文件 @
dcd002a1
...
...
@@ -794,7 +794,7 @@ class User < ActiveRecord::Base
def
avatar_url
(
size:
nil
,
scale:
2
,
**
args
)
# We use avatar_path instead of overriding avatar_url because of carrierwave.
# See https://gitlab.com/gitlab-org/gitlab-ce/merge_requests/11001/diffs#note_28659864
avatar_path
(
args
)
||
GravatarService
.
new
.
execute
(
email
,
size
,
scale
)
avatar_path
(
args
)
||
GravatarService
.
new
.
execute
(
email
,
size
,
scale
,
username:
username
)
end
def
all_emails
...
...
app/services/gravatar_service.rb
浏览文件 @
dcd002a1
class
GravatarService
include
Gitlab
::
CurrentSettings
def
execute
(
email
,
size
=
nil
,
scale
=
2
)
if
current_application_settings
.
gravatar_enabled?
&&
email
.
present?
size
=
40
if
size
.
nil?
||
size
<=
0
def
execute
(
email
,
size
=
nil
,
scale
=
2
,
username:
nil
)
return
unless
current_application_settings
.
gravatar_enabled?
sprintf
gravatar_url
,
hash:
Digest
::
MD5
.
hexdigest
(
email
.
strip
.
downcase
),
size:
size
*
scale
,
email:
email
.
strip
end
identifier
=
email
.
presence
||
username
.
presence
return
unless
identifier
hash
=
Digest
::
MD5
.
hexdigest
(
identifier
.
strip
.
downcase
)
size
=
40
unless
size
&&
size
>
0
sprintf
gravatar_url
,
hash:
hash
,
size:
size
*
scale
,
email:
ERB
::
Util
.
url_encode
(
email
&
.
strip
||
''
),
username:
ERB
::
Util
.
url_encode
(
username
&
.
strip
||
''
)
end
def
gitlab_config
...
...
changelogs/unreleased/dm-gravatar-username.yml
0 → 100644
浏览文件 @
dcd002a1
---
title
:
Add username parameter to gravatar URL
merge_request
:
author
:
config/gitlab.yml.example
浏览文件 @
dcd002a1
...
...
@@ -169,7 +169,7 @@ production: &base
## Gravatar
## For Libravatar see: http://doc.gitlab.com/ce/customization/libravatar.html
gravatar:
# gravatar urls: possible placeholders: %{hash} %{size} %{email}
# gravatar urls: possible placeholders: %{hash} %{size} %{email}
%{username}
# plain_url: "http://..." # default: http://www.gravatar.com/avatar/%{hash}?s=%{size}&d=identicon
# ssl_url: "https://..." # default: https://secure.gravatar.com/avatar/%{hash}?s=%{size}&d=identicon
...
...
doc/customization/libravatar.md
浏览文件 @
dcd002a1
...
...
@@ -16,7 +16,7 @@ the configuration options as follows:
```
yml
gravatar
:
enabled
:
true
# gravatar URLs: possible placeholders: %{hash} %{size} %{email}
# gravatar URLs: possible placeholders: %{hash} %{size} %{email}
%{username}
plain_url
:
"
http://cdn.libravatar.org/avatar/%{hash}?s=%{size}&d=identicon"
```
...
...
@@ -25,7 +25,7 @@ the configuration options as follows:
```
yml
gravatar
:
enabled
:
true
# gravatar URLs: possible placeholders: %{hash} %{size} %{email}
# gravatar URLs: possible placeholders: %{hash} %{size} %{email}
%{username}
ssl_url
:
"
https://seccdn.libravatar.org/avatar/%{hash}?s=%{size}&d=identicon"
```
...
...
spec/services/gravatar_service_spec.rb
0 → 100644
浏览文件 @
dcd002a1
require
'spec_helper'
describe
GravatarService
,
service:
true
do
describe
'#execute'
do
let
(
:url
)
{
'http://example.com/avatar?hash=%{hash}&size=%{size}&email=%{email}&username=%{username}'
}
before
do
allow
(
Gitlab
.
config
.
gravatar
).
to
receive
(
:plain_url
).
and_return
(
url
)
end
it
'replaces the placeholders'
do
avatar_url
=
described_class
.
new
.
execute
(
'user@example.com'
,
100
,
2
,
username:
'user'
)
expect
(
avatar_url
).
to
include
(
"hash=
#{
Digest
::
MD5
.
hexdigest
(
'user@example.com'
)
}
"
)
expect
(
avatar_url
).
to
include
(
"size=200"
)
expect
(
avatar_url
).
to
include
(
"email=user%40example.com"
)
expect
(
avatar_url
).
to
include
(
"username=user"
)
end
end
end
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录