diff options
author | Pacien | 2013-07-10 23:23:16 +0200 |
---|---|---|
committer | Pacien | 2013-07-10 23:23:16 +0200 |
commit | 8d1ff0e59f9473b9c98196874ee62e5625380fed (patch) | |
tree | a5524f38e4031e0c9c7fa32f5e33545f1b739e48 | |
parent | bafbd4a6aa831230e65659ee58919cd8b824ccf4 (diff) | |
download | foldaweb-8d1ff0e59f9473b9c98196874ee62e5625380fed.tar.gz |
Fix directory listing
-rw-r--r-- | dynamic.go | 12 |
1 files changed, 7 insertions, 5 deletions
@@ -35,16 +35,18 @@ func handle(w http.ResponseWriter, r *http.Request) { | |||
35 | } | 35 | } |
36 | 36 | ||
37 | // get the list of dirs to parse | 37 | // get the list of dirs to parse |
38 | request := strings.Trim(r.URL.Path, "/") | 38 | request := strings.TrimSuffix(r.URL.Path, "/") |
39 | dirs := strings.Split(request, "/") | 39 | dirs := strings.Split(request, "/") |
40 | if request != "" { | 40 | for i, dir := range dirs { |
41 | dirs = append(dirs, "") | 41 | if i != 0 { |
42 | dirs[i] = path.Join(dirs[i-1], dir) | ||
43 | } | ||
42 | } | 44 | } |
43 | 45 | ||
44 | // parse these dirs | 46 | // parse these dirs |
45 | elements := make(map[string][]byte) | 47 | elements := make(map[string][]byte) |
46 | for _, dir := range dirs { | 48 | for i := len(dirs) - 1; i >= 0; i-- /*_, dir := range reverse dirs*/ { |
47 | parse(path.Join(*settings.sourceDir, dir), elements, settings.exts, false) | 49 | parse(path.Join(*settings.sourceDir, dirs[i]), elements, settings.exts, false) |
48 | } | 50 | } |
49 | 51 | ||
50 | // render the page | 52 | // render the page |