Commit 4b3a21ec authored by rht's avatar rht

Humanize bytes in dir index listing

Fixes https://github.com/ipfs/dir-index-html/issues/3

License: MIT
Signed-off-by: default avatarrht <rhtbot@gmail.com>
parent 1dac8290
......@@ -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{
......
This diff is collapsed.
../vendor/src/QmeNXKecZ7CQagtkQUJxG3yS7UcvU6puS777dQsx3amkS7/dir-index-html/gw-assets
\ No newline at end of file
../vendor/src/QmeMZwyPnHMkvgdUNtdNcTX425gTCi5DCMeHLwTXbKoUB8/dir-index-html/gw-assets
\ No newline at end of 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)
}
......
......@@ -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)
......
QmeNXKecZ7CQagtkQUJxG3yS7UcvU6puS777dQsx3amkS7
\ No newline at end of file
# dir-index-html
directory listing html for go-ipfs gateways.
![](http://gateway.ipfs.io/ipfs/Qmf82jUC9ZuoSTCNY55hyx3HmiDed3WnhFD5PC7CTSPmC2/cap.png)
......@@ -52,7 +52,7 @@
<td>
<a href="{{ .Path }}">{{ .Name }}</a>
</td>
<td>{{ .Size }} bytes</td>
<td>{{ .Size }}</td>
</tr>
{{ end }}
</table>
......
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