diff options
author | Unknwon <u@gogs.io> | 2015-03-24 18:38:12 -0400 |
---|---|---|
committer | Unknwon <u@gogs.io> | 2015-03-24 18:38:12 -0400 |
commit | caf7618ea6771823e4954941ebf9d6227c4f48df (patch) | |
tree | 22565d43ad51664e7b7935cd46cfc1801f02fc2d | |
parent | 6f81c05dde2def51c30a97f65f901ae45c971e05 (diff) | |
download | gitea-caf7618ea6771823e4954941ebf9d6227c4f48df.tar.gz gitea-caf7618ea6771823e4954941ebf9d6227c4f48df.zip |
#1098 Hide gravatar email field if gravatar is disabled (or offline mode)
-rw-r--r-- | modules/base/template.go | 3 | ||||
-rw-r--r-- | modules/setting/setting.go | 3 | ||||
-rw-r--r-- | templates/org/settings/options.tmpl | 2 | ||||
-rw-r--r-- | templates/user/settings/profile.tmpl | 2 |
4 files changed, 10 insertions, 0 deletions
diff --git a/modules/base/template.go b/modules/base/template.go index 196b935107..1442bf0e84 100644 --- a/modules/base/template.go +++ b/modules/base/template.go @@ -118,6 +118,9 @@ var TemplateFuncs template.FuncMap = map[string]interface{}{ "CdnMode": func() bool { return setting.ProdMode && !setting.OfflineMode }, + "DisableGravatar": func() bool { + return setting.DisableGravatar + }, "LoadTimes": func(startTime time.Time) string { return fmt.Sprint(time.Since(startTime).Nanoseconds()/1e6) + "ms" }, diff --git a/modules/setting/setting.go b/modules/setting/setting.go index 462e838456..12fd52c999 100644 --- a/modules/setting/setting.go +++ b/modules/setting/setting.go @@ -322,6 +322,9 @@ func NewConfigContext() { GravatarSource = "//1.gravatar.com/avatar/" } DisableGravatar = sec.Key("DISABLE_GRAVATAR").MustBool() + if OfflineMode { + DisableGravatar = true + } if err = Cfg.Section("git").MapTo(&Git); err != nil { log.Fatal(4, "Fail to map Git settings: %v", err) diff --git a/templates/org/settings/options.tmpl b/templates/org/settings/options.tmpl index 1179ede620..86e52fcd82 100644 --- a/templates/org/settings/options.tmpl +++ b/templates/org/settings/options.tmpl @@ -46,10 +46,12 @@ <label for="location">{{.i18n.Tr "org.settings.location"}}</label> <input class="ipt ipt-large ipt-radius {{if .Err_Location}}ipt-error{{end}}" id="location" name="location" type="text" value="{{.Org.Location}}" /> </div> + {{if not DisableGravatar}} <div class="field"> <label for="gravatar-email">Gravatar {{.i18n.Tr "email"}}</label> <input class="ipt ipt-large ipt-radius {{if .Err_Avatar}}ipt-error{{end}}" id="gravatar-email" name="avatar" type="text" value="{{.Org.AvatarEmail}}" /> </div> + {{end}} <div class="field"> <span class="form-label"></span> <button class="btn btn-green btn-large btn-radius" id="change-orgname-btn" href="#change-orgname-modal">{{.i18n.Tr "org.settings.update_settings"}}</button> diff --git a/templates/user/settings/profile.tmpl b/templates/user/settings/profile.tmpl index febf523704..2fd6c7b2a5 100644 --- a/templates/user/settings/profile.tmpl +++ b/templates/user/settings/profile.tmpl @@ -46,10 +46,12 @@ <label for="location">{{.i18n.Tr "settings.location"}}</label> <input class="ipt ipt-large ipt-radius {{if .Err_Location}}ipt-error{{end}}" id="location" name="location" type="text" value="{{.SignedUser.Location}}" /> </div> + {{if not DisableGravatar}} <div class="field"> <label class="req" for="gravatar-email">Gravatar {{.i18n.Tr "email"}}</label> <input class="ipt ipt-large ipt-radius {{if .Err_Avatar}}ipt-error{{end}}" id="gravatar-email" name="avatar" type="text" value="{{.SignedUser.AvatarEmail}}" /> </div> + {{end}} <div class="field"> <label></label> <button class="btn btn-green btn-large btn-radius" id="change-username-btn" href="#change-username-modal">{{.i18n.Tr "settings.update_profile"}}</button> |