diff --git a/conf/locale/locale_en-US.ini b/conf/locale/locale_en-US.ini index 98b4cc6f2..4267d6730 100644 --- a/conf/locale/locale_en-US.ini +++ b/conf/locale/locale_en-US.ini @@ -427,6 +427,7 @@ file_history = History file_view_raw = View Raw file_permalink = Permalink file_too_large = This file is too large to be shown +video_not_supported_in_browser = Your browser doesn't support HTML5 video tag. editor.new_file = New file editor.upload_file = Upload file diff --git a/modules/base/tool.go b/modules/base/tool.go index 52d1e178d..f42c8b855 100644 --- a/modules/base/tool.go +++ b/modules/base/tool.go @@ -533,3 +533,7 @@ func IsImageFile(data []byte) bool { func IsPDFFile(data []byte) bool { return strings.Index(http.DetectContentType(data), "application/pdf") != -1 } + +func IsVideoFile(data []byte) bool { + return strings.Index(http.DetectContentType(data), "video/") != -1 +} diff --git a/routers/repo/view.go b/routers/repo/view.go index c04ef1ee3..2c17ed8d0 100644 --- a/routers/repo/view.go +++ b/routers/repo/view.go @@ -198,6 +198,8 @@ func renderFile(ctx *context.Context, entry *git.TreeEntry, treeLink, rawLink st case base.IsPDFFile(buf): ctx.Data["IsPDFFile"] = true + case base.IsVideoFile(buf): + ctx.Data["IsVideoFile"] = true case base.IsImageFile(buf): ctx.Data["IsImageFile"] = true } diff --git a/templates/repo/view_file.tmpl b/templates/repo/view_file.tmpl index 68e844476..08d77c3f3 100644 --- a/templates/repo/view_file.tmpl +++ b/templates/repo/view_file.tmpl @@ -43,6 +43,10 @@
{{if .IsImageFile}} + {{else if .IsVideoFile}} + {{else if .IsPDFFile}} {{else}}