mirror of
https://codeberg.org/forgejo/forgejo.git
synced 2024-11-27 12:53:57 +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)
|
||||
}
|
||||
default:
|
||||
println("Unknown command")
|
||||
println("Unknown command: " + cmd)
|
||||
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.
|
||||
continue = Continue
|
||||
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
|
||||
upload_avatar = Upload Avatar
|
||||
uploaded_avatar_not_a_image = Uploaded file is not a image
|
||||
upload_avatar_success = Your new avatar has been uploaded successfully.
|
||||
update_avatar = Update Avatar Setting
|
||||
uploaded_avatar_not_a_image = Uploaded file is not a image.
|
||||
update_avatar_success = Your avatar setting has been updated successfully.
|
||||
|
||||
change_password = Change Password
|
||||
old_password = Current Password
|
||||
|
|
|
@ -173,6 +173,7 @@ target_branch_not_exist=目标分支不存在。
|
|||
|
||||
[user]
|
||||
change_avatar=到 gravatar.com 上修改您的头像
|
||||
change_custom_avatar=到个人设置中修改头像
|
||||
join_on=加入于
|
||||
repositories=仓库列表
|
||||
activity=公开活动
|
||||
|
@ -202,6 +203,13 @@ change_username_desc=用户名被修改,您确定要继续操作吗?这将
|
|||
continue=继续操作
|
||||
cancel=取消操作
|
||||
|
||||
enable_custom_avatar=启动自定义头像
|
||||
enable_custom_avatar_helper=激活该选项来禁止从 Gravatar 获取头像
|
||||
choose_new_avatar=选择新的头像
|
||||
update_avatar=更新头像设置
|
||||
uploaded_avatar_not_a_image=上传的文件不是一张图片!
|
||||
update_avatar_success=您的头像设置更新成功!
|
||||
|
||||
change_password=修改密码
|
||||
old_password=当前密码
|
||||
new_password=新的密码
|
||||
|
|
|
@ -163,6 +163,7 @@ func (u *User) UploadAvatar(data []byte) error {
|
|||
return err
|
||||
}
|
||||
|
||||
os.MkdirAll(setting.AvatarUploadPath, os.ModePerm)
|
||||
fw, err := os.Create(savePath)
|
||||
if err != nil {
|
||||
sess.Rollback()
|
||||
|
|
|
@ -89,7 +89,8 @@ func (f *UpdateProfileForm) Validate(ctx *macaron.Context, errs binding.Errors)
|
|||
}
|
||||
|
||||
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 {
|
||||
|
|
|
@ -20,7 +20,7 @@ import (
|
|||
"github.com/macaron-contrib/session"
|
||||
|
||||
"github.com/gogits/gogs/modules/log"
|
||||
// "github.com/gogits/gogs-ng/modules/ssh"
|
||||
// "github.com/gogits/gogs/modules/ssh"
|
||||
)
|
||||
|
||||
type Scheme string
|
||||
|
@ -488,5 +488,5 @@ func NewServices() {
|
|||
newRegisterMailService()
|
||||
newNotifyMailService()
|
||||
newWebhookService()
|
||||
// ssh.Listen("2022")
|
||||
// ssh.Listen("2222")
|
||||
}
|
||||
|
|
|
@ -13,9 +13,8 @@ import (
|
|||
"os/exec"
|
||||
"strings"
|
||||
|
||||
"code.google.com/p/go.crypto/ssh"
|
||||
|
||||
"github.com/Unknwon/com"
|
||||
"golang.org/x/crypto/ssh"
|
||||
|
||||
"github.com/gogits/gogs/modules/log"
|
||||
)
|
||||
|
@ -35,8 +34,11 @@ func handleServerConn(keyId string, chans <-chan ssh.NewChannel) {
|
|||
go func(in <-chan *ssh.Request) {
|
||||
defer channel.Close()
|
||||
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)
|
||||
if req.WantReply {
|
||||
fmt.Println(req.Reply(true, nil))
|
||||
}
|
||||
switch req.Type {
|
||||
case "env":
|
||||
args := strings.Split(strings.Replace(payload, "\x00", "", -1), "\v")
|
||||
|
@ -54,7 +56,7 @@ func handleServerConn(keyId string, chans <-chan ssh.NewChannel) {
|
|||
case "exec":
|
||||
os.Setenv("SSH_ORIGINAL_COMMAND", 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.Stdin = channel
|
||||
cmd.Stderr = channel.Stderr()
|
||||
|
@ -65,7 +67,6 @@ func handleServerConn(keyId string, chans <-chan ssh.NewChannel) {
|
|||
}
|
||||
}
|
||||
fmt.Println("Done:", ok)
|
||||
req.Reply(ok, nil) // BUG: Git on Mac seems not know this reply and hang?
|
||||
}
|
||||
fmt.Println("Done!!!")
|
||||
}(requests)
|
||||
|
@ -101,7 +102,7 @@ func Listen(port string) {
|
|||
config := &ssh.ServerConfig{
|
||||
PublicKeyCallback: func(conn ssh.ConnMetadata, key ssh.PublicKey) (*ssh.Permissions, error) {
|
||||
// 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;
|
||||
}
|
||||
#profile-body {
|
||||
margin-left: 10px;
|
||||
margin-left: 20px;
|
||||
}
|
||||
|
|
|
@ -55,5 +55,5 @@
|
|||
}
|
||||
}
|
||||
#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) {
|
||||
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 {
|
||||
fr, err := form.Avatar.Open()
|
||||
if err != nil {
|
||||
|
@ -108,8 +113,8 @@ func SettingsAvatar(ctx *middleware.Context, form auth.UploadAvatarForm) {
|
|||
ctx.Flash.Error(err.Error())
|
||||
return
|
||||
}
|
||||
ctx.Flash.Success(ctx.Tr("settings.upload_avatar_success"))
|
||||
}
|
||||
ctx.Flash.Success(ctx.Tr("settings.update_avatar_success"))
|
||||
}
|
||||
|
||||
func SettingsPassword(ctx *middleware.Context) {
|
||||
|
|
|
@ -58,13 +58,18 @@
|
|||
<hr>
|
||||
<form class="form form-align" id="user-profile-form" action="{{AppSubUrl}}/user/settings/avatar" method="post" enctype="multipart/form-data">
|
||||
{{.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">
|
||||
<label>{{.i18n.Tr "settings.choose_new_avatar"}}</label>
|
||||
<input name="avatar" type="file" required />
|
||||
<input name="avatar" type="file" />
|
||||
</div>
|
||||
<div class="field">
|
||||
<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>
|
||||
</form>
|
||||
</div>
|
||||
|
|
Loading…
Reference in a new issue