Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
caddy
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
caddy
Commits
36a3e204
Commit
36a3e204
authored
Apr 11, 2016
by
Matt Holt
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #740 from tboerger/feature/browse-breadcrumb
Added breadcrumb map function to browse
parents
004a7f84
e0b63d92
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
28 additions
and
0 deletions
+28
-0
middleware/browse/browse.go
middleware/browse/browse.go
+28
-0
No files found.
middleware/browse/browse.go
View file @
36a3e204
...
...
@@ -96,6 +96,34 @@ func (l Listing) LinkedPath() string {
return
result
}
// BreadcrumbMap returns l.Path where every element is a map
// of URLs and path segment names.
func
(
l
Listing
)
BreadcrumbMap
()
map
[
string
]
string
{
result
:=
map
[
string
]
string
{}
if
len
(
l
.
Path
)
==
0
{
return
result
}
// skip trailing slash
lpath
:=
l
.
Path
if
lpath
[
len
(
lpath
)
-
1
]
==
'/'
{
lpath
=
lpath
[
:
len
(
lpath
)
-
1
]
}
parts
:=
strings
.
Split
(
lpath
,
"/"
)
for
i
,
part
:=
range
parts
{
if
i
==
0
&&
part
==
""
{
// Leading slash (root)
result
[
"/"
]
=
"/"
continue
}
result
[
strings
.
Join
(
parts
[
:
i
+
1
],
"/"
)]
=
part
}
return
result
}
// FileInfo is the info about a particular file or directory
type
FileInfo
struct
{
IsDir
bool
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment