From 935db7c618bd35268599d3dab011b16875b3f14b Mon Sep 17 00:00:00 2001 From: andreimarcu Date: Sun, 27 Sep 2015 23:07:15 -0400 Subject: [PATCH] Fixed pdf/audio --- display.go | 8 ++++++++ server.go | 2 +- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/display.go b/display.go index 8bd69ac..f80353b 100644 --- a/display.go +++ b/display.go @@ -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 } diff --git a/server.go b/server.go index 785af29..6e057fa 100644 --- a/server.go +++ b/server.go @@ -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 {