|
|
|
@ -1,8 +1,11 @@
|
|
|
|
|
package repo |
|
|
|
|
|
|
|
|
|
import ( |
|
|
|
|
repo_model "code.gitea.io/gitea/models/repo" |
|
|
|
|
"code.gitea.io/gitea/modules/base" |
|
|
|
|
"code.gitea.io/gitea/modules/context" |
|
|
|
|
"code.gitea.io/gitea/modules/markup" |
|
|
|
|
"code.gitea.io/gitea/modules/markup/markdown" |
|
|
|
|
"net/http" |
|
|
|
|
) |
|
|
|
|
|
|
|
|
@ -24,3 +27,40 @@ func Competences(ctx *context.Context) {
|
|
|
|
|
|
|
|
|
|
ctx.HTML(http.StatusOK, tplCompetences) |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
func ToggleCompetences(ctx *context.Context) { |
|
|
|
|
if !ctx.IsSigned { |
|
|
|
|
ctx.Error(http.StatusForbidden) |
|
|
|
|
return |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
repo := ctx.Repo.Repository |
|
|
|
|
toggledContent := ctx.FormString("content") |
|
|
|
|
|
|
|
|
|
content, err := markdown.RenderString(&markup.RenderContext{ |
|
|
|
|
URLPrefix: ctx.FormString("context"), // FIXME: <- IS THIS SAFE ?
|
|
|
|
|
Metas: ctx.Repo.Repository.ComposeMetas(), |
|
|
|
|
GitRepo: ctx.Repo.GitRepo, |
|
|
|
|
Ctx: ctx, |
|
|
|
|
}, toggledContent) |
|
|
|
|
if err != nil { |
|
|
|
|
ctx.ServerError("RenderString", err) |
|
|
|
|
return |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
repo.Competences = toggledContent |
|
|
|
|
err = repo_model.UpdateRepositoryCols(repo, "competences") |
|
|
|
|
if err != nil { |
|
|
|
|
ctx.ServerError("ToggleCompetences", err) |
|
|
|
|
return |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
responseBody := map[string]interface{}{ |
|
|
|
|
"content": content, |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
ctx.JSON( |
|
|
|
|
http.StatusOK, |
|
|
|
|
responseBody, |
|
|
|
|
) |
|
|
|
|
} |
|
|
|
|