Merge pull request #1457 from jqs7/customAvatar

add custom avatar source support
This commit is contained in:
无闻 2015-08-10 11:36:59 +08:00
commit 8f2a184e04
2 changed files with 8 additions and 4 deletions

View file

@ -198,6 +198,7 @@ SESSION_LIFE_TIME = 86400
SERVICE = server SERVICE = server
AVATAR_UPLOAD_PATH = data/avatars AVATAR_UPLOAD_PATH = data/avatars
; Chinese users can choose "duoshuo" ; Chinese users can choose "duoshuo"
; or a custom avatar source, like: http://cn.gravatar.com/avatar/
GRAVATAR_SOURCE = gravatar GRAVATAR_SOURCE = gravatar
DISABLE_GRAVATAR = false DISABLE_GRAVATAR = false

View file

@ -15,10 +15,11 @@ import (
"strings" "strings"
"time" "time"
"gopkg.in/ini.v1"
"github.com/Unknwon/com" "github.com/Unknwon/com"
"github.com/macaron-contrib/oauth2" "github.com/macaron-contrib/oauth2"
"github.com/macaron-contrib/session" "github.com/macaron-contrib/session"
"gopkg.in/ini.v1"
"github.com/gogits/gogs/modules/bindata" "github.com/gogits/gogs/modules/bindata"
"github.com/gogits/gogs/modules/log" "github.com/gogits/gogs/modules/log"
@ -345,11 +346,13 @@ func NewConfigContext() {
if !filepath.IsAbs(AvatarUploadPath) { if !filepath.IsAbs(AvatarUploadPath) {
AvatarUploadPath = path.Join(workDir, AvatarUploadPath) AvatarUploadPath = path.Join(workDir, AvatarUploadPath)
} }
switch sec.Key("GRAVATAR_SOURCE").MustString("gravatar") { switch source := sec.Key("GRAVATAR_SOURCE").MustString("gravatar"); source {
case "duoshuo": case "duoshuo":
GravatarSource = "http://gravatar.duoshuo.com/avatar/" GravatarSource = "http://gravatar.duoshuo.com/avatar/"
default: case "gravatar":
GravatarSource = "//1.gravatar.com/avatar/" GravatarSource = "//1.gravatar.com/avatar/"
default:
GravatarSource = source
} }
DisableGravatar = sec.Key("DISABLE_GRAVATAR").MustBool() DisableGravatar = sec.Key("DISABLE_GRAVATAR").MustBool()
if OfflineMode { if OfflineMode {