]> source.dussan.org Git - gitea.git/commitdiff
Add disable gravatar option
authorUnknown <joe2010xtmf@163.com>
Fri, 2 May 2014 01:30:04 +0000 (21:30 -0400)
committerUnknown <joe2010xtmf@163.com>
Fri, 2 May 2014 01:30:04 +0000 (21:30 -0400)
conf/app.ini
models/user.go
modules/base/conf.go
routers/admin/admin.go
templates/admin/config.tmpl

index 789f357fa9587254db171630f05fb022315ac935..77b808611393862d5fff0d0d6b65fc8bb35326f3 100644 (file)
@@ -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"
index e340eed441f2ab2fdbe86a293f74665b1c6ada63..27140cf1c1d5d018ff0792161e331fe0cc8d116f 100644 (file)
@@ -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
index eab83d20af3af1351095c6a135b27a6df7500c96..126fd63d2ef9ee853552ccc0c994eef2f3598726 100644 (file)
@@ -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()
index 14128c8c2b0e47f88dea4c461065fc7cd2d71d1b..2d5bdaff275a9e3ba24120be1a231d3cbb80636c 100644 (file)
@@ -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
index 08a68ae10ef654ca1fc6fab8f1128118cac1e224..8ba6b60cd51fb8f5ed7f5e7f2c45f4b03ebadd98 100644 (file)
                 <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>