fix:wiki
This commit is contained in:
parent
e26a306415
commit
ad679b575e
|
@ -994,7 +994,9 @@ func (repo *Repository) cloneLink(isWiki bool) *CloneLink {
|
|||
func (repo *Repository) CloneLink() (cl *CloneLink) {
|
||||
return repo.cloneLink(false)
|
||||
}
|
||||
|
||||
func (repo *Repository) CloneWikiLink() (cl *CloneLink) {
|
||||
return repo.cloneLink(true)
|
||||
}
|
||||
// CheckCreateRepository check if could created a repository
|
||||
func CheckCreateRepository(doer, u *User, name string) error {
|
||||
if !doer.CanCreateRepo() {
|
||||
|
|
|
@ -35,6 +35,7 @@ type WikiResponse struct {
|
|||
CommitCounts int64 `json:"commit_counts"`
|
||||
MdContent string `json:"md_content"`
|
||||
SimpleContent string `json:"simple_content"`
|
||||
WikiCloneLink CloneLink `json:"wiki_clone_link"`
|
||||
}
|
||||
|
||||
type WikiOption struct {
|
||||
|
|
|
@ -8,8 +8,6 @@ import (
|
|||
api "code.gitea.io/gitea/modules/structs"
|
||||
"code.gitea.io/gitea/modules/wikies"
|
||||
wiki_service "code.gitea.io/gitea/services/wiki"
|
||||
"fmt"
|
||||
|
||||
"net/http"
|
||||
)
|
||||
|
||||
|
@ -35,7 +33,8 @@ func WikiList(ctx *context.APIContext) {
|
|||
// "$ref": "#/responses/WikiList"
|
||||
|
||||
repository := ctx.Repo.Repository
|
||||
wikiCloneLink:= repository.CloneLink()
|
||||
wikiCloneLink:= repository.CloneWikiLink()
|
||||
|
||||
wikiRepo, commit, err := wikies.FindWikiRepoCommit(ctx)
|
||||
if err != nil {
|
||||
if wikiRepo != nil {
|
||||
|
@ -132,6 +131,10 @@ func GetWiki(ctx *context.APIContext) {
|
|||
|
||||
wikiRepo, commit, _ := wikies.FindWikiRepoCommit(ctx)
|
||||
|
||||
//repository := ctx.Repo.Repository
|
||||
//wikiCloneLink:= repository.CloneWikiLink()
|
||||
repository := ctx.Repo.Repository
|
||||
wikiCloneLink:= repository.CloneWikiLink()
|
||||
pageName := wiki_service.NormalizeWikiName(ctx.Params(":page"))
|
||||
if len(pageName) == 0 {
|
||||
pageName = "Home"
|
||||
|
@ -158,6 +161,10 @@ func GetWiki(ctx *context.APIContext) {
|
|||
commitsCount, _ := wikiRepo.FileCommitsCount("master", pageFilename)
|
||||
|
||||
wiki := api.WikiResponse{
|
||||
WikiCloneLink: api.CloneLink{
|
||||
HTTPS: wikiCloneLink.HTTPS,
|
||||
SSH: wikiCloneLink.SSH,
|
||||
},
|
||||
WikiMeta: api.WikiMeta{
|
||||
Name: pageName,
|
||||
Commit: api.WikiCommit{
|
||||
|
@ -282,7 +289,13 @@ func EditWiki(ctx *context.APIContext, form api.WikiOption) {
|
|||
// "200":
|
||||
// "$ref": "#/responses/Wiki
|
||||
oldWikiName := wiki_service.NormalizeWikiName(ctx.Params(":page"))
|
||||
|
||||
newWikiName := wiki_service.NormalizeWikiName(form.Name)
|
||||
err1 := wiki_service.CheckFile(newWikiName)
|
||||
if err1 != nil{
|
||||
ctx.FileNameError()
|
||||
return
|
||||
}
|
||||
err2 := wiki_service.EditWikiPage(ctx.User, ctx.Repo.Repository, oldWikiName,newWikiName, form.Content, form.CommitMessage)
|
||||
if err2 != nil{
|
||||
ctx.ServerError("EditWikiPage", err2)
|
||||
|
@ -298,7 +311,6 @@ func EditWiki(ctx *context.APIContext, form api.WikiOption) {
|
|||
return
|
||||
}
|
||||
}
|
||||
fmt.Println(form)
|
||||
wiki := api.WikiResponse{
|
||||
WikiMeta: api.WikiMeta{
|
||||
Name: form.Name,
|
||||
|
|
Loading…
Reference in New Issue