Browse Source

Fixed pdf/audio

pull/12/head
andreimarcu 9 years ago
parent
commit
935db7c618
  1. 8
      display.go
  2. 2
      server.go

8
display.go

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

2
server.go

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

Loading…
Cancel
Save