summaryrefslogtreecommitdiffstats
path: root/routers
diff options
context:
space:
mode:
authorGeorge Harvey <11440490+HarvsG@users.noreply.github.com>2019-10-21 07:54:18 +0100
committerzeripath <art27@cantab.net>2019-10-21 07:54:18 +0100
commit481c66a91f01ebbc3ebecab1c010791e232bb2ca (patch)
treea8ee9e2527103400844c63e65815431338ba65b7 /routers
parent28f60bb5cb24c71fdbefe16c2d86943fb4cf8a08 (diff)
downloadgitea-481c66a91f01ebbc3ebecab1c010791e232bb2ca.tar.gz
gitea-481c66a91f01ebbc3ebecab1c010791e232bb2ca.zip
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
Diffstat (limited to 'routers')
-rw-r--r--routers/repo/view.go14
1 files changed, 14 insertions, 0 deletions
diff --git a/routers/repo/view.go b/routers/repo/view.go
index c4e6a69220..a2e431e435 100644
--- a/routers/repo/view.go
+++ b/routers/repo/view.go
@@ -346,6 +346,20 @@ func renderFile(ctx *context.Context, entry *git.TreeEntry, treeLink, rawLink st
ctx.Data["IsAudioFile"] = true
case base.IsImageFile(buf):
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() {