2021-04-23 05:21:11 +08:00
|
|
|
package filer_ui
|
2016-07-18 16:28:24 +08:00
|
|
|
|
|
|
|
import (
|
2021-07-05 18:09:44 +08:00
|
|
|
_ "embed"
|
2018-08-11 14:47:31 +08:00
|
|
|
"github.com/dustin/go-humanize"
|
2018-08-13 05:27:14 +08:00
|
|
|
"html/template"
|
2020-09-11 10:46:00 +08:00
|
|
|
"net/url"
|
|
|
|
"strings"
|
2016-07-18 16:28:24 +08:00
|
|
|
)
|
|
|
|
|
2020-09-11 10:46:00 +08:00
|
|
|
func printpath(parts ...string) string {
|
2024-07-03 12:36:01 +08:00
|
|
|
var escapedParts []string
|
|
|
|
for _, p := range parts {
|
|
|
|
if len(p) == 1 {
|
|
|
|
escapedParts = append(escapedParts, p)
|
|
|
|
} else {
|
|
|
|
escapedParts = append(escapedParts, url.PathEscape(p))
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return strings.Join(escapedParts, "")
|
2020-09-11 10:46:00 +08:00
|
|
|
}
|
|
|
|
|
2018-08-11 14:47:31 +08:00
|
|
|
var funcMap = template.FuncMap{
|
|
|
|
"humanizeBytes": humanize.Bytes,
|
2020-09-11 10:46:00 +08:00
|
|
|
"printpath": printpath,
|
2018-08-11 14:47:31 +08:00
|
|
|
}
|
|
|
|
|
2021-07-05 18:09:44 +08:00
|
|
|
//go:embed filer.html
|
|
|
|
var filerHtml string
|
2018-08-20 09:42:40 +08:00
|
|
|
|
2021-07-05 18:09:44 +08:00
|
|
|
var StatusTpl = template.Must(template.New("status").Funcs(funcMap).Parse(filerHtml))
|