Ver código fonte

serve video files using the HTML5 video tag (#418)

* serve video files using the HTML5 video tag

* lint fix: add comment to IsVideoFile
tags/v1.0.0
Nico Mandery 7 anos atrás
pai
commit
6ade13e86e

+ 1
- 0
conf/locale/locale_en-US.ini Ver arquivo

file_view_raw = View Raw file_view_raw = View Raw
file_permalink = Permalink file_permalink = Permalink
file_too_large = This file is too large to be shown 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.new_file = New file
editor.upload_file = Upload file editor.upload_file = Upload file

+ 5
- 0
modules/base/tool.go Ver arquivo

func IsPDFFile(data []byte) bool { func IsPDFFile(data []byte) bool {
return strings.Index(http.DetectContentType(data), "application/pdf") != -1 return strings.Index(http.DetectContentType(data), "application/pdf") != -1
} }

// IsVideoFile detectes if data is an video format
func IsVideoFile(data []byte) bool {
return strings.Index(http.DetectContentType(data), "video/") != -1
}

+ 2
- 0
routers/repo/view.go Ver arquivo



case base.IsPDFFile(buf): case base.IsPDFFile(buf):
ctx.Data["IsPDFFile"] = true ctx.Data["IsPDFFile"] = true
case base.IsVideoFile(buf):
ctx.Data["IsVideoFile"] = true
case base.IsImageFile(buf): case base.IsImageFile(buf):
ctx.Data["IsImageFile"] = true ctx.Data["IsImageFile"] = true
} }

+ 4
- 0
templates/repo/view_file.tmpl Ver arquivo

<div class="view-raw ui center"> <div class="view-raw ui center">
{{if .IsImageFile}} {{if .IsImageFile}}
<img src="{{EscapePound $.RawFileLink}}"> <img src="{{EscapePound $.RawFileLink}}">
{{else if .IsVideoFile}}
<video controls src="{{EscapePound $.RawFileLink}}">
<strong>{{.i18n.Tr "repo.video_not_supported_in_browser"}}</strong>
</video>
{{else if .IsPDFFile}} {{else if .IsPDFFile}}
<iframe width="100%" height="600px" src="{{AppSubUrl}}/plugins/pdfjs-1.4.20/web/viewer.html?file={{EscapePound $.RawFileLink}}"></iframe> <iframe width="100%" height="600px" src="{{AppSubUrl}}/plugins/pdfjs-1.4.20/web/viewer.html?file={{EscapePound $.RawFileLink}}"></iframe>
{{else}} {{else}}

Carregando…
Cancelar
Salvar