You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

36 lines
577 B

7 years ago
5 years ago
6 months ago
5 years ago
  1. package filer_ui
  2. import (
  3. "strings"
  4. "github.com/seaweedfs/seaweedfs/weed/util"
  5. )
  6. type Breadcrumb struct {
  7. Name string
  8. Link string
  9. }
  10. func ToBreadcrumb(fullpath string) (crumbs []Breadcrumb) {
  11. parts := strings.Split(fullpath, "/")
  12. if fullpath == "/" {
  13. parts = []string{""}
  14. }
  15. for i := 0; i < len(parts); i++ {
  16. name := parts[i]
  17. if name == "" {
  18. name = "/"
  19. }
  20. crumb := Breadcrumb{
  21. Name: name,
  22. Link: "/" + util.Join(parts[0:i+1]...),
  23. }
  24. if !strings.HasSuffix(crumb.Link, "/") {
  25. crumb.Link += "/"
  26. }
  27. crumbs = append(crumbs, crumb)
  28. }
  29. return
  30. }