summaryrefslogtreecommitdiff
path: root/modules/caddyhttp/fileserver/browsetplcontext.go
diff options
context:
space:
mode:
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).