From e7d8fadb083451c632af43de862eab88adb5b29a Mon Sep 17 00:00:00 2001 From: Unknown Date: Thu, 1 May 2014 21:30:04 -0400 Subject: [PATCH] Add disable gravatar option --- conf/app.ini | 1 + models/user.go | 4 +++- modules/base/conf.go | 5 ++++- routers/admin/admin.go | 1 + templates/admin/config.tmpl | 2 ++ 5 files changed, 11 insertions(+), 2 deletions(-) diff --git a/conf/app.ini b/conf/app.ini index 789f357fa9..77b8086113 100644 --- a/conf/app.ini +++ b/conf/app.ini @@ -166,6 +166,7 @@ SESSION_ID_HASHKEY = [picture] ; The place to picture data, either "server" or "qiniu", default is "server" SERVICE = server +DISABLE_GRAVATAR = false [log] ; Either "console", "file", "conn", "smtp" or "database", default is "console" diff --git a/models/user.go b/models/user.go index e340eed441..27140cf1c1 100644 --- a/models/user.go +++ b/models/user.go @@ -74,7 +74,9 @@ func (user *User) HomeLink() string { // AvatarLink returns the user gravatar link. func (user *User) AvatarLink() string { - if base.Service.EnableCacheAvatar { + if base.DisableGravatar { + return "/img/avatar_default.jpg" + } else if base.Service.EnableCacheAvatar { return "/avatar/" + user.Avatar } return "//1.gravatar.com/avatar/" + user.Avatar diff --git a/modules/base/conf.go b/modules/base/conf.go index eab83d20af..126fd63d2e 100644 --- a/modules/base/conf.go +++ b/modules/base/conf.go @@ -80,7 +80,8 @@ var ( SessionConfig *session.Config SessionManager *session.Manager - PictureService string + PictureService string + DisableGravatar bool EnableRedis bool EnableMemcache bool @@ -345,7 +346,9 @@ func NewConfigContext() { LogInRememberDays = Cfg.MustInt("security", "LOGIN_REMEMBER_DAYS") CookieUserName = Cfg.MustValue("security", "COOKIE_USERNAME") CookieRememberName = Cfg.MustValue("security", "COOKIE_REMEMBER_NAME") + PictureService = Cfg.MustValue("picture", "SERVICE") + DisableGravatar = Cfg.MustBool("picture", "DISABLE_GRAVATAR", false) // Determine and create root git reposiroty path. homeDir, err := com.HomeDir() diff --git a/routers/admin/admin.go b/routers/admin/admin.go index 14128c8c2b..2d5bdaff27 100644 --- a/routers/admin/admin.go +++ b/routers/admin/admin.go @@ -169,6 +169,7 @@ func Config(ctx *middleware.Context) { ctx.Data["SessionConfig"] = base.SessionConfig ctx.Data["PictureService"] = base.PictureService + ctx.Data["DisableGravatar"] = base.DisableGravatar ctx.Data["LogMode"] = base.LogMode ctx.Data["LogConfig"] = base.LogConfig diff --git a/templates/admin/config.tmpl b/templates/admin/config.tmpl index 08a68ae10e..8ba6b60cd5 100644 --- a/templates/admin/config.tmpl +++ b/templates/admin/config.tmpl @@ -181,6 +181,8 @@
Picture Service
{{.PictureService}}
+
Disable Gravatar
+