2018-05-25 06:42:13 +00:00
|
|
|
package master_ui
|
|
|
|
|
|
|
|
import (
|
2018-05-27 18:52:26 +00:00
|
|
|
"strings"
|
2020-04-05 20:11:43 +00:00
|
|
|
|
|
|
|
"github.com/chrislusf/seaweedfs/weed/util"
|
2018-05-25 06:42:13 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
type Breadcrumb struct {
|
|
|
|
Name string
|
|
|
|
Link string
|
|
|
|
}
|
|
|
|
|
|
|
|
func ToBreadcrumb(fullpath string) (crumbs []Breadcrumb) {
|
|
|
|
parts := strings.Split(fullpath, "/")
|
|
|
|
|
|
|
|
for i := 0; i < len(parts); i++ {
|
2019-12-12 07:09:01 +00:00
|
|
|
crumb := Breadcrumb{
|
|
|
|
Name: parts[i] + " /",
|
2020-04-05 20:11:43 +00:00
|
|
|
Link: "/" + util.Join(parts[0:i+1]...),
|
2019-12-12 07:09:01 +00:00
|
|
|
}
|
|
|
|
if !strings.HasSuffix(crumb.Link, "/") {
|
|
|
|
crumb.Link += "/"
|
|
|
|
}
|
|
|
|
crumbs = append(crumbs, crumb)
|
2018-05-25 06:42:13 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return
|
|
|
|
}
|