"os"
"path"
"sort"
- "strings"
"time"
"github.com/dustin/go-humanize"
}
type DirListFile struct {
- Name string
+ Name template.URL
Size string
Type string
ModTime string
}
file := DirListFile{
Idx: i,
- Name: fi.Name(),
+ Name: template.URL(fi.Name()),
Size: humanize.IBytes(uint64(fi.Size())),
ModTime: fi.ModTime().UTC().Truncate(time.Second).Format(MTimeFmt),
}
if fi.IsDir() {
file.IsDir = true
} else {
- file.Type = mediaType(file.Name, cfg.MIMEs)
+ file.Type = mediaType(fi.Name(), cfg.MIMEs)
}
if (entry.Type() & fs.ModeSymlink) > 0 {
file.Symlink, _ = os.Readlink(path.Join(pth, fi.Name()))
Files []DirListFile
}{
Root: root,
- Dir: strings.TrimRight(dir, "/"),
+ Dir: dir,
Readme: readme,
Files: files,
})
<tr><th> </th><th>Name</th><th>Mtime</th><th>Size</th><th>Type</th></tr>
{{$Dir := .Dir}}{{$Root := .Root}}{{range .Files}}<tr>
<td {{if .Symlink}}rowspan="2"{{end}}>{{.Idx}}</td>
- <td><a href="{{$Root}}{{$Dir}}/{{.Name}}{{if .IsDir}}/{{end -}}"><tt>
+ <td><a href="{{$Root}}{{$Dir}}{{.Name}}{{if .IsDir}}/{{end -}}"><tt>
{{- .Name}}{{if .IsDir}}/{{end}}</tt></a></td>
<td><tt>{{.ModTime}}</tt></td>
<td>{{.Size}}</td>
// Highly-customizable HTTP, HTTP/2, HTTPS server
package godlighty
-const Version = "godlighty/0.8.0"
+const Version = "godlighty/0.9.0"
var BindAddr string