Add disable gravatar option

tokarchuk/v1.17
Unknown 11 years ago
parent 3bd5fc6d6f
commit e7d8fadb08
  1. 1
      conf/app.ini
  2. 4
      models/user.go
  3. 3
      modules/base/conf.go
  4. 1
      routers/admin/admin.go
  5. 2
      templates/admin/config.tmpl

@ -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"

@ -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

@ -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()

@ -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

@ -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>

Loading…
Cancel
Save