Commit ac80f6ed authored by Matt Holt's avatar Matt Holt

Merge pull request #744 from tboerger/feature/breadcrumb

browse: Dropped LinkedPath and updated browse template
parents 36a3e204 ef951738
...@@ -264,7 +264,6 @@ footer { ...@@ -264,7 +264,6 @@ footer {
</g> </g>
</g> </g>
<!-- File --> <!-- File -->
<linearGradient id="a"> <linearGradient id="a">
<stop stop-color="#cbcbcb" offset="0"/> <stop stop-color="#cbcbcb" offset="0"/>
...@@ -300,14 +299,14 @@ footer { ...@@ -300,14 +299,14 @@ footer {
</defs> </defs>
</svg> </svg>
<header> <header>
<h1>{{.LinkedPath}}</h1> <h1>
{{range $url, $name := .BreadcrumbMap}}<a href="{{$url}}">{{$name}}</a>{{if ne $url "/"}}/{{end}}{{end}}
</h1>
</header> </header>
<main> <main>
<div class="meta"> <div class="meta">
<div class="content"> <div class="content">
<span class="meta-item"><b>{{.NumDirs}}</b> director{{if eq 1 .NumDirs}}y{{else}}ies{{end}}</span> <span class="meta-item"><b>{{.NumDirs}}</b> director{{if eq 1 .NumDirs}}y{{else}}ies{{end}}</span>
<span class="meta-item"><b>{{.NumFiles}}</b> file{{if ne 1 .NumFiles}}s{{end}}</span> <span class="meta-item"><b>{{.NumFiles}}</b> file{{if ne 1 .NumFiles}}s{{end}}</span>
</div> </div>
......
...@@ -6,7 +6,6 @@ import ( ...@@ -6,7 +6,6 @@ import (
"bytes" "bytes"
"encoding/json" "encoding/json"
"errors" "errors"
"fmt"
"net/http" "net/http"
"net/url" "net/url"
"os" "os"
...@@ -69,33 +68,6 @@ type Listing struct { ...@@ -69,33 +68,6 @@ type Listing struct {
middleware.Context middleware.Context
} }
// LinkedPath returns l.Path where every element is a clickable
// link to the path up to that point so far.
func (l Listing) LinkedPath() string {
if len(l.Path) == 0 {
return ""
}
// skip trailing slash
lpath := l.Path
if lpath[len(lpath)-1] == '/' {
lpath = lpath[:len(lpath)-1]
}
parts := strings.Split(lpath, "/")
var result string
for i, part := range parts {
if i == 0 && part == "" {
// Leading slash (root)
result += `<a href="/">/</a>`
continue
}
result += fmt.Sprintf(`<a href="%s/">%s</a>/`, strings.Join(parts[:i+1], "/"), part)
}
return result
}
// BreadcrumbMap returns l.Path where every element is a map // BreadcrumbMap returns l.Path where every element is a map
// of URLs and path segment names. // of URLs and path segment names.
func (l Listing) BreadcrumbMap() map[string]string { func (l Listing) BreadcrumbMap() map[string]string {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment