templates.go 503 B

12345678910111213141516171819202122232425
  1. package filer_ui
  2. import (
  3. _ "embed"
  4. "github.com/dustin/go-humanize"
  5. "html/template"
  6. "net/url"
  7. "strings"
  8. )
  9. func printpath(parts ...string) string {
  10. concat := strings.Join(parts, "")
  11. escaped := url.PathEscape(concat)
  12. return strings.ReplaceAll(escaped, "%2F", "/")
  13. }
  14. var funcMap = template.FuncMap{
  15. "humanizeBytes": humanize.Bytes,
  16. "printpath": printpath,
  17. }
  18. //go:embed filer.html
  19. var filerHtml string
  20. var StatusTpl = template.Must(template.New("status").Funcs(funcMap).Parse(filerHtml))