diff options
author | Matt Holt <mholt@users.noreply.github.com> | 2023-03-10 11:19:31 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-03-10 18:19:31 +0000 |
commit | 6cc3cbbc697d80ae7112c589ce34032f821b4b47 (patch) | |
tree | f054ac5d6c742cb514b439c97cf7e3b25bfca9cd /modules/caddyhttp/fileserver/browse.go | |
parent | 9e943319b4ba2120e1f862f6615afb3c99e3a81e (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/browse.go')
-rw-r--r-- | modules/caddyhttp/fileserver/browse.go | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/modules/caddyhttp/fileserver/browse.go b/modules/caddyhttp/fileserver/browse.go index a8f5e8a..e1a0894 100644 --- a/modules/caddyhttp/fileserver/browse.go +++ b/modules/caddyhttp/fileserver/browse.go @@ -152,12 +152,20 @@ func (fsrv *FileServer) loadDirectoryContents(ctx context.Context, dir fs.ReadDi // browseApplyQueryParams applies query parameters to the listing. // It mutates the listing and may set cookies. func (fsrv *FileServer) browseApplyQueryParams(w http.ResponseWriter, r *http.Request, listing *browseTemplateContext) { + layoutParam := r.URL.Query().Get("layout") sortParam := r.URL.Query().Get("sort") orderParam := r.URL.Query().Get("order") limitParam := r.URL.Query().Get("limit") offsetParam := r.URL.Query().Get("offset") - // first figure out what to sort by + switch layoutParam { + case "list", "grid", "": + listing.Layout = layoutParam + default: + listing.Layout = "list" + } + + // figure out what to sort by switch sortParam { case "": sortParam = sortByNameDirFirst |