swarm/api/http: fixed list leaf links (#17342)
This commit is contained in:
@ -18,6 +18,7 @@ package http
|
||||
|
||||
import (
|
||||
"encoding/hex"
|
||||
"fmt"
|
||||
"html/template"
|
||||
"path"
|
||||
|
||||
@ -45,7 +46,10 @@ func init() {
|
||||
{
|
||||
templateName: "bzz-list",
|
||||
partial: bzzList,
|
||||
funcs: template.FuncMap{"basename": path.Base},
|
||||
funcs: template.FuncMap{
|
||||
"basename": path.Base,
|
||||
"leaflink": leafLink,
|
||||
},
|
||||
},
|
||||
{
|
||||
templateName: "landing-page",
|
||||
@ -62,6 +66,10 @@ func init() {
|
||||
faviconBytes = bytes
|
||||
}
|
||||
|
||||
func leafLink(URI api.URI, manifestEntry api.ManifestEntry) string {
|
||||
return fmt.Sprintf("/bzz:/%s/%s", URI.Addr, manifestEntry.Path)
|
||||
}
|
||||
|
||||
const bzzList = `{{ define "content" }}
|
||||
<h3 class="top-space">Swarm index of {{ .URI }}</h3>
|
||||
<hr>
|
||||
@ -83,10 +91,11 @@ const bzzList = `{{ define "content" }}
|
||||
<td>DIR</td>
|
||||
<td>-</td>
|
||||
</tr>
|
||||
{{ end }} {{ range .List.Entries }}
|
||||
{{ end }}
|
||||
{{ range .List.Entries }}
|
||||
<tr>
|
||||
<td>
|
||||
<a class="normal-link" href="{{ basename .Path }}">{{ basename .Path }}</a>
|
||||
<a class="normal-link" href="{{ leaflink $.URI . }}">{{ basename .Path }}</a>
|
||||
</td>
|
||||
<td>{{ .ContentType }}</td>
|
||||
<td>{{ .Size }}</td>
|
||||
|
Reference in New Issue
Block a user