mirror of
https://github.com/seaweedfs/seaweedfs.git
synced 2024-12-01 07:49:02 +08:00
30 lines
486 B
Go
30 lines
486 B
Go
package master_ui
|
|
|
|
import (
|
|
"strings"
|
|
|
|
"github.com/chrislusf/seaweedfs/weed/util"
|
|
)
|
|
|
|
type Breadcrumb struct {
|
|
Name string
|
|
Link string
|
|
}
|
|
|
|
func ToBreadcrumb(fullpath string) (crumbs []Breadcrumb) {
|
|
parts := strings.Split(fullpath, "/")
|
|
|
|
for i := 0; i < len(parts); i++ {
|
|
crumb := Breadcrumb{
|
|
Name: parts[i] + " /",
|
|
Link: "/" + util.Join(parts[0:i+1]...),
|
|
}
|
|
if !strings.HasSuffix(crumb.Link, "/") {
|
|
crumb.Link += "/"
|
|
}
|
|
crumbs = append(crumbs, crumb)
|
|
}
|
|
|
|
return
|
|
}
|