mirror of
https://codeberg.org/forgejo/forgejo.git
synced 2024-12-26 01:14:10 -05:00
Allows external rendering of other filetypes 2 (#8300)
* allow external rendering of other filetypes fixes #4996 and #7614 allows rendering of non-tex files, or otherwise accounted for filetypes * Moves flie-size check before read() And performs gofmt -s * Only reads if markType is detected
This commit is contained in:
parent
28f60bb5cb
commit
481c66a91f
1 changed files with 14 additions and 0 deletions
|
@ -346,6 +346,20 @@ func renderFile(ctx *context.Context, entry *git.TreeEntry, treeLink, rawLink st
|
||||||
ctx.Data["IsAudioFile"] = true
|
ctx.Data["IsAudioFile"] = true
|
||||||
case base.IsImageFile(buf):
|
case base.IsImageFile(buf):
|
||||||
ctx.Data["IsImageFile"] = true
|
ctx.Data["IsImageFile"] = true
|
||||||
|
default:
|
||||||
|
if fileSize >= setting.UI.MaxDisplayFileSize {
|
||||||
|
ctx.Data["IsFileTooLarge"] = true
|
||||||
|
break
|
||||||
|
}
|
||||||
|
|
||||||
|
if markupType := markup.Type(blob.Name()); markupType != "" {
|
||||||
|
d, _ := ioutil.ReadAll(dataRc)
|
||||||
|
buf = append(buf, d...)
|
||||||
|
ctx.Data["IsMarkup"] = true
|
||||||
|
ctx.Data["MarkupType"] = markupType
|
||||||
|
ctx.Data["FileContent"] = string(markup.Render(blob.Name(), buf, path.Dir(treeLink), ctx.Repo.Repository.ComposeMetas()))
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if ctx.Repo.CanEnableEditor() {
|
if ctx.Repo.CanEnableEditor() {
|
||||||
|
|
Loading…
Reference in a new issue