From fdbb4eeedf8793e24903990742e8a847200cacb3 Mon Sep 17 00:00:00 2001 From: ache Date: Thu, 14 Feb 2019 04:10:52 +0100 Subject: Grid CSS --- server.go | 35 +++++++++++++++++++++++++++-------- 1 file changed, 27 insertions(+), 8 deletions(-) (limited to 'server.go') diff --git a/server.go b/server.go index 6274934..d072342 100644 --- a/server.go +++ b/server.go @@ -40,10 +40,11 @@ func handleGet( w http.ResponseWriter, r *http.Request, headOnly bool) { type Entry struct { Name string - Size int + Size int64 } var files []Entry + var cols []Entry f, err := os.Open(filename) if err != nil { @@ -68,16 +69,24 @@ func handleGet( w http.ResponseWriter, r *http.Request, headOnly bool) { } } + + cols = append(cols, Entry{".", 0}) + if filename != "." { + cols = append(cols, Entry{"..", 0}) + } for _, file := range fileInfo { - files = append(files, Entry{file.Name(), 0}) + if file.IsDir() { + cols = append(cols, Entry{file.Name(), 0}) + } else { + files = append(files, Entry{file.Name(), file.Size()}) + } } - - type Collection struct { Name string - ListEntries []Entry + ListCols []Entry + ListFiles []Entry } - tmpl.Execute(w, Collection{ "Title" , files}) + tmpl.Execute(w, Collection{ "Title" , cols, files}) case stat.Mode().IsRegular(): if !headOnly { @@ -161,13 +170,23 @@ func handleCopy( w http.ResponseWriter, r *http.Request) { } func handleMove( w http.ResponseWriter, r *http.Request) { filename := r.URL.Path[1:] - oups := "" + dest := r.Header.Get("Destination") + overwrite := "T" + + if r.Header.Get("Overwrite") != "" { + overwrite = r.Header.Get("Overwrite") + } + if filename == "" || filename == "." { w.WriteHeader(http.StatusBadRequest) fmt.Fprintln(w, "Cannot move root directory") return } - fmt.Printf("Trying to move [%s] to [%s]\n", filename, oups) + + if tmpDir, err := os.Stat( path.Dir( dest ) ) ; err == nil && tmpDir.IsDir() { + + } + fmt.Printf("Trying to move [%s] to [%s]\n", filename, dest) } func handleMethod( w http.ResponseWriter, r *http.Request) { -- cgit v1.2.3