seaweedfs/weed/server/filer_ui/breadcrumb.go

25 lines
394 B
Go
Raw Normal View History

2018-05-25 14:42:13 +08:00
package master_ui
import (
"path/filepath"
2018-05-28 02:52:26 +08:00
"strings"
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++ {
crumbs = append(crumbs, Breadcrumb{
Name: parts[i] + "/",
Link: "/" + filepath.ToSlash(filepath.Join(parts[0:i+1]...)),
2018-05-25 14:42:13 +08:00
})
}
return
}