Add support for federated avatars (#3320)

* Add support for federated avatars

Fixes #3105

Removes avatar fetching duplication code
Adds an "Enable Federated Avatar" checkbox in user settings
(defaults to unchecked)

Moves avatar settings all in the same form, making
local and remote avatars mutually exclusive

Renames UploadAvatarForm to AvatarForm
as it's not anymore only for uploading

* Run gofmt on all modified files

* Move Avatar form in its own page

* Add go-libravatar dependency to vendor/ dir

Hopefully helps with accepting the contribution.
See also #3214

* Revert "Add go-libravatar dependency to vendor/ dir"

This reverts commit a8cb93ae640bbb90f7d25012fc257bda9fae9b82.

* Make federated avatar setting a global configuration

Removes the per-user setting

* Move avatar handling back to base tool, disable federated avatar in offline mode

* Format, handle error

* Properly set fallback host

* Use unsupported github.com mirror for importing go-libravatar

* Remove comment showing life exists outside of github.com

... pity, but contribution would not be accepted otherwise

* Use Combo for Get and Post methods over /avatar

* FEDERATED_AVATAR -> ENABLE_FEDERATED_AVATAR

* Fix persistance of federated avatar lookup checkbox at install time

* Federated Avatars -> Enable Federated Avatars

* Use len(string) == 0 instead of string == ""

* Move import line where it belong

See
https://github.com/Unknwon/go-code-convention/blob/master/en-US/import_packages.md

Pity the import url is still the unofficial one, but oh well...

* Save a line (and waste much more expensive time)

* Remove redundant parens

* Remove an empty line

* Remove empty lines

* Reorder lines to make diff smaller

* Remove another newline

Unknwon review got me start a fight against newlines

* Move DISABLE_GRAVATAR and ENABLE_FEDERATED_AVATAR after OFFLINE_MODE

On re-reading the diff I figured what Unknwon meant here:
https://github.com/gogits/gogs/pull/3320/files#r73741106

* Remove newlines that weren't there before my intervention
pull/197/head
Sandro Santilli 8 years ago committed by 无闻
parent ec92565f23
commit 90dd0657b5
  1. 5
      cmd/web.go
  2. 3
      conf/app.ini
  3. 7
      conf/locale/locale_en-US.ini
  4. 2
      models/user.go
  5. 15
      modules/auth/user_form.go
  6. 22
      modules/base/tool.go
  7. 19
      modules/setting/setting.go
  8. 1
      routers/admin/admin.go
  9. 2
      routers/install.go
  10. 4
      routers/org/setting.go
  11. 27
      routers/user/setting.go
  12. 6
      templates/admin/config.tmpl
  13. 6
      templates/install.tmpl
  14. 50
      templates/user/settings/avatar.tmpl
  15. 3
      templates/user/settings/navbar.tmpl
  16. 26
      templates/user/settings/profile.tmpl

@ -226,7 +226,8 @@ func runWeb(ctx *cli.Context) error {
m.Group("/user/settings", func() { m.Group("/user/settings", func() {
m.Get("", user.Settings) m.Get("", user.Settings)
m.Post("", bindIgnErr(auth.UpdateProfileForm{}), user.SettingsPost) m.Post("", bindIgnErr(auth.UpdateProfileForm{}), user.SettingsPost)
m.Post("/avatar", binding.MultipartForm(auth.UploadAvatarForm{}), user.SettingsAvatar) m.Combo("/avatar").Get(user.SettingsAvatar).
Post(binding.MultipartForm(auth.AvatarForm{}), user.SettingsAvatarPost)
m.Post("/avatar/delete", user.SettingsDeleteAvatar) m.Post("/avatar/delete", user.SettingsDeleteAvatar)
m.Combo("/email").Get(user.SettingsEmails). m.Combo("/email").Get(user.SettingsEmails).
Post(bindIgnErr(auth.AddEmailForm{}), user.SettingsEmailPost) Post(bindIgnErr(auth.AddEmailForm{}), user.SettingsEmailPost)
@ -375,7 +376,7 @@ func runWeb(ctx *cli.Context) error {
m.Group("/settings", func() { m.Group("/settings", func() {
m.Combo("").Get(org.Settings). m.Combo("").Get(org.Settings).
Post(bindIgnErr(auth.UpdateOrgSettingForm{}), org.SettingsPost) Post(bindIgnErr(auth.UpdateOrgSettingForm{}), org.SettingsPost)
m.Post("/avatar", binding.MultipartForm(auth.UploadAvatarForm{}), org.SettingsAvatar) m.Post("/avatar", binding.MultipartForm(auth.AvatarForm{}), org.SettingsAvatar)
m.Post("/avatar/delete", org.SettingsDeleteAvatar) m.Post("/avatar/delete", org.SettingsDeleteAvatar)
m.Group("/hooks", func() { m.Group("/hooks", func() {

@ -230,6 +230,9 @@ AVATAR_UPLOAD_PATH = data/avatars
; or a custom avatar source, like: http://cn.gravatar.com/avatar/ ; or a custom avatar source, like: http://cn.gravatar.com/avatar/
GRAVATAR_SOURCE = gravatar GRAVATAR_SOURCE = gravatar
DISABLE_GRAVATAR = false DISABLE_GRAVATAR = false
; Federated avatar lookup uses DNS to discover avatar associated
; with emails, see http://www.libravatar.org
ENABLE_FEDERATED_AVATAR = false
[attachment] [attachment]
; Whether attachments are enabled. Defaults to `true` ; Whether attachments are enabled. Defaults to `true`

@ -96,6 +96,7 @@ offline_mode = Enable Offline Mode
offline_mode_popup = Disable CDN even in production mode, all resource files will be served locally. offline_mode_popup = Disable CDN even in production mode, all resource files will be served locally.
disable_gravatar = Disable Gravatar Service disable_gravatar = Disable Gravatar Service
disable_gravatar_popup = Disable Gravatar and custom sources, all avatars are uploaded by users or default. disable_gravatar_popup = Disable Gravatar and custom sources, all avatars are uploaded by users or default.
federated_avatar_lookup = Enable Federated Avatars Lookup
disable_registration = Disable Self-registration disable_registration = Disable Self-registration
disable_registration_popup = Disable user self-registration, only admin can create accounts. disable_registration_popup = Disable user self-registration, only admin can create accounts.
enable_captcha = Enable Captcha enable_captcha = Enable Captcha
@ -239,6 +240,7 @@ form.name_pattern_not_allowed = Username pattern '%s' is not allowed.
[settings] [settings]
profile = Profile profile = Profile
password = Password password = Password
avatar = Avatar
ssh_keys = SSH Keys ssh_keys = SSH Keys
social = Social Accounts social = Social Accounts
applications = Applications applications = Applications
@ -259,7 +261,9 @@ change_username_prompt = This change will affect the way how links relate to you
continue = Continue continue = Continue
cancel = Cancel cancel = Cancel
enable_custom_avatar = Enable Custom Avatar lookup_avatar_by_mail = Lookup Avatar by mail
federated_avatar_lookup = Federated Avatar Lookup
enable_custom_avatar = Use Custom Avatar
choose_new_avatar = Choose new avatar choose_new_avatar = Choose new avatar
update_avatar = Update Avatar Setting update_avatar = Update Avatar Setting
delete_current_avatar = Delete Current Avatar delete_current_avatar = Delete Current Avatar
@ -1044,6 +1048,7 @@ config.cookie_life_time = Cookie Life Time
config.picture_config = Picture Configuration config.picture_config = Picture Configuration
config.picture_service = Picture Service config.picture_service = Picture Service
config.disable_gravatar = Disable Gravatar config.disable_gravatar = Disable Gravatar
config.enable_federated_avatar = Enable Federated Avatars
config.log_config = Log Configuration config.log_config = Log Configuration
config.log_mode = Log Mode config.log_mode = Log Mode

@ -254,7 +254,7 @@ func (u *User) RelAvatarLink() string {
return setting.AppSubUrl + "/avatars/" + com.ToStr(u.ID) return setting.AppSubUrl + "/avatars/" + com.ToStr(u.ID)
} }
return setting.GravatarSource + u.Avatar return base.AvatarLink(u.AvatarEmail)
} }
// AvatarLink returns user avatar absolute link. // AvatarLink returns user avatar absolute link.

@ -38,6 +38,7 @@ type InstallForm struct {
OfflineMode bool OfflineMode bool
DisableGravatar bool DisableGravatar bool
EnableFederatedAvatar bool
DisableRegistration bool DisableRegistration bool
EnableCaptcha bool EnableCaptcha bool
RequireSignInView bool RequireSignInView bool
@ -93,19 +94,25 @@ type UpdateProfileForm struct {
Email string `binding:"Required;Email;MaxSize(254)"` Email string `binding:"Required;Email;MaxSize(254)"`
Website string `binding:"Url;MaxSize(100)"` Website string `binding:"Url;MaxSize(100)"`
Location string `binding:"MaxSize(50)"` Location string `binding:"MaxSize(50)"`
Gravatar string `binding:"OmitEmpty;Email;MaxSize(254)"`
} }
func (f *UpdateProfileForm) Validate(ctx *macaron.Context, errs binding.Errors) binding.Errors { func (f *UpdateProfileForm) Validate(ctx *macaron.Context, errs binding.Errors) binding.Errors {
return validate(errs, ctx.Data, f, ctx.Locale) return validate(errs, ctx.Data, f, ctx.Locale)
} }
type UploadAvatarForm struct { const (
Enable bool AVATAR_LOCAL string = "local"
AVATAR_BYMAIL string = "bymail"
)
type AvatarForm struct {
Source string
Avatar *multipart.FileHeader Avatar *multipart.FileHeader
Gravatar string `binding:"OmitEmpty;Email;MaxSize(254)"`
Federavatar bool
} }
func (f *UploadAvatarForm) Validate(ctx *macaron.Context, errs binding.Errors) binding.Errors { func (f *AvatarForm) Validate(ctx *macaron.Context, errs binding.Errors) binding.Errors {
return validate(errs, ctx.Data, f, ctx.Locale) return validate(errs, ctx.Data, f, ctx.Locale)
} }

@ -205,12 +205,26 @@ func HashEmail(email string) string {
} }
// AvatarLink returns avatar link by given email. // AvatarLink returns avatar link by given email.
func AvatarLink(email string) string { func AvatarLink(email string) (url string) {
if setting.DisableGravatar || setting.OfflineMode {
return setting.AppSubUrl + "/img/avatar_default.png" if !setting.OfflineMode {
if setting.EnableFederatedAvatar && setting.LibravatarService != nil {
var err error
url, err = setting.LibravatarService.FromEmail(email)
if err != nil {
log.Error(1, "LibravatarService.FromEmail:: %v", err)
}
}
if len(url) == 0 && !setting.DisableGravatar {
url = setting.GravatarSource + HashEmail(email)
}
}
if len(url) == 0 {
url = setting.AppSubUrl + "/img/avatar_default.png"
} }
return setting.GravatarSource + HashEmail(email) return url
} }
// Seconds-based time units // Seconds-based time units

@ -21,6 +21,7 @@ import (
"github.com/go-macaron/session" "github.com/go-macaron/session"
_ "github.com/go-macaron/session/redis" _ "github.com/go-macaron/session/redis"
"gopkg.in/ini.v1" "gopkg.in/ini.v1"
"github.com/strk/go-libravatar"
"github.com/gogits/gogs/modules/bindata" "github.com/gogits/gogs/modules/bindata"
"github.com/gogits/gogs/modules/log" "github.com/gogits/gogs/modules/log"
@ -143,6 +144,8 @@ var (
AvatarUploadPath string AvatarUploadPath string
GravatarSource string GravatarSource string
DisableGravatar bool DisableGravatar bool
EnableFederatedAvatar bool
LibravatarService *libravatar.Libravatar
// Log settings // Log settings
LogRootPath string LogRootPath string
@ -462,8 +465,24 @@ func NewContext() {
GravatarSource = source GravatarSource = source
} }
DisableGravatar = sec.Key("DISABLE_GRAVATAR").MustBool() DisableGravatar = sec.Key("DISABLE_GRAVATAR").MustBool()
EnableFederatedAvatar = sec.Key("ENABLE_FEDERATED_AVATAR").MustBool()
if OfflineMode { if OfflineMode {
DisableGravatar = true DisableGravatar = true
EnableFederatedAvatar = false
}
if !DisableGravatar && EnableFederatedAvatar {
LibravatarService = libravatar.New()
parts := strings.Split(GravatarSource, "/")
if len(parts) >= 3 {
if parts[0] == "https:" {
LibravatarService.SetUseHTTPS(true)
LibravatarService.SetSecureFallbackHost(parts[2])
} else {
LibravatarService.SetUseHTTPS(false)
LibravatarService.SetFallbackHost(parts[2])
}
}
} }
if err = Cfg.Section("ui").MapTo(&UI); err != nil { if err = Cfg.Section("ui").MapTo(&UI); err != nil {

@ -222,6 +222,7 @@ func Config(ctx *context.Context) {
ctx.Data["SessionConfig"] = setting.SessionConfig ctx.Data["SessionConfig"] = setting.SessionConfig
ctx.Data["DisableGravatar"] = setting.DisableGravatar ctx.Data["DisableGravatar"] = setting.DisableGravatar
ctx.Data["EnableFederatedAvatar"] = setting.EnableFederatedAvatar
type logger struct { type logger struct {
Mode, Config string Mode, Config string

@ -169,6 +169,7 @@ func Install(ctx *context.Context) {
// Server and other services settings // Server and other services settings
form.OfflineMode = setting.OfflineMode form.OfflineMode = setting.OfflineMode
form.DisableGravatar = setting.DisableGravatar form.DisableGravatar = setting.DisableGravatar
form.EnableFederatedAvatar = setting.EnableFederatedAvatar
form.DisableRegistration = setting.Service.DisableRegistration form.DisableRegistration = setting.Service.DisableRegistration
form.EnableCaptcha = setting.Service.EnableCaptcha form.EnableCaptcha = setting.Service.EnableCaptcha
form.RequireSignInView = setting.Service.RequireSignInView form.RequireSignInView = setting.Service.RequireSignInView
@ -329,6 +330,7 @@ func InstallPost(ctx *context.Context, form auth.InstallForm) {
cfg.Section("server").Key("OFFLINE_MODE").SetValue(com.ToStr(form.OfflineMode)) cfg.Section("server").Key("OFFLINE_MODE").SetValue(com.ToStr(form.OfflineMode))
cfg.Section("picture").Key("DISABLE_GRAVATAR").SetValue(com.ToStr(form.DisableGravatar)) cfg.Section("picture").Key("DISABLE_GRAVATAR").SetValue(com.ToStr(form.DisableGravatar))
cfg.Section("picture").Key("ENABLE_FEDERATED_AVATAR").SetValue(com.ToStr(form.EnableFederatedAvatar))
cfg.Section("service").Key("DISABLE_REGISTRATION").SetValue(com.ToStr(form.DisableRegistration)) cfg.Section("service").Key("DISABLE_REGISTRATION").SetValue(com.ToStr(form.DisableRegistration))
cfg.Section("service").Key("ENABLE_CAPTCHA").SetValue(com.ToStr(form.EnableCaptcha)) cfg.Section("service").Key("ENABLE_CAPTCHA").SetValue(com.ToStr(form.EnableCaptcha))
cfg.Section("service").Key("REQUIRE_SIGNIN_VIEW").SetValue(com.ToStr(form.RequireSignInView)) cfg.Section("service").Key("REQUIRE_SIGNIN_VIEW").SetValue(com.ToStr(form.RequireSignInView))

@ -83,8 +83,8 @@ func SettingsPost(ctx *context.Context, form auth.UpdateOrgSettingForm) {
ctx.Redirect(ctx.Org.OrgLink + "/settings") ctx.Redirect(ctx.Org.OrgLink + "/settings")
} }
func SettingsAvatar(ctx *context.Context, form auth.UploadAvatarForm) { func SettingsAvatar(ctx *context.Context, form auth.AvatarForm) {
form.Enable = true form.Source = auth.AVATAR_LOCAL
if err := user.UpdateAvatarSetting(ctx, form, ctx.Org.Organization); err != nil { if err := user.UpdateAvatarSetting(ctx, form, ctx.Org.Organization); err != nil {
ctx.Flash.Error(err.Error()) ctx.Flash.Error(err.Error())
} else { } else {

@ -22,6 +22,7 @@ import (
const ( const (
SETTINGS_PROFILE base.TplName = "user/settings/profile" SETTINGS_PROFILE base.TplName = "user/settings/profile"
SETTINGS_AVATAR base.TplName = "user/settings/avatar"
SETTINGS_PASSWORD base.TplName = "user/settings/password" SETTINGS_PASSWORD base.TplName = "user/settings/password"
SETTINGS_EMAILS base.TplName = "user/settings/email" SETTINGS_EMAILS base.TplName = "user/settings/email"
SETTINGS_SSH_KEYS base.TplName = "user/settings/sshkeys" SETTINGS_SSH_KEYS base.TplName = "user/settings/sshkeys"
@ -91,10 +92,6 @@ func SettingsPost(ctx *context.Context, form auth.UpdateProfileForm) {
ctx.User.Email = form.Email ctx.User.Email = form.Email
ctx.User.Website = form.Website ctx.User.Website = form.Website
ctx.User.Location = form.Location ctx.User.Location = form.Location
if len(form.Gravatar) > 0 {
ctx.User.Avatar = base.EncodeMD5(form.Gravatar)
ctx.User.AvatarEmail = form.Gravatar
}
if err := models.UpdateUser(ctx.User); err != nil { if err := models.UpdateUser(ctx.User); err != nil {
ctx.Handle(500, "UpdateUser", err) ctx.Handle(500, "UpdateUser", err)
return return
@ -106,8 +103,12 @@ func SettingsPost(ctx *context.Context, form auth.UpdateProfileForm) {
} }
// FIXME: limit size. // FIXME: limit size.
func UpdateAvatarSetting(ctx *context.Context, form auth.UploadAvatarForm, ctxUser *models.User) error { func UpdateAvatarSetting(ctx *context.Context, form auth.AvatarForm, ctxUser *models.User) error {
ctxUser.UseCustomAvatar = form.Enable ctxUser.UseCustomAvatar = form.Source == auth.AVATAR_LOCAL
if len(form.Gravatar) > 0 {
ctxUser.Avatar = base.EncodeMD5(form.Gravatar)
ctxUser.AvatarEmail = form.Gravatar
}
if form.Avatar != nil { if form.Avatar != nil {
fr, err := form.Avatar.Open() fr, err := form.Avatar.Open()
@ -129,7 +130,7 @@ func UpdateAvatarSetting(ctx *context.Context, form auth.UploadAvatarForm, ctxUs
} else { } else {
// No avatar is uploaded but setting has been changed to enable, // No avatar is uploaded but setting has been changed to enable,
// generate a random one when needed. // generate a random one when needed.
if form.Enable && !com.IsFile(ctxUser.CustomAvatarPath()) { if ctxUser.UseCustomAvatar && !com.IsFile(ctxUser.CustomAvatarPath()) {
if err := ctxUser.GenerateRandomAvatar(); err != nil { if err := ctxUser.GenerateRandomAvatar(); err != nil {
log.Error(4, "GenerateRandomAvatar[%d]: %v", ctxUser.ID, err) log.Error(4, "GenerateRandomAvatar[%d]: %v", ctxUser.ID, err)
} }
@ -143,14 +144,20 @@ func UpdateAvatarSetting(ctx *context.Context, form auth.UploadAvatarForm, ctxUs
return nil return nil
} }
func SettingsAvatar(ctx *context.Context, form auth.UploadAvatarForm) { func SettingsAvatar(ctx *context.Context) {
ctx.Data["Title"] = ctx.Tr("settings")
ctx.Data["PageIsSettingsAvatar"] = true
ctx.HTML(200, SETTINGS_AVATAR)
}
func SettingsAvatarPost(ctx *context.Context, form auth.AvatarForm) {
if err := UpdateAvatarSetting(ctx, form, ctx.User); err != nil { if err := UpdateAvatarSetting(ctx, form, ctx.User); err != nil {
ctx.Flash.Error(err.Error()) ctx.Flash.Error(err.Error())
} else { } else {
ctx.Flash.Success(ctx.Tr("settings.update_avatar_success")) ctx.Flash.Success(ctx.Tr("settings.update_avatar_success"))
} }
ctx.Redirect(setting.AppSubUrl + "/user/settings") ctx.Redirect(setting.AppSubUrl + "/user/settings/avatar")
} }
func SettingsDeleteAvatar(ctx *context.Context) { func SettingsDeleteAvatar(ctx *context.Context) {
@ -158,7 +165,7 @@ func SettingsDeleteAvatar(ctx *context.Context) {
ctx.Flash.Error(err.Error()) ctx.Flash.Error(err.Error())
} }
ctx.Redirect(setting.AppSubUrl + "/user/settings") ctx.Redirect(setting.AppSubUrl + "/user/settings/avatar")
} }
func SettingsPassword(ctx *context.Context) { func SettingsPassword(ctx *context.Context) {

@ -215,6 +215,12 @@
<dd><i class="fa fa{{if .DisableGravatar}}-check{{end}}-square-o"></i></dd> <dd><i class="fa fa{{if .DisableGravatar}}-check{{end}}-square-o"></i></dd>
</dl> </dl>
</div> </div>
<div class="ui attached table segment">
<dl class="dl-horizontal admin-dl-horizontal">
<dt>{{.i18n.Tr "admin.config.enable_federated_avatar"}}</dt>
<dd><i class="fa fa{{if .EnableFederatedAvatar}}-check{{end}}-square-o"></i></dd>
</dl>
</div>
<h4 class="ui top attached header"> <h4 class="ui top attached header">
{{.i18n.Tr "admin.config.log_config"}} {{.i18n.Tr "admin.config.log_config"}}

@ -177,6 +177,12 @@
<input name="disable_gravatar" type="checkbox" {{if .disable_gravatar}}checked{{end}}> <input name="disable_gravatar" type="checkbox" {{if .disable_gravatar}}checked{{end}}>
</div> </div>
</div> </div>
<div class="inline field">
<div class="ui checkbox" id="federated-avatar-lookup">
<label class="poping up" data-content="{{.i18n.Tr "install.federated_avatar_lookup"}}"><strong>{{.i18n.Tr "install.federated_avatar_lookup"}}</strong></label>
<input name="enable_federated_avatar" type="checkbox" {{if .enable_federated_avatar}}checked{{end}}>
</div>
</div>
<div class="inline field"> <div class="inline field">
<div class="ui checkbox" id="disable-registration"> <div class="ui checkbox" id="disable-registration">
<label class="poping up" data-content="{{.i18n.Tr "install.disable_registration_popup"}}"><strong>{{.i18n.Tr "install.disable_registration"}}</strong></label> <label class="poping up" data-content="{{.i18n.Tr "install.disable_registration_popup"}}"><strong>{{.i18n.Tr "install.disable_registration"}}</strong></label>

@ -0,0 +1,50 @@
{{template "base/head" .}}
<div class="user settings avatar">
<div class="ui container">
<div class="ui grid">
{{template "user/settings/navbar" .}}
<div class="twelve wide column content">
{{template "base/alert" .}}
<h4 class="ui top attached header">
{{.i18n.Tr "settings.avatar"}}
</h4>
<div class="ui attached segment">
<form class="ui form" action="{{.Link}}" method="post" enctype="multipart/form-data">
{{.CsrfTokenHtml}}
{{if not DisableGravatar}}
<div class="inline field">
<div class="ui radio">
<input name="source" value="lookup" type="radio" {{if not .SignedUser.UseCustomAvatar}}checked{{end}}>
<label>{{.i18n.Tr "settings.lookup_avatar_by_mail"}}</label>
</div>
</div>
<div class="field {{if .Err_Gravatar}}error{{end}}">
<label for="gravatar">Avatar {{.i18n.Tr "email"}}</label>
<input id="gravatar" name="gravatar" value="{{.SignedUser.AvatarEmail}}" />
</div>
{{end}}
<div class="inline field">
<div class="ui radio">
<input name="source" value="local" type="radio" {{if .SignedUser.UseCustomAvatar}}checked{{end}}>
<label>{{.i18n.Tr "settings.enable_custom_avatar"}}</label>
</div>
</div>
<div class="inline field">
<label for="avatar">{{.i18n.Tr "settings.choose_new_avatar"}}</label>
<input name="avatar" type="file" >
</div>
<div class="field">
<button class="ui green button">{{$.i18n.Tr "settings.update_avatar"}}</button>
<a class="ui red button delete-post" data-request-url="{{.Link}}/delete" data-done-url="{{.Link}}">{{$.i18n.Tr "settings.delete_current_avatar"}}</a>
</div>
</form>
</div>
</div>
</div>
</div>
</div>
{{template "base/footer" .}}

@ -4,6 +4,9 @@
<a class="{{if .PageIsSettingsProfile}}active{{end}} item" href="{{AppSubUrl}}/user/settings"> <a class="{{if .PageIsSettingsProfile}}active{{end}} item" href="{{AppSubUrl}}/user/settings">
{{.i18n.Tr "settings.profile"}} {{.i18n.Tr "settings.profile"}}
</a> </a>
<a class="{{if .PageIsSettingsAvatar}}active{{end}} item" href="{{AppSubUrl}}/user/settings/avatar">
{{.i18n.Tr "settings.avatar"}}
</a>
<a class="{{if .PageIsSettingsPassword}}active{{end}} item" href="{{AppSubUrl}}/user/settings/password"> <a class="{{if .PageIsSettingsPassword}}active{{end}} item" href="{{AppSubUrl}}/user/settings/password">
{{.i18n.Tr "settings.password"}} {{.i18n.Tr "settings.password"}}
</a> </a>

@ -35,38 +35,12 @@
<label for="location">{{.i18n.Tr "settings.location"}}</label> <label for="location">{{.i18n.Tr "settings.location"}}</label>
<input id="location" name="location" value="{{.SignedUser.Location}}"> <input id="location" name="location" value="{{.SignedUser.Location}}">
</div> </div>
{{if not DisableGravatar}}
<div class="field {{if .Err_Gravatar}}error{{end}}">
<label for="gravatar">Gravatar {{.i18n.Tr "email"}}</label>
<input id="gravatar" name="gravatar" value="{{.SignedUser.AvatarEmail}}" />
</div>
{{end}}
<div class="field"> <div class="field">
<button class="ui green button">{{$.i18n.Tr "settings.update_profile"}}</button> <button class="ui green button">{{$.i18n.Tr "settings.update_profile"}}</button>
</div> </div>
</form> </form>
<div class="ui divider"></div>
<form class="ui form" action="{{.Link}}/avatar" method="post" enctype="multipart/form-data">
{{.CsrfTokenHtml}}
<div class="inline field">
<div class="ui checkbox">
<input name="enable" type="checkbox" {{if .SignedUser.UseCustomAvatar}}checked{{end}}>
<label>{{.i18n.Tr "settings.enable_custom_avatar"}}</label>
</div>
</div>
<div class="inline field">
<label for="avatar">{{.i18n.Tr "settings.choose_new_avatar"}}</label>
<input name="avatar" type="file" >
</div>
<div class="field">
<button class="ui green button">{{$.i18n.Tr "settings.update_avatar"}}</button>
<a class="ui red button delete-post" data-request-url="{{.Link}}/avatar/delete" data-done-url="{{.Link}}">{{$.i18n.Tr "settings.delete_current_avatar"}}</a>
</div>
</form>
</div> </div>
</div> </div>
</div> </div>

Loading…
Cancel
Save