diff options
author | Giulio M <sperectrum@gmail.com> | 2018-08-08 15:33:06 +0800 |
---|---|---|
committer | Balint Gabor <balint.g@gmail.com> | 2018-08-08 15:33:06 +0800 |
commit | a1eb9c7d13240fd250866219a502d0cdc9924e06 (patch) | |
tree | 37126b9c5d169bd9eadf0559edbbea7075eecbb0 /swarm/api/http/templates.go | |
parent | 00e6da9704b2cd7ddcc1cd31ed3f6bbaa8e1e284 (diff) | |
download | dexon-a1eb9c7d13240fd250866219a502d0cdc9924e06.tar dexon-a1eb9c7d13240fd250866219a502d0cdc9924e06.tar.gz dexon-a1eb9c7d13240fd250866219a502d0cdc9924e06.tar.bz2 dexon-a1eb9c7d13240fd250866219a502d0cdc9924e06.tar.lz dexon-a1eb9c7d13240fd250866219a502d0cdc9924e06.tar.xz dexon-a1eb9c7d13240fd250866219a502d0cdc9924e06.tar.zst dexon-a1eb9c7d13240fd250866219a502d0cdc9924e06.zip |
swarm/api/http: fixed list leaf links (#17342)
Diffstat (limited to 'swarm/api/http/templates.go')
-rw-r--r-- | swarm/api/http/templates.go | 15 |
1 files changed, 12 insertions, 3 deletions
diff --git a/swarm/api/http/templates.go b/swarm/api/http/templates.go index 1cd42ca37..986f5f887 100644 --- a/swarm/api/http/templates.go +++ b/swarm/api/http/templates.go @@ -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> |