fix:wikies
This commit is contained in:
parent
554fd29ebb
commit
10e2b49064
|
@ -290,13 +290,8 @@ func NewWikiPost(ctx *context.APIContext, form api.WikiOption) {
|
|||
}
|
||||
return
|
||||
}
|
||||
|
||||
//ctx.Redirect(ctx.Repo.RepoLink + "/wiki/" + wiki_service.NameToSubURL(wikiName))
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
func EditWikiPost(ctx *context.APIContext, form api.WikiOption) {
|
||||
ctx.Data["Title"] = ctx.Tr("repo.wiki.new_page")
|
||||
ctx.Data["PageIsWiki"] = true
|
||||
|
@ -313,6 +308,5 @@ func EditWikiPost(ctx *context.APIContext, form api.WikiOption) {
|
|||
ctx.ServerError("EditWikiPage", err)
|
||||
return
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -103,7 +103,7 @@ func WikiList(ctx *context.APIContext) {
|
|||
}
|
||||
//根据创建时间,按最新的时间排序
|
||||
sort.Slice(wikiesList,func(i, j int) bool{
|
||||
return wikiesList[i].Commit.Commiter.When > wikiesList[j].Commit.Commiter.When
|
||||
return wikiesList[i].Commit.Commiter.When < wikiesList[j].Commit.Commiter.When
|
||||
})
|
||||
ctx.JSON(http.StatusOK, wikiesList)
|
||||
}
|
||||
|
@ -365,56 +365,13 @@ func DeleteWiki(ctx *context.APIContext) {
|
|||
// "500":
|
||||
// "$ref": "#/responses/noFound"
|
||||
|
||||
|
||||
wikiRepo, commit, err := wikies.FindWikiRepoCommit(ctx)
|
||||
if err != nil {
|
||||
if wikiRepo != nil {
|
||||
wikiRepo.Close()
|
||||
}
|
||||
return
|
||||
}
|
||||
entries, err1 := commit.ListEntries()
|
||||
if err1 != nil {
|
||||
if wikiRepo != nil {
|
||||
wikiRepo.Close()
|
||||
}
|
||||
return
|
||||
}
|
||||
wikies := make([]api.WikiMeta, 0, len(entries))
|
||||
for _, entry := range entries {
|
||||
|
||||
name, err := wiki_service.FilenameToName(entry.Name())
|
||||
if err != nil {
|
||||
if models.IsErrWikiInvalidFileName(err) {
|
||||
continue
|
||||
}
|
||||
if wikiRepo != nil {
|
||||
wikiRepo.Close()
|
||||
}
|
||||
return
|
||||
}
|
||||
wikies = append(wikies, api.WikiMeta{
|
||||
Name: name,
|
||||
})
|
||||
|
||||
}
|
||||
wikiName := wiki_service.NormalizeWikiName(ctx.Params(":page"))
|
||||
if len(wikiName) == 0 {
|
||||
wikiName = "Home"
|
||||
}
|
||||
//Does the file exist
|
||||
for _, wiky := range wikies {
|
||||
if wikiName == wiky.Name{
|
||||
continue
|
||||
}else{
|
||||
ctx.FileExistError()
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
err2 := wiki_service.DeleteWikiPage(ctx.User, ctx.Repo.Repository, wikiName)
|
||||
if err2 != nil{
|
||||
//ctx.Error(http.StatusInternalServerError,"DeleteWikiPage", err)
|
||||
ctx.FileExistError()
|
||||
return
|
||||
}
|
||||
|
|
|
@ -68,7 +68,7 @@ func FilenameToName(filename string) (string, error) {
|
|||
}
|
||||
// check filename
|
||||
func CheckFile(filename string) error {
|
||||
if(len(filename) <= 50 ){
|
||||
if(len(filename) <= 150 ){
|
||||
return nil
|
||||
}else {
|
||||
err := errors.New("The name is too long, please be less than 200 bytes")
|
||||
|
|
Loading…
Reference in New Issue