Add disable gravatar option

This commit is contained in:
Unknown 2014-05-01 21:30:04 -04:00
parent 3bd5fc6d6f
commit e7d8fadb08
5 changed files with 11 additions and 2 deletions

View File

@ -166,6 +166,7 @@ SESSION_ID_HASHKEY =
[picture] [picture]
; The place to picture data, either "server" or "qiniu", default is "server" ; The place to picture data, either "server" or "qiniu", default is "server"
SERVICE = server SERVICE = server
DISABLE_GRAVATAR = false
[log] [log]
; Either "console", "file", "conn", "smtp" or "database", default is "console" ; Either "console", "file", "conn", "smtp" or "database", default is "console"

View File

@ -74,7 +74,9 @@ func (user *User) HomeLink() string {
// AvatarLink returns the user gravatar link. // AvatarLink returns the user gravatar link.
func (user *User) AvatarLink() string { 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 "/avatar/" + user.Avatar
} }
return "//1.gravatar.com/avatar/" + user.Avatar return "//1.gravatar.com/avatar/" + user.Avatar

View File

@ -81,6 +81,7 @@ var (
SessionManager *session.Manager SessionManager *session.Manager
PictureService string PictureService string
DisableGravatar bool
EnableRedis bool EnableRedis bool
EnableMemcache bool EnableMemcache bool
@ -345,7 +346,9 @@ func NewConfigContext() {
LogInRememberDays = Cfg.MustInt("security", "LOGIN_REMEMBER_DAYS") LogInRememberDays = Cfg.MustInt("security", "LOGIN_REMEMBER_DAYS")
CookieUserName = Cfg.MustValue("security", "COOKIE_USERNAME") CookieUserName = Cfg.MustValue("security", "COOKIE_USERNAME")
CookieRememberName = Cfg.MustValue("security", "COOKIE_REMEMBER_NAME") CookieRememberName = Cfg.MustValue("security", "COOKIE_REMEMBER_NAME")
PictureService = Cfg.MustValue("picture", "SERVICE") PictureService = Cfg.MustValue("picture", "SERVICE")
DisableGravatar = Cfg.MustBool("picture", "DISABLE_GRAVATAR", false)
// Determine and create root git reposiroty path. // Determine and create root git reposiroty path.
homeDir, err := com.HomeDir() homeDir, err := com.HomeDir()

View File

@ -169,6 +169,7 @@ func Config(ctx *middleware.Context) {
ctx.Data["SessionConfig"] = base.SessionConfig ctx.Data["SessionConfig"] = base.SessionConfig
ctx.Data["PictureService"] = base.PictureService ctx.Data["PictureService"] = base.PictureService
ctx.Data["DisableGravatar"] = base.DisableGravatar
ctx.Data["LogMode"] = base.LogMode ctx.Data["LogMode"] = base.LogMode
ctx.Data["LogConfig"] = base.LogConfig ctx.Data["LogConfig"] = base.LogConfig

View File

@ -181,6 +181,8 @@
<dl class="dl-horizontal admin-dl-horizontal"> <dl class="dl-horizontal admin-dl-horizontal">
<dt>Picture Service</dt> <dt>Picture Service</dt>
<dd>{{.PictureService}}</dd> <dd>{{.PictureService}}</dd>
<dt>Disable Gravatar</dt>
<dd><i class="fa fa{{if .DisableGravatar}}-check{{end}}-square-o"></i></dd>
</dl> </dl>
</div> </div>
</div> </div>