forked from Gitlink/gitea-1156
add:Delete Wiki
This commit is contained in:
parent
37b73aa99b
commit
4920cd6040
|
@ -127,6 +127,28 @@ func (ctx *APIContext) FileNameError(objs ...interface{}) {
|
||||||
"errors": errors,
|
"errors": errors,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
func (ctx *APIContext) FileExistError(objs ...interface{}) {
|
||||||
|
var message = "file does not exist"
|
||||||
|
var errors []string
|
||||||
|
|
||||||
|
for _, obj := range objs {
|
||||||
|
// Ignore nil
|
||||||
|
if obj == nil {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
|
||||||
|
if err, ok := obj.(error); ok {
|
||||||
|
errors = append(errors, err.Error())
|
||||||
|
} else {
|
||||||
|
message = obj.(string)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
ctx.JSON(500, map[string]interface{}{
|
||||||
|
"message": message,
|
||||||
|
"documentation_url": setting.API.SwaggerURL,
|
||||||
|
"errors": errors,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
// InternalServerError responds with an error message to the client with the error as a message
|
// InternalServerError responds with an error message to the client with the error as a message
|
||||||
// and the file and line of the caller.
|
// and the file and line of the caller.
|
||||||
|
|
|
@ -325,10 +325,6 @@ func GetWiki(ctx *context.APIContext) {
|
||||||
ctx.JSON(http.StatusOK, wiki)
|
ctx.JSON(http.StatusOK, wiki)
|
||||||
}
|
}
|
||||||
|
|
||||||
func DeleteWiki(ctx *context.APIContext) {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
func EditWiki(ctx *context.APIContext) {
|
func EditWiki(ctx *context.APIContext) {
|
||||||
// swagger:operation PATCH /repos/{owner}/{repo}/wikies/{pagename} repository repoEditWiki
|
// swagger:operation PATCH /repos/{owner}/{repo}/wikies/{pagename} repository repoEditWiki
|
||||||
// ---
|
// ---
|
||||||
|
@ -438,3 +434,42 @@ func EditWiki(ctx *context.APIContext) {
|
||||||
}
|
}
|
||||||
ctx.JSON(http.StatusOK, wiki)
|
ctx.JSON(http.StatusOK, wiki)
|
||||||
}
|
}
|
||||||
|
func DeleteWiki(ctx *context.APIContext) {
|
||||||
|
// swagger:operation DELETE /repos/{owner}/{repo}/wikies/{pagename} repository repoDeleteWiki
|
||||||
|
// ---
|
||||||
|
// summary: Delete a wiki in a repository
|
||||||
|
// produces:
|
||||||
|
// - application/json
|
||||||
|
// parameters:
|
||||||
|
// - name: owner
|
||||||
|
// in: path
|
||||||
|
// description: owner of the repo
|
||||||
|
// type: string
|
||||||
|
// required: true
|
||||||
|
// - name: repo
|
||||||
|
// in: path
|
||||||
|
// description: name of the repo
|
||||||
|
// type: string
|
||||||
|
// required: true
|
||||||
|
// - name: pagename
|
||||||
|
// in: path
|
||||||
|
// description: name of the wiki
|
||||||
|
// type: string
|
||||||
|
// required: true
|
||||||
|
// responses:
|
||||||
|
// "204":
|
||||||
|
// "$ref": "#/responses/empty"
|
||||||
|
// "500":
|
||||||
|
// "$ref": "#/responses/noFound"
|
||||||
|
|
||||||
|
wikiName := wiki_service.NormalizeWikiName(ctx.Params(":page"))
|
||||||
|
if len(wikiName) == 0 {
|
||||||
|
wikiName = "Home"
|
||||||
|
}
|
||||||
|
|
||||||
|
err2 := wiki_service.DeleteWikiPage(ctx.User, ctx.Repo.Repository, wikiName)
|
||||||
|
if err2 != nil {
|
||||||
|
ctx.FileExistError()
|
||||||
|
return
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -9887,6 +9887,47 @@
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"delete": {
|
||||||
|
"produces": [
|
||||||
|
"application/json"
|
||||||
|
],
|
||||||
|
"tags": [
|
||||||
|
"repository"
|
||||||
|
],
|
||||||
|
"summary": "Delete a wiki in a repository",
|
||||||
|
"operationId": "repoDeleteWiki",
|
||||||
|
"parameters": [
|
||||||
|
{
|
||||||
|
"type": "string",
|
||||||
|
"description": "owner of the repo",
|
||||||
|
"name": "owner",
|
||||||
|
"in": "path",
|
||||||
|
"required": true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "string",
|
||||||
|
"description": "name of the repo",
|
||||||
|
"name": "repo",
|
||||||
|
"in": "path",
|
||||||
|
"required": true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "string",
|
||||||
|
"description": "name of the wiki",
|
||||||
|
"name": "pagename",
|
||||||
|
"in": "path",
|
||||||
|
"required": true
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"responses": {
|
||||||
|
"204": {
|
||||||
|
"$ref": "#/responses/empty"
|
||||||
|
},
|
||||||
|
"500": {
|
||||||
|
"$ref": "#/responses/noFound"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
"patch": {
|
"patch": {
|
||||||
"produces": [
|
"produces": [
|
||||||
"application/json"
|
"application/json"
|
||||||
|
|
Loading…
Reference in New Issue