1
0
mirror of https://github.com/ipfs/kubo.git synced 2025-10-25 10:27:01 +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:
rht
2015-08-28 20:01:16 +07:00
parent 1dac829062
commit 4b3a21eceb
13 changed files with 69 additions and 85 deletions

View File

@ -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

View File

@ -1 +1 @@
../vendor/src/QmeNXKecZ7CQagtkQUJxG3yS7UcvU6puS777dQsx3amkS7/dir-index-html/gw-assets
../vendor/src/QmeMZwyPnHMkvgdUNtdNcTX425gTCi5DCMeHLwTXbKoUB8/dir-index-html/gw-assets

View File

@ -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)
}

View File

@ -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)

View File

@ -4,7 +4,7 @@
"dependencies": [
{
"name": "dir-index-html",
"hash": "QmeNXKecZ7CQagtkQUJxG3yS7UcvU6puS777dQsx3amkS7"
"hash": "QmeMZwyPnHMkvgdUNtdNcTX425gTCi5DCMeHLwTXbKoUB8"
}
]
}

View File

@ -0,0 +1 @@
QmeNXKecZ7CQagtkQUJxG3yS7UcvU6puS777dQsx3amkS7

View File

@ -0,0 +1,6 @@
# dir-index-html
directory listing html for go-ipfs gateways.
![](http://gateway.ipfs.io/ipfs/Qmf82jUC9ZuoSTCNY55hyx3HmiDed3WnhFD5PC7CTSPmC2/cap.png)

View File

@ -52,7 +52,7 @@
<td>
<a href="{{ .Path }}">{{ .Name }}</a>
</td>
<td>{{ .Size }} bytes</td>
<td>{{ .Size }}</td>
</tr>
{{ end }}
</table>