mirror of
https://github.com/rclone/rclone.git
synced 2025-12-06 00:03:32 +00:00
http: improved directory listing with new template from Caddy project
This includes a new directory listing template which was originally from the Caddy project (used with permission and copyright attribution). This is used whenever we serve directory listings so `rclone serve http`, `rclone serve webdav` and `rclone rcd --rc-serve` This also modifies the tests so they work with the original template which is easier to debug.
This commit is contained in:
@@ -6,6 +6,7 @@ import (
|
||||
"path"
|
||||
"strconv"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"github.com/rclone/rclone/cmd"
|
||||
"github.com/rclone/rclone/cmd/serve/httplib"
|
||||
@@ -131,7 +132,11 @@ func (s *server) serveDir(w http.ResponseWriter, r *http.Request, dirRemote stri
|
||||
// Make the entries for display
|
||||
directory := serve.NewDirectory(dirRemote, s.HTMLTemplate)
|
||||
for _, node := range dirEntries {
|
||||
directory.AddHTMLEntry(node.Path(), node.IsDir(), node.Size(), node.ModTime())
|
||||
if vfsflags.Opt.NoModTime {
|
||||
directory.AddHTMLEntry(node.Path(), node.IsDir(), node.Size(), time.Time{})
|
||||
} else {
|
||||
directory.AddHTMLEntry(node.Path(), node.IsDir(), node.Size(), node.ModTime().UTC())
|
||||
}
|
||||
}
|
||||
|
||||
sortParm := r.URL.Query().Get("sort")
|
||||
|
||||
Reference in New Issue
Block a user