Browse Source

#1098 Hide gravatar email field if gravatar is disabled (or offline mode)

pull/1144/head
Unknwon 10 years ago
parent
commit
caf7618ea6
  1. 3
      modules/base/template.go
  2. 3
      modules/setting/setting.go
  3. 2
      templates/org/settings/options.tmpl
  4. 2
      templates/user/settings/profile.tmpl

3
modules/base/template.go

@ -118,6 +118,9 @@ var TemplateFuncs template.FuncMap = map[string]interface{}{
"CdnMode": func() bool { "CdnMode": func() bool {
return setting.ProdMode && !setting.OfflineMode return setting.ProdMode && !setting.OfflineMode
}, },
"DisableGravatar": func() bool {
return setting.DisableGravatar
},
"LoadTimes": func(startTime time.Time) string { "LoadTimes": func(startTime time.Time) string {
return fmt.Sprint(time.Since(startTime).Nanoseconds()/1e6) + "ms" return fmt.Sprint(time.Since(startTime).Nanoseconds()/1e6) + "ms"
}, },

3
modules/setting/setting.go

@ -322,6 +322,9 @@ func NewConfigContext() {
GravatarSource = "//1.gravatar.com/avatar/" GravatarSource = "//1.gravatar.com/avatar/"
} }
DisableGravatar = sec.Key("DISABLE_GRAVATAR").MustBool() DisableGravatar = sec.Key("DISABLE_GRAVATAR").MustBool()
if OfflineMode {
DisableGravatar = true
}
if err = Cfg.Section("git").MapTo(&Git); err != nil { if err = Cfg.Section("git").MapTo(&Git); err != nil {
log.Fatal(4, "Fail to map Git settings: %v", err) log.Fatal(4, "Fail to map Git settings: %v", err)

2
templates/org/settings/options.tmpl

@ -46,10 +46,12 @@
<label for="location">{{.i18n.Tr "org.settings.location"}}</label> <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}}" /> <input class="ipt ipt-large ipt-radius {{if .Err_Location}}ipt-error{{end}}" id="location" name="location" type="text" value="{{.Org.Location}}" />
</div> </div>
{{if not DisableGravatar}}
<div class="field"> <div class="field">
<label for="gravatar-email">Gravatar {{.i18n.Tr "email"}}</label> <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}}" /> <input class="ipt ipt-large ipt-radius {{if .Err_Avatar}}ipt-error{{end}}" id="gravatar-email" name="avatar" type="text" value="{{.Org.AvatarEmail}}" />
</div> </div>
{{end}}
<div class="field"> <div class="field">
<span class="form-label"></span> <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> <button class="btn btn-green btn-large btn-radius" id="change-orgname-btn" href="#change-orgname-modal">{{.i18n.Tr "org.settings.update_settings"}}</button>

2
templates/user/settings/profile.tmpl

@ -46,10 +46,12 @@
<label for="location">{{.i18n.Tr "settings.location"}}</label> <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}}" /> <input class="ipt ipt-large ipt-radius {{if .Err_Location}}ipt-error{{end}}" id="location" name="location" type="text" value="{{.SignedUser.Location}}" />
</div> </div>
{{if not DisableGravatar}}
<div class="field"> <div class="field">
<label class="req" for="gravatar-email">Gravatar {{.i18n.Tr "email"}}</label> <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}}" /> <input class="ipt ipt-large ipt-radius {{if .Err_Avatar}}ipt-error{{end}}" id="gravatar-email" name="avatar" type="text" value="{{.SignedUser.AvatarEmail}}" />
</div> </div>
{{end}}
<div class="field"> <div class="field">
<label></label> <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> <button class="btn btn-green btn-large btn-radius" id="change-username-btn" href="#change-username-modal">{{.i18n.Tr "settings.update_profile"}}</button>

Loading…
Cancel
Save