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.

33 lines
529 B

7 years ago
5 years 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. for i := 0; i < len(parts); i++ {
  13. name := parts[i]
  14. if name == "" {
  15. name = "/"
  16. }
  17. crumb := Breadcrumb{
  18. Name: name,
  19. Link: "/" + util.Join(parts[0:i+1]...),
  20. }
  21. if !strings.HasSuffix(crumb.Link, "/") {
  22. crumb.Link += "/"
  23. }
  24. crumbs = append(crumbs, crumb)
  25. }
  26. return
  27. }