From 6cc3cbbc697d80ae7112c589ce34032f821b4b47 Mon Sep 17 00:00:00 2001 From: Matt Holt Date: Fri, 10 Mar 2023 11:19:31 -0700 Subject: fileserver: New file browse template (#5427) * fileserver: New file browse template * Redo extension/icon logic; minor color tweaks * Fine-tune image display --- modules/caddyhttp/fileserver/browsetplcontext.go | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'modules/caddyhttp/fileserver/browsetplcontext.go') diff --git a/modules/caddyhttp/fileserver/browsetplcontext.go b/modules/caddyhttp/fileserver/browsetplcontext.go index 172fa50..bd21aa8 100644 --- a/modules/caddyhttp/fileserver/browsetplcontext.go +++ b/modules/caddyhttp/fileserver/browsetplcontext.go @@ -134,6 +134,9 @@ type browseTemplateContext struct { // Sorting order Order string `json:"order,omitempty"` + + // Display format (list or grid) + Layout string `json:"layout,omitempty"` } // Breadcrumbs returns l.Path where every element maps @@ -229,6 +232,16 @@ type fileInfo struct { IsSymlink bool `json:"is_symlink"` } +// HasExt returns true if the filename has any of the given suffixes, case-insensitive. +func (fi fileInfo) HasExt(exts ...string) bool { + for _, ext := range exts { + if strings.HasSuffix(strings.ToLower(fi.Name), strings.ToLower(ext)) { + return true + } + } + return false +} + // HumanSize returns the size of the file as a // human-readable string in IEC format (i.e. // power of 2 or base 1024). -- cgit v1.2.3