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) { ...@@ -29,8 +29,8 @@ func SeedInitDocs(nd *core.IpfsNode) (*key.Key, error) {
} }
var initDirIndex = []string{ var initDirIndex = []string{
"../vendor/src/QmeNXKecZ7CQagtkQUJxG3yS7UcvU6puS777dQsx3amkS7/dir-index-html/knownIcons.txt", "../vendor/src/QmeMZwyPnHMkvgdUNtdNcTX425gTCi5DCMeHLwTXbKoUB8/dir-index-html/knownIcons.txt",
"../vendor/src/QmeNXKecZ7CQagtkQUJxG3yS7UcvU6puS777dQsx3amkS7/dir-index-html/dir-index.html", "../vendor/src/QmeMZwyPnHMkvgdUNtdNcTX425gTCi5DCMeHLwTXbKoUB8/dir-index-html/dir-index.html",
} }
var initGwAssets = []string{ var initGwAssets = []string{
......
This diff is collapsed.
../vendor/src/QmeNXKecZ7CQagtkQUJxG3yS7UcvU6puS777dQsx3amkS7/dir-index-html/gw-assets ../vendor/src/QmeMZwyPnHMkvgdUNtdNcTX425gTCi5DCMeHLwTXbKoUB8/dir-index-html/gw-assets
\ No newline at end of file \ No newline at end of file
...@@ -9,6 +9,7 @@ import ( ...@@ -9,6 +9,7 @@ import (
"strings" "strings"
"time" "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" "github.com/ipfs/go-ipfs/Godeps/_workspace/src/golang.org/x/net/context"
key "github.com/ipfs/go-ipfs/blocks/key" key "github.com/ipfs/go-ipfs/blocks/key"
...@@ -201,7 +202,7 @@ func (i *gatewayHandler) getOrHeadHandler(w http.ResponseWriter, r *http.Request ...@@ -201,7 +202,7 @@ func (i *gatewayHandler) getOrHeadHandler(w http.ResponseWriter, r *http.Request
} }
// See comment above where originalUrlPath is declared. // 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) dirListing = append(dirListing, di)
} }
......
...@@ -15,7 +15,7 @@ type listingTemplateData struct { ...@@ -15,7 +15,7 @@ type listingTemplateData struct {
} }
type directoryItem struct { type directoryItem struct {
Size uint64 Size string
Name string Name string
Path string Path string
} }
...@@ -23,7 +23,7 @@ type directoryItem struct { ...@@ -23,7 +23,7 @@ type directoryItem struct {
var listingTemplate *template.Template var listingTemplate *template.Template
func init() { func init() {
assetPath := "../vendor/src/QmeNXKecZ7CQagtkQUJxG3yS7UcvU6puS777dQsx3amkS7/dir-index-html/" assetPath := "../vendor/src/QmeMZwyPnHMkvgdUNtdNcTX425gTCi5DCMeHLwTXbKoUB8/dir-index-html/"
knownIconsBytes, err := assets.Asset(assetPath + "knownIcons.txt") knownIconsBytes, err := assets.Asset(assetPath + "knownIcons.txt")
if err != nil { if err != nil {
panic(err) panic(err)
......
...@@ -4,7 +4,7 @@ ...@@ -4,7 +4,7 @@
"dependencies": [ "dependencies": [
{ {
"name": "dir-index-html", "name": "dir-index-html",
"hash": "QmeNXKecZ7CQagtkQUJxG3yS7UcvU6puS777dQsx3amkS7" "hash": "QmeMZwyPnHMkvgdUNtdNcTX425gTCi5DCMeHLwTXbKoUB8"
} }
] ]
} }
\ No newline at end of file
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 @@ ...@@ -52,7 +52,7 @@
<td> <td>
<a href="{{ .Path }}">{{ .Name }}</a> <a href="{{ .Path }}">{{ .Name }}</a>
</td> </td>
<td>{{ .Size }} bytes</td> <td>{{ .Size }}</td>
</tr> </tr>
{{ end }} {{ end }}
</table> </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