wikies
This commit is contained in:
parent
b8599a9fa2
commit
64ef5a1567
modules
routers/api/v1/repo
services/wiki
templates/swagger
|
@ -198,7 +198,6 @@ func (repo *Repository) GetCommitByPath(relpath string) (*Commit, error) {
|
|||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
commits, err := repo.parsePrettyFormatLogToList(stdout)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
package structs
|
||||
|
||||
type WikiesResponse struct {
|
||||
|
||||
When int64 `json:"when"`
|
||||
WikiMeta
|
||||
WikiCloneLink CloneLink `json:"wiki_clone_link"`
|
||||
}
|
||||
|
@ -22,7 +22,7 @@ type WikiCommit struct {
|
|||
ID string `json:"id"`
|
||||
Message string `json:"message"`
|
||||
Author WikiUser `json:"author"`
|
||||
Commiter WikiUser `json:"-"`
|
||||
Commiter WikiUser `json:"commiter"`
|
||||
}
|
||||
|
||||
type WikiUser struct {
|
||||
|
|
|
@ -313,12 +313,3 @@ func EditWikiPost(ctx *context.APIContext, form api.WikiOption) {
|
|||
return
|
||||
}
|
||||
}
|
||||
|
||||
//func GetWikiesByRepoID(repoID int64 ) ([]*api.WikiesResponse, error) {
|
||||
//
|
||||
//
|
||||
// //sess := listOptions.getPaginatedSession()
|
||||
// //webhooks := make([]*Webhook, 0, listOptions.PageSize)
|
||||
//
|
||||
// //return webhooks, sess.Find(&webhooks, &Webhook{RepoID: repoID})
|
||||
//}
|
||||
|
|
|
@ -8,9 +8,9 @@ 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"
|
||||
"sort"
|
||||
|
||||
)
|
||||
|
||||
func WikiList(ctx *context.APIContext) {
|
||||
|
@ -34,22 +34,13 @@ func WikiList(ctx *context.APIContext) {
|
|||
// "200":
|
||||
// "$ref": "#/responses/WikiList"
|
||||
|
||||
|
||||
if !ctx.Repo.Repository.HasWiki() {
|
||||
ctx.CheckHasWiki()
|
||||
return
|
||||
}
|
||||
|
||||
repository := ctx.Repo.Repository
|
||||
wikiCloneLink := repository.CloneWikiLink()
|
||||
wikiRepo, commit, err := wikies.FindWikiRepoCommit(ctx)
|
||||
|
||||
|
||||
|
||||
fmt.Println("wikiRepo================================\n",wikiRepo)
|
||||
|
||||
fmt.Println("repository===================\n", repository)
|
||||
|
||||
if err != nil {
|
||||
if wikiRepo != nil {
|
||||
wikiRepo.Close()
|
||||
|
@ -63,15 +54,6 @@ func WikiList(ctx *context.APIContext) {
|
|||
}
|
||||
return
|
||||
}
|
||||
|
||||
for _, entry := range entries {
|
||||
|
||||
fmt.Println("entry",entry)
|
||||
fmt.Println("entry name",entry.Name())
|
||||
fmt.Println()
|
||||
|
||||
}
|
||||
|
||||
wikiesList := make([]api.WikiesResponse, 0, len(entries))
|
||||
for _, entry := range entries {
|
||||
if !entry.IsRegular() {
|
||||
|
@ -82,7 +64,6 @@ func WikiList(ctx *context.APIContext) {
|
|||
if wikiRepo != nil {
|
||||
wikiRepo.Close()
|
||||
}
|
||||
|
||||
ctx.ServerError("GetCommit", err)
|
||||
return
|
||||
}
|
||||
|
@ -98,7 +79,7 @@ func WikiList(ctx *context.APIContext) {
|
|||
return
|
||||
}
|
||||
wikiesList = append(wikiesList, api.WikiesResponse{
|
||||
|
||||
When: c.Author.When.Unix(),
|
||||
WikiCloneLink: api.CloneLink{
|
||||
HTTPS: wikiCloneLink.HTTPS,
|
||||
SSH: wikiCloneLink.SSH,
|
||||
|
@ -114,7 +95,7 @@ func WikiList(ctx *context.APIContext) {
|
|||
Commiter: api.WikiUser{
|
||||
Name: c.Committer.Name,
|
||||
Email: c.Committer.Email,
|
||||
When: c.Author.When.Unix(),
|
||||
When: c.Committer.When.Unix(),
|
||||
},
|
||||
ID: c.ID.String(),
|
||||
Message: c.Message(),
|
||||
|
@ -244,11 +225,9 @@ func CreateWiki(ctx *context.APIContext, form api.WikiOption) {
|
|||
}
|
||||
OwnerName := ctx.Repo.Repository.OwnerName
|
||||
RepoName := ctx.Repo.Repository.Name
|
||||
|
||||
repository := ctx.Repo.Repository
|
||||
wikiCloneLink := repository.CloneWikiLink()
|
||||
wikies.NewWikiPost(ctx, form)
|
||||
|
||||
wikiRepo, commit, _ := wikies.FindWikiRepoCommit(ctx)
|
||||
data, entry, pageFilename, _ := wikies.WikiContentsByName(ctx, commit, form.Name)
|
||||
metas := ctx.Repo.Repository.ComposeDocumentMetas()
|
||||
|
|
|
@ -144,6 +144,10 @@ func updateWikiPage(doer *models.User, repo *models.Repository, oldWikiName, new
|
|||
}
|
||||
|
||||
newWikiPath := NameToFilename(newWikiName)
|
||||
|
||||
//进行url解码
|
||||
//newWikiPath, _ = url.QueryUnescape(newWikiPath)
|
||||
|
||||
if isNew {
|
||||
filesInIndex, err := gitRepo.LsFiles(newWikiPath)
|
||||
if err != nil {
|
||||
|
@ -180,6 +184,8 @@ func updateWikiPage(doer *models.User, repo *models.Repository, oldWikiName, new
|
|||
return err
|
||||
}
|
||||
|
||||
fmt.Println("newWikiPath======================",newWikiPath)
|
||||
|
||||
if err := gitRepo.AddObjectToIndex("100644", objectHash, newWikiPath); err != nil {
|
||||
log.Error("%v", err)
|
||||
return err
|
||||
|
|
|
@ -15506,6 +15506,9 @@
|
|||
"WikiCommit": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"_": {
|
||||
"$ref": "#/definitions/WikiUser"
|
||||
},
|
||||
"author": {
|
||||
"$ref": "#/definitions/WikiUser"
|
||||
},
|
||||
|
@ -15557,6 +15560,14 @@
|
|||
"type": "string",
|
||||
"x-go-name": "Name"
|
||||
},
|
||||
"owner_name": {
|
||||
"type": "string",
|
||||
"x-go-name": "OwnerName"
|
||||
},
|
||||
"repo_name": {
|
||||
"type": "string",
|
||||
"x-go-name": "RepoName"
|
||||
},
|
||||
"simple_content": {
|
||||
"type": "string",
|
||||
"x-go-name": "SimpleContent"
|
||||
|
@ -15596,13 +15607,10 @@
|
|||
"type": "string",
|
||||
"x-go-name": "Name"
|
||||
},
|
||||
"owner_name": {
|
||||
"type": "string",
|
||||
"x-go-name": "OwnerName"
|
||||
},
|
||||
"repo_name": {
|
||||
"type": "string",
|
||||
"x-go-name": "RepoName"
|
||||
"when": {
|
||||
"type": "integer",
|
||||
"format": "int64",
|
||||
"x-go-name": "When"
|
||||
},
|
||||
"wiki_clone_link": {
|
||||
"$ref": "#/definitions/CloneLink"
|
||||
|
|
Loading…
Reference in New Issue