2021-04-23 05:21:11 +08:00
|
|
|
package filer_ui
|
2018-05-25 14:42:13 +08:00
|
|
|
|
|
|
|
import (
|
2018-05-28 02:52:26 +08:00
|
|
|
"strings"
|
2020-04-06 04:11:43 +08:00
|
|
|
|
|
|
|
"github.com/chrislusf/seaweedfs/weed/util"
|
2018-05-25 14:42:13 +08: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 15:09:01 +08:00
|
|
|
crumb := Breadcrumb{
|
|
|
|
Name: parts[i] + " /",
|
2020-04-06 04:11:43 +08:00
|
|
|
Link: "/" + util.Join(parts[0:i+1]...),
|
2019-12-12 15:09:01 +08:00
|
|
|
}
|
|
|
|
if !strings.HasSuffix(crumb.Link, "/") {
|
|
|
|
crumb.Link += "/"
|
|
|
|
}
|
|
|
|
crumbs = append(crumbs, crumb)
|
2018-05-25 14:42:13 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
return
|
|
|
|
}
|