diff --git a/assets/dir-index-html/dir-index.html b/assets/dir-index-html/dir-index.html index a2d662d19c7..a92df1397d0 100644 --- a/assets/dir-index-html/dir-index.html +++ b/assets/dir-index-html/dir-index.html @@ -19,7 +19,7 @@ {{ .Path }} @@ -84,9 +84,12 @@ {{ if .Hash }} - + {{ .ShortHash }} + {{ end }} {{ .Size }} @@ -97,3 +100,8 @@ + diff --git a/assets/dir-index-html/src/dir-index.html b/assets/dir-index-html/src/dir-index.html index 1bbbb0a9a8c..cd0c7e46681 100644 --- a/assets/dir-index-html/src/dir-index.html +++ b/assets/dir-index-html/src/dir-index.html @@ -83,9 +83,12 @@ {{ if .Hash }} - + {{ .ShortHash }} + {{ end }} {{ .Size }} @@ -96,3 +99,8 @@ + diff --git a/assets/dir-index-html/src/icons.css b/assets/dir-index-html/src/icons.css index dcdbd3cd9e2..4b0a3ded8d1 100644 --- a/assets/dir-index-html/src/icons.css +++ b/assets/dir-index-html/src/icons.css @@ -401,3 +401,10 @@ background-repeat:no-repeat; background-size:contain } + +/* Source - https://icons.radix-ui.com/.org */ +.ipfs-copy { + background-image: url("data:image/svg+xml,%3Csvg width='15' height='15' viewBox='0 0 15 15' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M5 2V1H10V2H5ZM4.75 0C4.33579 0 4 0.335786 4 0.75V1H3.5C2.67157 1 2 1.67157 2 2.5V12.5C2 13.3284 2.67157 14 3.5 14H7V13H3.5C3.22386 13 3 12.7761 3 12.5V2.5C3 2.22386 3.22386 2 3.5 2H4V2.25C4 2.66421 4.33579 3 4.75 3H10.25C10.6642 3 11 2.66421 11 2.25V2H11.5C11.7761 2 12 2.22386 12 2.5V7H13V2.5C13 1.67157 12.3284 1 11.5 1H11V0.75C11 0.335786 10.6642 0 10.25 0H4.75ZM9 8.5C9 8.77614 8.77614 9 8.5 9C8.22386 9 8 8.77614 8 8.5C8 8.22386 8.22386 8 8.5 8C8.77614 8 9 8.22386 9 8.5ZM10.5 9C10.7761 9 11 8.77614 11 8.5C11 8.22386 10.7761 8 10.5 8C10.2239 8 10 8.22386 10 8.5C10 8.77614 10.2239 9 10.5 9ZM13 8.5C13 8.77614 12.7761 9 12.5 9C12.2239 9 12 8.77614 12 8.5C12 8.22386 12.2239 8 12.5 8C12.7761 8 13 8.22386 13 8.5ZM14.5 9C14.7761 9 15 8.77614 15 8.5C15 8.22386 14.7761 8 14.5 8C14.2239 8 14 8.22386 14 8.5C14 8.77614 14.2239 9 14.5 9ZM15 10.5C15 10.7761 14.7761 11 14.5 11C14.2239 11 14 10.7761 14 10.5C14 10.2239 14.2239 10 14.5 10C14.7761 10 15 10.2239 15 10.5ZM14.5 13C14.7761 13 15 12.7761 15 12.5C15 12.2239 14.7761 12 14.5 12C14.2239 12 14 12.2239 14 12.5C14 12.7761 14.2239 13 14.5 13ZM14.5 15C14.7761 15 15 14.7761 15 14.5C15 14.2239 14.7761 14 14.5 14C14.2239 14 14 14.2239 14 14.5C14 14.7761 14.2239 15 14.5 15ZM8.5 11C8.77614 11 9 10.7761 9 10.5C9 10.2239 8.77614 10 8.5 10C8.22386 10 8 10.2239 8 10.5C8 10.7761 8.22386 11 8.5 11ZM9 12.5C9 12.7761 8.77614 13 8.5 13C8.22386 13 8 12.7761 8 12.5C8 12.2239 8.22386 12 8.5 12C8.77614 12 9 12.2239 9 12.5ZM8.5 15C8.77614 15 9 14.7761 9 14.5C9 14.2239 8.77614 14 8.5 14C8.22386 14 8 14.2239 8 14.5C8 14.7761 8.22386 15 8.5 15ZM11 14.5C11 14.7761 10.7761 15 10.5 15C10.2239 15 10 14.7761 10 14.5C10 14.2239 10.2239 14 10.5 14C10.7761 14 11 14.2239 11 14.5ZM12.5 15C12.7761 15 13 14.7761 13 14.5C13 14.2239 12.7761 14 12.5 14C12.2239 14 12 14.2239 12 14.5C12 14.7761 12.2239 15 12.5 15Z' fill='currentColor' fill-rule='evenodd' clip-rule='evenodd'%3E%3C/path%3E%3C/svg%3E"); + background-repeat:no-repeat; + background-size:contain +} \ No newline at end of file diff --git a/assets/dir-index-html/src/style.css b/assets/dir-index-html/src/style.css index 3e7b8a734bc..9d2508164bc 100644 --- a/assets/dir-index-html/src/style.css +++ b/assets/dir-index-html/src/style.css @@ -25,6 +25,18 @@ a:visited { color:#00b0e9 } +button { + padding: 0; + border: none; + background: none; + vertical-align: middle; +} + +button:hover { + background-color: #00b0e9; + cursor: pointer; +} + strong { font-weight:700 } diff --git a/assets/dir-index-html/test/main.go b/assets/dir-index-html/test/main.go index 43b4a098101..0172d61a876 100644 --- a/assets/dir-index-html/test/main.go +++ b/assets/dir-index-html/test/main.go @@ -1,6 +1,7 @@ package main import ( + "encoding/json" "fmt" "net/http" "net/url" @@ -95,6 +96,13 @@ func main() { pathUrl := url.URL{Path: rawUrl} return pathUrl.String() }, + "jsonEncode": func(rawString string) string { + encodedStr, err := json.Marshal(rawString) + if err != nil { + panic(err) + } + return string(encodedStr) + }, }).ParseFiles(templateFile) if err != nil { http.Error(w, fmt.Sprintf("failed to parse template file: %s", err), http.StatusInternalServerError) diff --git a/core/corehttp/gateway_indexPage.go b/core/corehttp/gateway_indexPage.go index 1168d65560c..30ce1233e47 100644 --- a/core/corehttp/gateway_indexPage.go +++ b/core/corehttp/gateway_indexPage.go @@ -1,6 +1,7 @@ package corehttp import ( + "encoding/json" "html/template" "net/url" "path" @@ -121,6 +122,15 @@ func init() { return pathUrl.String() } + // custom function to encode strings in json, to future-proof for new encoding + jsonEncode := func(rawString string) string { + encodedStr, err := json.Marshal(rawString) + if err != nil { + panic(err) + } + return string(encodedStr) + } + // Directory listing template dirIndexBytes, err := assets.Asset.ReadFile("dir-index-html/dir-index.html") if err != nil { @@ -130,5 +140,6 @@ func init() { listingTemplate = template.Must(template.New("dir").Funcs(template.FuncMap{ "iconFromExt": iconFromExt, "urlEscape": urlEscape, + "jsonEncode": jsonEncode, }).Parse(string(dirIndexBytes))) }