2021-04-22 21:21:11 +00:00
|
|
|
package filer_ui
|
2018-05-25 06:42:13 +00:00
|
|
|
|
|
|
|
import (
|
2018-05-27 18:52:26 +00:00
|
|
|
"strings"
|
2020-04-05 20:11:43 +00:00
|
|
|
|
2022-07-29 07:17:28 +00:00
|
|
|
"github.com/seaweedfs/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++ {
|
2022-04-07 09:53:22 +00:00
|
|
|
name := parts[i]
|
|
|
|
if name == "" {
|
|
|
|
name = "/"
|
|
|
|
}
|
2019-12-12 07:09:01 +00:00
|
|
|
crumb := Breadcrumb{
|
2022-04-07 09:53:22 +00:00
|
|
|
Name: name,
|
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
|
|
|
|
}
|