summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--conf/app.ini1
-rw-r--r--models/user.go4
-rw-r--r--modules/base/conf.go5
-rw-r--r--routers/admin/admin.go1
-rw-r--r--templates/admin/config.tmpl2
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 @@
<dl class="dl-horizontal admin-dl-horizontal">
<dt>Picture Service</dt>
<dd>{{.PictureService}}</dd>
+ <dt>Disable Gravatar</dt>
+ <dd><i class="fa fa{{if .DisableGravatar}}-check{{end}}-square-o"></i></dd>
</dl>
</div>
</div>