Fixed pdf/audio

This commit is contained in:
andreimarcu 2015-09-27 23:07:15 -04:00
parent d2c7be17c0
commit 935db7c618
2 changed files with 9 additions and 1 deletions

View File

@ -12,8 +12,10 @@ import (
)
var imageTpl = pongo2.Must(pongo2.FromCache("templates/display/image.html"))
var audioTpl = pongo2.Must(pongo2.FromCache("templates/display/audio.html"))
var videoTpl = pongo2.Must(pongo2.FromCache("templates/display/video.html"))
var fileTpl = pongo2.Must(pongo2.FromCache("templates/display/file.html"))
var pdfTpl = pongo2.Must(pongo2.FromCache("templates/display/pdf.html"))
func fileDisplayHandler(c web.C, w http.ResponseWriter, r *http.Request) {
fileName := c.URLParams["name"]
@ -25,6 +27,8 @@ func fileDisplayHandler(c web.C, w http.ResponseWriter, r *http.Request) {
return
}
// file expiry checking
if err := magicmime.Open(magicmime.MAGIC_MIME_TYPE |
magicmime.MAGIC_SYMLINK |
magicmime.MAGIC_ERROR); err != nil {
@ -43,6 +47,10 @@ func fileDisplayHandler(c web.C, w http.ResponseWriter, r *http.Request) {
tpl = imageTpl
} else if strings.HasPrefix(mimetype, "video/") {
tpl = videoTpl
} else if strings.HasPrefix(mimetype, "audio/") {
tpl = audioTpl
} else if mimetype == "application/pdf" {
tpl = pdfTpl
} else {
tpl = fileTpl
}

View File

@ -35,7 +35,7 @@ func main() {
flag.StringVar(&Config.siteName, "sitename", "linx",
"name of the site")
flag.StringVar(&Config.siteURL, "siteurl", "http://"+Config.bind+"/",
"site base url")
"site base url (including trailing slash)")
flag.Parse()
if Config.noLogs {