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