Save content form on gist create error (#420)

This commit is contained in:
Thomas Miceli
2025-01-29 16:00:58 +01:00
committed by GitHub
parent d363743203
commit 62d56cd1c7
7 changed files with 105 additions and 91 deletions

View File

@ -62,6 +62,7 @@ func ProcessCreate(ctx *context.Context) error {
Content: escapedValue,
})
}
ctx.SetData("dto", dto)
err = ctx.Validate(dto)
if err != nil {

View File

@ -10,12 +10,12 @@ import (
func Edit(ctx *context.Context) error {
gist := ctx.GetData("gist").(*db.Gist)
files, err := gist.Files("HEAD", false)
gistDto, err := gist.ToDTO()
if err != nil {
return ctx.ErrorRes(500, "Error fetching files from repository", err)
return ctx.ErrorRes(500, "Error getting gist data", err)
}
ctx.SetData("files", files)
ctx.SetData("dto", gistDto)
ctx.SetData("htmlTitle", ctx.TrH("gist.edit.edit-gist", gist.Title))
return ctx.Html("edit.html")