summaryrefslogtreecommitdiff
path: root/modules/caddyhttp/fileserver/browsetplcontext.go
diff options
context:
space:
mode:
authorMatt Holt <mholt@users.noreply.github.com>2023-03-10 11:19:31 -0700
committerGitHub <noreply@github.com>2023-03-10 18:19:31 +0000
commit6cc3cbbc697d80ae7112c589ce34032f821b4b47 (patch)
treef054ac5d6c742cb514b439c97cf7e3b25bfca9cd /modules/caddyhttp/fileserver/browsetplcontext.go
parent9e943319b4ba2120e1f862f6615afb3c99e3a81e (diff)
fileserver: New file browse template (#5427)
* fileserver: New file browse template * Redo extension/icon logic; minor color tweaks * Fine-tune image display
Diffstat (limited to 'modules/caddyhttp/fileserver/browsetplcontext.go')
-rw-r--r--modules/caddyhttp/fileserver/browsetplcontext.go13
1 files changed, 13 insertions, 0 deletions
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).