diff --git a/gossa.go b/gossa.go index 38a0a43..bda4873 100755 --- a/gossa.go +++ b/gossa.go @@ -24,10 +24,11 @@ import ( ) type rowTemplate struct { - Name string - Href template.HTML - Size string - Ext string + Name string + Href template.HTML + Size string + Ext string + Image bool } type pageTemplate struct { @@ -94,7 +95,7 @@ func replyList(w http.ResponseWriter, r *http.Request, fullPath string, path str title := "/" + strings.TrimPrefix(path, *extraPath) p := pageTemplate{} if path != *extraPath { - p.RowsFolders = append(p.RowsFolders, rowTemplate{"../", "../", "", "folder"}) + p.RowsFolders = append(p.RowsFolders, rowTemplate{"../", "../", "", "folder", false}) } p.ExtraPath = template.HTML(html.EscapeString(*extraPath)) p.Ro = *ro @@ -116,17 +117,19 @@ func replyList(w http.ResponseWriter, r *http.Request, fullPath string, path str href := url.PathEscape(el.Name()) name := el.Name() + lowerName := strings.ToLower(el.Name()) + image := strings.HasSuffix(lowerName, ".png") || strings.HasSuffix(lowerName, ".jpeg") || strings.HasSuffix(lowerName, ".jpg") if el.IsDir() && strings.HasPrefix(href, "/") { href = strings.Replace(href, "/", "", 1) } if el.IsDir() { - p.RowsFolders = append(p.RowsFolders, rowTemplate{name + "/", template.HTML(href), "", "folder"}) + p.RowsFolders = append(p.RowsFolders, rowTemplate{name + "/", template.HTML(href), "", "folder", false}) } else { sl := strings.Split(name, ".") ext := strings.ToLower(sl[len(sl)-1]) - p.RowsFiles = append(p.RowsFiles, rowTemplate{name, template.HTML(href), humanize(el.Size()), ext}) + p.RowsFiles = append(p.RowsFiles, rowTemplate{name, template.HTML(href), humanize(el.Size()), ext, image}) } } diff --git a/ui/ui.tmpl b/ui/ui.tmpl index 3d4bcfb..6a20b62 100644 --- a/ui/ui.tmpl +++ b/ui/ui.tmpl @@ -75,6 +75,9 @@
{{.Size}}