From 16f74b62b98a978deb26167888d1881708a84268 Mon Sep 17 00:00:00 2001 From: Jqs7 <7@jqs7.com> Date: Mon, 10 Aug 2015 08:44:43 +0800 Subject: [PATCH] custom avatar source --- conf/app.ini | 3 ++- modules/setting/setting.go | 9 ++++++--- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/conf/app.ini b/conf/app.ini index 8710e3d01..3e6e615a5 100644 --- a/conf/app.ini +++ b/conf/app.ini @@ -198,6 +198,7 @@ SESSION_LIFE_TIME = 86400 SERVICE = server AVATAR_UPLOAD_PATH = data/avatars ; Chinese users can choose "duoshuo" +; or a custom avatar source, like: http://cn.gravatar.com/avatar/ GRAVATAR_SOURCE = gravatar DISABLE_GRAVATAR = false @@ -317,4 +318,4 @@ bg-BG = bg it-IT = it [other] -SHOW_FOOTER_BRANDING = false \ No newline at end of file +SHOW_FOOTER_BRANDING = false diff --git a/modules/setting/setting.go b/modules/setting/setting.go index 7f9d9908f..d32df4736 100644 --- a/modules/setting/setting.go +++ b/modules/setting/setting.go @@ -15,10 +15,11 @@ import ( "strings" "time" + "gopkg.in/ini.v1" + "github.com/Unknwon/com" "github.com/macaron-contrib/oauth2" "github.com/macaron-contrib/session" - "gopkg.in/ini.v1" "github.com/gogits/gogs/modules/bindata" "github.com/gogits/gogs/modules/log" @@ -345,11 +346,13 @@ func NewConfigContext() { if !filepath.IsAbs(AvatarUploadPath) { AvatarUploadPath = path.Join(workDir, AvatarUploadPath) } - switch sec.Key("GRAVATAR_SOURCE").MustString("gravatar") { + switch source := sec.Key("GRAVATAR_SOURCE").MustString("gravatar"); source { case "duoshuo": GravatarSource = "http://gravatar.duoshuo.com/avatar/" - default: + case "gravatar": GravatarSource = "//1.gravatar.com/avatar/" + default: + GravatarSource = source } DisableGravatar = sec.Key("DISABLE_GRAVATAR").MustBool() if OfflineMode {