mirror of
https://codeberg.org/forgejo/forgejo.git
synced 2024-11-08 18:04:14 +01:00
Fix #285
This commit is contained in:
parent
63cc14062a
commit
0f907301b7
9 changed files with 48 additions and 15 deletions
12
cmd/fix.go
12
cmd/fix.go
|
@ -11,6 +11,7 @@ import (
|
|||
"io/ioutil"
|
||||
"os"
|
||||
"path"
|
||||
"runtime"
|
||||
"strings"
|
||||
|
||||
"github.com/codegangsta/cli"
|
||||
|
@ -93,9 +94,16 @@ func rewriteAuthorizedKeys(sshPath, oldPath, newPath string) error {
|
|||
}
|
||||
|
||||
func rewriteUpdateHook(path, appPath string) error {
|
||||
rp := strings.NewReplacer("\\", "/", " ", "\\ ")
|
||||
if runtime.GOOS == "windows" {
|
||||
rp := strings.NewReplacer("\\", "/")
|
||||
appPath = "\"" + rp.Replace(appPath) + "\""
|
||||
} else {
|
||||
rp := strings.NewReplacer("\\", "/", " ", "\\ ")
|
||||
appPath = rp.Replace(appPath)
|
||||
}
|
||||
|
||||
if err := ioutil.WriteFile(path, []byte(fmt.Sprintf(models.TPL_UPDATE_HOOK,
|
||||
setting.ScriptType, rp.Replace(appPath))), os.ModePerm); err != nil {
|
||||
setting.ScriptType, appPath)), os.ModePerm); err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
|
|
|
@ -103,7 +103,10 @@ func runWeb(*cli.Context) {
|
|||
r.Post("/markdown/raw", v1.MarkdownRaw)
|
||||
|
||||
// Users.
|
||||
r.Get("/users/search", v1.SearchUser)
|
||||
r.Get("/users/search", v1.SearchUsers)
|
||||
|
||||
// Repositories.
|
||||
r.Get("/orgs/:org/repos/search", v1.SearchOrgRepositoreis)
|
||||
|
||||
r.Any("**", func(ctx *middleware.Context) {
|
||||
ctx.JSON(404, &base.ApiJsonErr{"Not Found", v1.DOC_URL})
|
||||
|
@ -182,6 +185,8 @@ func runWeb(*cli.Context) {
|
|||
r.Get("/:authid/delete", admin.DeleteAuthSource)
|
||||
}, adminReq)
|
||||
|
||||
m.Get("/:username", ignSignIn, user.Profile)
|
||||
|
||||
if martini.Env == martini.Dev {
|
||||
m.Get("/template/**", dev.TemplatePreview)
|
||||
dev.RegisterDebugRoutes(m)
|
||||
|
|
2
gogs.go
2
gogs.go
|
@ -17,7 +17,7 @@ import (
|
|||
"github.com/gogits/gogs/modules/setting"
|
||||
)
|
||||
|
||||
const APP_VER = "0.4.5.0707 Alpha"
|
||||
const APP_VER = "0.4.5.0712 Alpha"
|
||||
|
||||
func init() {
|
||||
runtime.GOMAXPROCS(runtime.NumCPU())
|
||||
|
|
|
@ -11,6 +11,7 @@ import (
|
|||
"os"
|
||||
"path"
|
||||
"path/filepath"
|
||||
"runtime"
|
||||
"sort"
|
||||
"strings"
|
||||
"time"
|
||||
|
@ -359,11 +360,17 @@ func initRepository(f string, user *User, repo *Repository, initReadme bool, rep
|
|||
return err
|
||||
}
|
||||
|
||||
rp := strings.NewReplacer("\\", "/", " ", "\\ ")
|
||||
if runtime.GOOS == "windows" {
|
||||
rp := strings.NewReplacer("\\", "/")
|
||||
appPath = "\"" + rp.Replace(appPath) + "\""
|
||||
} else {
|
||||
rp := strings.NewReplacer("\\", "/", " ", "\\ ")
|
||||
appPath = rp.Replace(appPath)
|
||||
}
|
||||
|
||||
// hook/post-update
|
||||
if err := createHookUpdate(filepath.Join(repoPath, "hooks", "update"),
|
||||
fmt.Sprintf(TPL_UPDATE_HOOK, setting.ScriptType,
|
||||
rp.Replace(appPath))); err != nil {
|
||||
fmt.Sprintf(TPL_UPDATE_HOOK, setting.ScriptType, appPath)); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
|
|
|
@ -500,7 +500,7 @@ func SearchUserByName(key string, limit int) (us []*User, err error) {
|
|||
key = strings.ToLower(key)
|
||||
|
||||
us = make([]*User, 0, limit)
|
||||
err = x.Limit(limit).Where("lower_name like '%" + key + "%'").Find(&us)
|
||||
err = x.Limit(limit).Where("type=0").And("lower_name like '%" + key + "%'").Find(&us)
|
||||
return us, err
|
||||
}
|
||||
|
||||
|
|
|
@ -163,7 +163,7 @@ func Users(ctx *middleware.Context) {
|
|||
if p < 1 {
|
||||
p = 1
|
||||
}
|
||||
pageNum := 100
|
||||
pageNum := 50
|
||||
count := models.CountUsers()
|
||||
curCount := int64((p-1)*pageNum + pageNum)
|
||||
if curCount > count {
|
||||
|
@ -192,7 +192,7 @@ func Repositories(ctx *middleware.Context) {
|
|||
if p < 1 {
|
||||
p = 1
|
||||
}
|
||||
pageNum := 2
|
||||
pageNum := 50
|
||||
count := models.CountRepositories()
|
||||
curCount := int64((p-1)*pageNum + pageNum)
|
||||
if curCount > count {
|
||||
|
|
13
routers/api/v1/repositories.go
Normal file
13
routers/api/v1/repositories.go
Normal file
|
@ -0,0 +1,13 @@
|
|||
// Copyright 2014 The Gogs Authors. All rights reserved.
|
||||
// Use of this source code is governed by a MIT-style
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
package v1
|
||||
|
||||
import (
|
||||
"github.com/gogits/gogs/modules/middleware"
|
||||
)
|
||||
|
||||
func SearchOrgRepositoreis(ctx *middleware.Context) {
|
||||
|
||||
}
|
|
@ -15,7 +15,7 @@ type user struct {
|
|||
AvatarLink string `json:"avatar"`
|
||||
}
|
||||
|
||||
func SearchUser(ctx *middleware.Context) {
|
||||
func SearchUsers(ctx *middleware.Context) {
|
||||
q := ctx.Query("q")
|
||||
limit, err := base.StrTo(ctx.Query("limit")).Int()
|
||||
if err != nil {
|
||||
|
|
|
@ -47,13 +47,13 @@ func SettingPost(ctx *middleware.Context, form auth.UpdateProfileForm) {
|
|||
if ctx.User.Name != form.UserName {
|
||||
isExist, err := models.IsUserExist(form.UserName)
|
||||
if err != nil {
|
||||
ctx.Handle(500, "user.Setting(update: check existence)", err)
|
||||
ctx.Handle(500, "user.SettingPost(update: check existence)", err)
|
||||
return
|
||||
} else if isExist {
|
||||
ctx.RenderWithErr("User name has been taken.", "user/setting", &form)
|
||||
ctx.RenderWithErr("User name has been taken.", SETTING, &form)
|
||||
return
|
||||
} else if err = models.ChangeUserName(ctx.User, form.UserName); err != nil {
|
||||
ctx.Handle(500, "user.Setting(change user name)", err)
|
||||
ctx.Handle(500, "user.SettingPost(change user name)", err)
|
||||
return
|
||||
}
|
||||
log.Trace("%s User name changed: %s -> %s", ctx.Req.RequestURI, ctx.User.Name, form.UserName)
|
||||
|
@ -68,7 +68,7 @@ func SettingPost(ctx *middleware.Context, form auth.UpdateProfileForm) {
|
|||
ctx.User.Avatar = base.EncodeMd5(form.Avatar)
|
||||
ctx.User.AvatarEmail = form.Avatar
|
||||
if err := models.UpdateUser(ctx.User); err != nil {
|
||||
ctx.Handle(500, "setting.Setting(UpdateUser)", err)
|
||||
ctx.Handle(500, "setting.SettingPost(UpdateUser)", err)
|
||||
return
|
||||
}
|
||||
log.Trace("%s User setting updated: %s", ctx.Req.RequestURI, ctx.User.LowerName)
|
||||
|
|
Loading…
Reference in a new issue