mirror of
https://github.com/go-gitea/gitea
synced 2024-12-24 17:44:27 +00:00
Merge pull request #716 from ErebusBat/master
Fix Gravatar images in web view (like commit listing)
This commit is contained in:
commit
298ebc58c1
@ -48,8 +48,12 @@ func init() {
|
|||||||
// hash email to md5 string
|
// hash email to md5 string
|
||||||
// keep this func in order to make this package indenpent
|
// keep this func in order to make this package indenpent
|
||||||
func HashEmail(email string) string {
|
func HashEmail(email string) string {
|
||||||
|
// https://en.gravatar.com/site/implement/hash/
|
||||||
|
email = strings.TrimSpace(email)
|
||||||
|
email = strings.ToLower(email)
|
||||||
|
|
||||||
h := md5.New()
|
h := md5.New()
|
||||||
h.Write([]byte(strings.ToLower(email)))
|
h.Write([]byte(email))
|
||||||
return hex.EncodeToString(h.Sum(nil))
|
return hex.EncodeToString(h.Sum(nil))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -23,6 +23,7 @@ import (
|
|||||||
"github.com/Unknwon/com"
|
"github.com/Unknwon/com"
|
||||||
"github.com/Unknwon/i18n"
|
"github.com/Unknwon/i18n"
|
||||||
|
|
||||||
|
"github.com/gogits/gogs/modules/avatar"
|
||||||
"github.com/gogits/gogs/modules/setting"
|
"github.com/gogits/gogs/modules/setting"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -177,10 +178,13 @@ func CreateTimeLimitCode(data string, minutes int, startInf interface{}) string
|
|||||||
func AvatarLink(email string) string {
|
func AvatarLink(email string) string {
|
||||||
if setting.DisableGravatar {
|
if setting.DisableGravatar {
|
||||||
return setting.AppSubUrl + "/img/avatar_default.jpg"
|
return setting.AppSubUrl + "/img/avatar_default.jpg"
|
||||||
} else if setting.Service.EnableCacheAvatar {
|
|
||||||
return setting.AppSubUrl + "/avatar/" + EncodeMd5(email)
|
|
||||||
}
|
}
|
||||||
return setting.GravatarSource + EncodeMd5(email)
|
|
||||||
|
gravatarHash := avatar.HashEmail(email)
|
||||||
|
if setting.Service.EnableCacheAvatar {
|
||||||
|
return setting.AppSubUrl + "/avatar/" + gravatarHash
|
||||||
|
}
|
||||||
|
return setting.GravatarSource + gravatarHash
|
||||||
}
|
}
|
||||||
|
|
||||||
// Seconds-based time units
|
// Seconds-based time units
|
||||||
|
Loading…
Reference in New Issue
Block a user