mirror of
https://github.com/ipfs/kubo.git
synced 2025-10-25 18:36:26 +08:00
Humanize bytes in dir index listing
Fixes https://github.com/ipfs/dir-index-html/issues/3 License: MIT Signed-off-by: rht <rhtbot@gmail.com>
This commit is contained in:
@ -29,8 +29,8 @@ func SeedInitDocs(nd *core.IpfsNode) (*key.Key, error) {
|
||||
}
|
||||
|
||||
var initDirIndex = []string{
|
||||
"../vendor/src/QmeNXKecZ7CQagtkQUJxG3yS7UcvU6puS777dQsx3amkS7/dir-index-html/knownIcons.txt",
|
||||
"../vendor/src/QmeNXKecZ7CQagtkQUJxG3yS7UcvU6puS777dQsx3amkS7/dir-index-html/dir-index.html",
|
||||
"../vendor/src/QmeMZwyPnHMkvgdUNtdNcTX425gTCi5DCMeHLwTXbKoUB8/dir-index-html/knownIcons.txt",
|
||||
"../vendor/src/QmeMZwyPnHMkvgdUNtdNcTX425gTCi5DCMeHLwTXbKoUB8/dir-index-html/dir-index.html",
|
||||
}
|
||||
|
||||
var initGwAssets = []string{
|
||||
|
||||
File diff suppressed because one or more lines are too long
@ -1 +1 @@
|
||||
../vendor/src/QmeNXKecZ7CQagtkQUJxG3yS7UcvU6puS777dQsx3amkS7/dir-index-html/gw-assets
|
||||
../vendor/src/QmeMZwyPnHMkvgdUNtdNcTX425gTCi5DCMeHLwTXbKoUB8/dir-index-html/gw-assets
|
||||
@ -9,6 +9,7 @@ import (
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
humanize "github.com/ipfs/go-ipfs/Godeps/_workspace/src/github.com/dustin/go-humanize"
|
||||
"github.com/ipfs/go-ipfs/Godeps/_workspace/src/golang.org/x/net/context"
|
||||
|
||||
key "github.com/ipfs/go-ipfs/blocks/key"
|
||||
@ -201,7 +202,7 @@ func (i *gatewayHandler) getOrHeadHandler(w http.ResponseWriter, r *http.Request
|
||||
}
|
||||
|
||||
// See comment above where originalUrlPath is declared.
|
||||
di := directoryItem{link.Size, link.Name, gopath.Join(originalUrlPath, link.Name)}
|
||||
di := directoryItem{humanize.Bytes(link.Size), link.Name, gopath.Join(originalUrlPath, link.Name)}
|
||||
dirListing = append(dirListing, di)
|
||||
}
|
||||
|
||||
|
||||
@ -15,7 +15,7 @@ type listingTemplateData struct {
|
||||
}
|
||||
|
||||
type directoryItem struct {
|
||||
Size uint64
|
||||
Size string
|
||||
Name string
|
||||
Path string
|
||||
}
|
||||
@ -23,7 +23,7 @@ type directoryItem struct {
|
||||
var listingTemplate *template.Template
|
||||
|
||||
func init() {
|
||||
assetPath := "../vendor/src/QmeNXKecZ7CQagtkQUJxG3yS7UcvU6puS777dQsx3amkS7/dir-index-html/"
|
||||
assetPath := "../vendor/src/QmeMZwyPnHMkvgdUNtdNcTX425gTCi5DCMeHLwTXbKoUB8/dir-index-html/"
|
||||
knownIconsBytes, err := assets.Asset(assetPath + "knownIcons.txt")
|
||||
if err != nil {
|
||||
panic(err)
|
||||
|
||||
@ -4,7 +4,7 @@
|
||||
"dependencies": [
|
||||
{
|
||||
"name": "dir-index-html",
|
||||
"hash": "QmeNXKecZ7CQagtkQUJxG3yS7UcvU6puS777dQsx3amkS7"
|
||||
"hash": "QmeMZwyPnHMkvgdUNtdNcTX425gTCi5DCMeHLwTXbKoUB8"
|
||||
}
|
||||
]
|
||||
}
|
||||
1
vendor/src/QmeMZwyPnHMkvgdUNtdNcTX425gTCi5DCMeHLwTXbKoUB8/dir-index-html/.gxlastpubver
vendored
Normal file
1
vendor/src/QmeMZwyPnHMkvgdUNtdNcTX425gTCi5DCMeHLwTXbKoUB8/dir-index-html/.gxlastpubver
vendored
Normal file
@ -0,0 +1 @@
|
||||
QmeNXKecZ7CQagtkQUJxG3yS7UcvU6puS777dQsx3amkS7
|
||||
6
vendor/src/QmeMZwyPnHMkvgdUNtdNcTX425gTCi5DCMeHLwTXbKoUB8/dir-index-html/README.md
vendored
Normal file
6
vendor/src/QmeMZwyPnHMkvgdUNtdNcTX425gTCi5DCMeHLwTXbKoUB8/dir-index-html/README.md
vendored
Normal file
@ -0,0 +1,6 @@
|
||||
# dir-index-html
|
||||
|
||||
directory listing html for go-ipfs gateways.
|
||||
|
||||

|
||||
|
||||
@ -52,7 +52,7 @@
|
||||
<td>
|
||||
<a href="{{ .Path }}">{{ .Name }}</a>
|
||||
</td>
|
||||
<td>{{ .Size }} bytes</td>
|
||||
<td>{{ .Size }}</td>
|
||||
</tr>
|
||||
{{ end }}
|
||||
</table>
|
||||
Reference in New Issue
Block a user