Browse Source

Order matters!

pull/73/head v1.1.7
andreimarcu 9 years ago
parent
commit
7c1a4640db
  1. 14
      display.go

14
display.go

@ -77,23 +77,23 @@ func fileDisplayHandler(c web.C, w http.ResponseWriter, r *http.Request) {
} else if metadata.Mimetype == "application/pdf" { } else if metadata.Mimetype == "application/pdf" {
tpl = Templates["display/pdf.html"] tpl = Templates["display/pdf.html"]
} else if strings.HasPrefix(metadata.Mimetype, "text/") || supportedBinExtension(extension) {
} else if extension == "story" {
if metadata.Size < maxDisplayFileSizeBytes { if metadata.Size < maxDisplayFileSizeBytes {
bytes, err := ioutil.ReadFile(filePath) bytes, err := ioutil.ReadFile(filePath)
if err == nil { if err == nil {
extra["extension"] = extension
extra["lang_hl"], extra["lang_ace"] = extensionToHlAndAceLangs(extension)
extra["contents"] = string(bytes) extra["contents"] = string(bytes)
tpl = Templates["display/bin.html"]
lines = strings.Split(extra["contents"], "\n")
tpl = Templates["display/story.html"]
} }
} }
} else if extension == "story" {
} else if strings.HasPrefix(metadata.Mimetype, "text/") || supportedBinExtension(extension) {
if metadata.Size < maxDisplayFileSizeBytes { if metadata.Size < maxDisplayFileSizeBytes {
bytes, err := ioutil.ReadFile(filePath) bytes, err := ioutil.ReadFile(filePath)
if err == nil { if err == nil {
extra["extension"] = extension
extra["lang_hl"], extra["lang_ace"] = extensionToHlAndAceLangs(extension)
extra["contents"] = string(bytes) extra["contents"] = string(bytes)
lines = strings.Split(extra["contents"], "\n")
tpl = Templates["display/story.html"]
tpl = Templates["display/bin.html"]
} }
} }
} else if extension == "md" { } else if extension == "md" {

Loading…
Cancel
Save