Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allows external rendering of other filetypes 2 #8300

Merged
merged 11 commits into from
Oct 21, 2019
14 changes: 14 additions & 0 deletions routers/repo/view.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 != "" {
HarvsG marked this conversation as resolved.
Show resolved Hide resolved
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() {
Expand Down