@@ -420,10 +420,10 @@ func DiffPreviewPost(ctx *context.Context) { | |||
} | |||
if diff.NumFiles == 0 { | |||
ctx.HTMLString(http.StatusOK, `<div class="tw-p-6">`+ctx.Locale.TrString("repo.editor.no_changes_to_show")+`</div>`) | |||
return | |||
ctx.Data["File"] = nil | |||
} else { | |||
ctx.Data["File"] = diff.Files[0] | |||
} | |||
ctx.Data["File"] = diff.Files[0] | |||
ctx.HTML(http.StatusOK, tplEditDiffPreview) | |||
} |
@@ -137,15 +137,6 @@ func (b *Base) JSON(status int, content any) { | |||
} | |||
} | |||
// HTMLString renders string as HTML | |||
func (b *Base) HTMLString(status int, html string) { | |||
b.Resp.Header().Set("Content-Type", "text/html;charset=utf-8") | |||
b.Resp.WriteHeader(status) | |||
if _, err := b.Resp.Write([]byte(html)); err != nil { | |||
log.Error("Render HTMLString failed: %v", err) | |||
} | |||
} | |||
// RemoteAddr returns the client machine ip address | |||
func (b *Base) RemoteAddr() string { | |||
return b.Req.RemoteAddr |
@@ -1,3 +1,4 @@ | |||
{{if .File}} | |||
<div class="diff-file-box"> | |||
<div class="ui attached table segment"> | |||
<div class="file-body file-code code-diff code-diff-unified unicode-escaped"> | |||
@@ -9,3 +10,8 @@ | |||
</div> | |||
</div> | |||
</div> | |||
{{else}} | |||
<div class="tw-p-6"> | |||
{{ctx.Locale.Tr "repo.editor.no_changes_to_show"}} | |||
</div> | |||
{{end}} |