mirror of
https://codeberg.org/forgejo/forgejo.git
synced 2024-11-09 11:21:19 +01:00
more on change avatar
This commit is contained in:
parent
22ab4fa1b0
commit
ef275ebf62
11 changed files with 42 additions and 18 deletions
|
@ -164,7 +164,7 @@ func runServ(k *cli.Context) {
|
||||||
log.GitLogger.Fatal(2, "User %s has no right to read repository %s", user.Name, repoPath)
|
log.GitLogger.Fatal(2, "User %s has no right to read repository %s", user.Name, repoPath)
|
||||||
}
|
}
|
||||||
default:
|
default:
|
||||||
println("Unknown command")
|
println("Unknown command: " + cmd)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -202,10 +202,13 @@ change_username = Username Changed
|
||||||
change_username_desc = Username has been changed, do you want to continue? This will affect all links relate to your account.
|
change_username_desc = Username has been changed, do you want to continue? This will affect all links relate to your account.
|
||||||
continue = Continue
|
continue = Continue
|
||||||
cancel = Cancel
|
cancel = Cancel
|
||||||
|
|
||||||
|
enable_custom_avatar = Enable Custom Avatar
|
||||||
|
enable_custom_avatar_helper = Enable this to disable fetch from Gravatar
|
||||||
choose_new_avatar = Choose new avatar
|
choose_new_avatar = Choose new avatar
|
||||||
upload_avatar = Upload Avatar
|
update_avatar = Update Avatar Setting
|
||||||
uploaded_avatar_not_a_image = Uploaded file is not a image
|
uploaded_avatar_not_a_image = Uploaded file is not a image.
|
||||||
upload_avatar_success = Your new avatar has been uploaded successfully.
|
update_avatar_success = Your avatar setting has been updated successfully.
|
||||||
|
|
||||||
change_password = Change Password
|
change_password = Change Password
|
||||||
old_password = Current Password
|
old_password = Current Password
|
||||||
|
|
|
@ -173,6 +173,7 @@ target_branch_not_exist=目标分支不存在。
|
||||||
|
|
||||||
[user]
|
[user]
|
||||||
change_avatar=到 gravatar.com 上修改您的头像
|
change_avatar=到 gravatar.com 上修改您的头像
|
||||||
|
change_custom_avatar=到个人设置中修改头像
|
||||||
join_on=加入于
|
join_on=加入于
|
||||||
repositories=仓库列表
|
repositories=仓库列表
|
||||||
activity=公开活动
|
activity=公开活动
|
||||||
|
@ -202,6 +203,13 @@ change_username_desc=用户名被修改,您确定要继续操作吗?这将
|
||||||
continue=继续操作
|
continue=继续操作
|
||||||
cancel=取消操作
|
cancel=取消操作
|
||||||
|
|
||||||
|
enable_custom_avatar=启动自定义头像
|
||||||
|
enable_custom_avatar_helper=激活该选项来禁止从 Gravatar 获取头像
|
||||||
|
choose_new_avatar=选择新的头像
|
||||||
|
update_avatar=更新头像设置
|
||||||
|
uploaded_avatar_not_a_image=上传的文件不是一张图片!
|
||||||
|
update_avatar_success=您的头像设置更新成功!
|
||||||
|
|
||||||
change_password=修改密码
|
change_password=修改密码
|
||||||
old_password=当前密码
|
old_password=当前密码
|
||||||
new_password=新的密码
|
new_password=新的密码
|
||||||
|
|
|
@ -163,6 +163,7 @@ func (u *User) UploadAvatar(data []byte) error {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
os.MkdirAll(setting.AvatarUploadPath, os.ModePerm)
|
||||||
fw, err := os.Create(savePath)
|
fw, err := os.Create(savePath)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
sess.Rollback()
|
sess.Rollback()
|
||||||
|
|
|
@ -89,7 +89,8 @@ func (f *UpdateProfileForm) Validate(ctx *macaron.Context, errs binding.Errors)
|
||||||
}
|
}
|
||||||
|
|
||||||
type UploadAvatarForm struct {
|
type UploadAvatarForm struct {
|
||||||
Avatar *multipart.FileHeader `form:"avatar" binding:"Required"`
|
Enable bool `form:"enable"`
|
||||||
|
Avatar *multipart.FileHeader `form:"avatar"`
|
||||||
}
|
}
|
||||||
|
|
||||||
func (f *UploadAvatarForm) Validate(ctx *macaron.Context, errs binding.Errors) binding.Errors {
|
func (f *UploadAvatarForm) Validate(ctx *macaron.Context, errs binding.Errors) binding.Errors {
|
||||||
|
|
|
@ -20,7 +20,7 @@ import (
|
||||||
"github.com/macaron-contrib/session"
|
"github.com/macaron-contrib/session"
|
||||||
|
|
||||||
"github.com/gogits/gogs/modules/log"
|
"github.com/gogits/gogs/modules/log"
|
||||||
// "github.com/gogits/gogs-ng/modules/ssh"
|
// "github.com/gogits/gogs/modules/ssh"
|
||||||
)
|
)
|
||||||
|
|
||||||
type Scheme string
|
type Scheme string
|
||||||
|
@ -488,5 +488,5 @@ func NewServices() {
|
||||||
newRegisterMailService()
|
newRegisterMailService()
|
||||||
newNotifyMailService()
|
newNotifyMailService()
|
||||||
newWebhookService()
|
newWebhookService()
|
||||||
// ssh.Listen("2022")
|
// ssh.Listen("2222")
|
||||||
}
|
}
|
||||||
|
|
|
@ -13,9 +13,8 @@ import (
|
||||||
"os/exec"
|
"os/exec"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"code.google.com/p/go.crypto/ssh"
|
|
||||||
|
|
||||||
"github.com/Unknwon/com"
|
"github.com/Unknwon/com"
|
||||||
|
"golang.org/x/crypto/ssh"
|
||||||
|
|
||||||
"github.com/gogits/gogs/modules/log"
|
"github.com/gogits/gogs/modules/log"
|
||||||
)
|
)
|
||||||
|
@ -35,8 +34,11 @@ func handleServerConn(keyId string, chans <-chan ssh.NewChannel) {
|
||||||
go func(in <-chan *ssh.Request) {
|
go func(in <-chan *ssh.Request) {
|
||||||
defer channel.Close()
|
defer channel.Close()
|
||||||
for req := range in {
|
for req := range in {
|
||||||
ok, payload := false, strings.TrimLeft(string(req.Payload), "\x00")
|
ok, payload := false, strings.TrimLeft(string(req.Payload), "\x00&")
|
||||||
fmt.Println("Request:", req.Type, req.WantReply, payload)
|
fmt.Println("Request:", req.Type, req.WantReply, payload)
|
||||||
|
if req.WantReply {
|
||||||
|
fmt.Println(req.Reply(true, nil))
|
||||||
|
}
|
||||||
switch req.Type {
|
switch req.Type {
|
||||||
case "env":
|
case "env":
|
||||||
args := strings.Split(strings.Replace(payload, "\x00", "", -1), "\v")
|
args := strings.Split(strings.Replace(payload, "\x00", "", -1), "\v")
|
||||||
|
@ -54,7 +56,7 @@ func handleServerConn(keyId string, chans <-chan ssh.NewChannel) {
|
||||||
case "exec":
|
case "exec":
|
||||||
os.Setenv("SSH_ORIGINAL_COMMAND", strings.TrimLeft(payload, "'("))
|
os.Setenv("SSH_ORIGINAL_COMMAND", strings.TrimLeft(payload, "'("))
|
||||||
log.Info("Payload: %v", strings.TrimLeft(payload, "'("))
|
log.Info("Payload: %v", strings.TrimLeft(payload, "'("))
|
||||||
cmd := exec.Command("/Users/jiahuachen/Applications/Go/src/github.com/gogits/gogs-ng/gogs-ng", "serv", "key-"+keyId)
|
cmd := exec.Command("/Users/jiahuachen/Applications/Go/src/github.com/gogits/gogs/gogs", "serv", "key-"+keyId)
|
||||||
cmd.Stdout = channel
|
cmd.Stdout = channel
|
||||||
cmd.Stdin = channel
|
cmd.Stdin = channel
|
||||||
cmd.Stderr = channel.Stderr()
|
cmd.Stderr = channel.Stderr()
|
||||||
|
@ -65,7 +67,6 @@ func handleServerConn(keyId string, chans <-chan ssh.NewChannel) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
fmt.Println("Done:", ok)
|
fmt.Println("Done:", ok)
|
||||||
req.Reply(ok, nil) // BUG: Git on Mac seems not know this reply and hang?
|
|
||||||
}
|
}
|
||||||
fmt.Println("Done!!!")
|
fmt.Println("Done!!!")
|
||||||
}(requests)
|
}(requests)
|
||||||
|
@ -101,7 +102,7 @@ func Listen(port string) {
|
||||||
config := &ssh.ServerConfig{
|
config := &ssh.ServerConfig{
|
||||||
PublicKeyCallback: func(conn ssh.ConnMetadata, key ssh.PublicKey) (*ssh.Permissions, error) {
|
PublicKeyCallback: func(conn ssh.ConnMetadata, key ssh.PublicKey) (*ssh.Permissions, error) {
|
||||||
// keyCache[string(ssh.MarshalAuthorizedKey(key))] = 2
|
// keyCache[string(ssh.MarshalAuthorizedKey(key))] = 2
|
||||||
return &ssh.Permissions{Extensions: map[string]string{"key-id": "2"}}, nil
|
return &ssh.Permissions{Extensions: map[string]string{"key-id": "1"}}, nil
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -2414,5 +2414,5 @@ textarea#issue-add-content {
|
||||||
border-bottom: 2px solid #D26911;
|
border-bottom: 2px solid #D26911;
|
||||||
}
|
}
|
||||||
#profile-body {
|
#profile-body {
|
||||||
margin-left: 10px;
|
margin-left: 20px;
|
||||||
}
|
}
|
||||||
|
|
|
@ -55,5 +55,5 @@
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#profile-body {
|
#profile-body {
|
||||||
margin-left: 10px;
|
margin-left: 20px;
|
||||||
}
|
}
|
|
@ -88,6 +88,11 @@ func SettingsPost(ctx *middleware.Context, form auth.UpdateProfileForm) {
|
||||||
func SettingsAvatar(ctx *middleware.Context, form auth.UploadAvatarForm) {
|
func SettingsAvatar(ctx *middleware.Context, form auth.UploadAvatarForm) {
|
||||||
defer ctx.Redirect(setting.AppSubUrl + "/user/settings")
|
defer ctx.Redirect(setting.AppSubUrl + "/user/settings")
|
||||||
|
|
||||||
|
ctx.User.UseCustomAvatar = form.Enable
|
||||||
|
if err := models.UpdateUser(ctx.User); err != nil {
|
||||||
|
ctx.Flash.Error(err.Error())
|
||||||
|
}
|
||||||
|
|
||||||
if form.Avatar != nil {
|
if form.Avatar != nil {
|
||||||
fr, err := form.Avatar.Open()
|
fr, err := form.Avatar.Open()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -108,8 +113,8 @@ func SettingsAvatar(ctx *middleware.Context, form auth.UploadAvatarForm) {
|
||||||
ctx.Flash.Error(err.Error())
|
ctx.Flash.Error(err.Error())
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
ctx.Flash.Success(ctx.Tr("settings.upload_avatar_success"))
|
|
||||||
}
|
}
|
||||||
|
ctx.Flash.Success(ctx.Tr("settings.update_avatar_success"))
|
||||||
}
|
}
|
||||||
|
|
||||||
func SettingsPassword(ctx *middleware.Context) {
|
func SettingsPassword(ctx *middleware.Context) {
|
||||||
|
|
|
@ -58,13 +58,18 @@
|
||||||
<hr>
|
<hr>
|
||||||
<form class="form form-align" id="user-profile-form" action="{{AppSubUrl}}/user/settings/avatar" method="post" enctype="multipart/form-data">
|
<form class="form form-align" id="user-profile-form" action="{{AppSubUrl}}/user/settings/avatar" method="post" enctype="multipart/form-data">
|
||||||
{{.CsrfTokenHtml}}
|
{{.CsrfTokenHtml}}
|
||||||
|
<div class="field">
|
||||||
|
<label for="enable">{{.i18n.Tr "settings.enable_custom_avatar"}}</label>
|
||||||
|
<input class="ipt-chk" id="enable" name="enable" type="checkbox" {{if .SignedUser.UseCustomAvatar}}checked{{end}} />
|
||||||
|
<span>{{.i18n.Tr "settings.enable_custom_avatar_helper"}}</span>
|
||||||
|
</div>
|
||||||
<div class="field">
|
<div class="field">
|
||||||
<label>{{.i18n.Tr "settings.choose_new_avatar"}}</label>
|
<label>{{.i18n.Tr "settings.choose_new_avatar"}}</label>
|
||||||
<input name="avatar" type="file" required />
|
<input name="avatar" type="file" />
|
||||||
</div>
|
</div>
|
||||||
<div class="field">
|
<div class="field">
|
||||||
<label></label>
|
<label></label>
|
||||||
<button class="btn btn-green btn-large btn-radius">{{.i18n.Tr "settings.upload_avatar"}}</button>
|
<button class="btn btn-green btn-large btn-radius">{{.i18n.Tr "settings.update_avatar"}}</button>
|
||||||
</div>
|
</div>
|
||||||
</form>
|
</form>
|
||||||
</div>
|
</div>
|
||||||
|
|
Loading…
Reference in a new issue