diff --git a/godoc/dl/dl.go b/godoc/dl/dl.go index 6c219d26..ed6e5902 100644 --- a/godoc/dl/dl.go +++ b/godoc/dl/dl.go @@ -49,14 +49,29 @@ func RegisterHandlers(mux *http.ServeMux) { } type File struct { - Filename string - OS string - Arch string - Version string - Checksum string `datastore:",noindex"` - Size int64 `datastore:",noindex"` - Kind string // "archive", "installer", "source" - Uploaded time.Time + Filename string + OS string + Arch string + Version string + Checksum string `datastore:",noindex"` // SHA1; deprecated + ChecksumSHA256 string `datastore:",noindex"` + Size int64 `datastore:",noindex"` + Kind string // "archive", "installer", "source" + Uploaded time.Time +} + +func (f File) ChecksumType() string { + if f.ChecksumSHA256 != "" { + return "SHA256" + } + return "SHA1" +} + +func (f File) PrettyChecksum() string { + if f.ChecksumSHA256 != "" { + return f.ChecksumSHA256 + } + return f.Checksum } func (f File) PrettyOS() string { diff --git a/godoc/dl/tmpl.go b/godoc/dl/tmpl.go index 0274d487..54a2d546 100644 --- a/godoc/dl/tmpl.go +++ b/godoc/dl/tmpl.go @@ -33,7 +33,7 @@ const templateHTML = ` padding: 6px 10px; } table.codetable tt { - font-size: x-small; + font-size: xx-small; } table.codetable tr.highlight td { font-weight: bold; @@ -73,7 +73,7 @@ const templateHTML = ` font-style: italic; } .downloadBox .checksum { - font-size: x-small; + font-size: 5pt; } @@ -235,7 +235,8 @@ $(document).ready(function() { OS Arch Size - SHA1 Checksum + {{/* Use the checksum type of the first file for the column heading. */}} + {{(index . 0).ChecksumType}} Checksum {{range .}} @@ -245,7 +246,7 @@ $(document).ready(function() { {{.PrettyOS}} {{pretty .Arch}} {{.PrettySize}} - {{.Checksum}} + {{.PrettyChecksum}} {{else}} @@ -263,7 +264,7 @@ $(document).ready(function() { {{.Filename}} {{if .Size}}({{.PrettySize}}){{end}} -
SHA1: {{.Checksum}}
+
{{.ChecksumType}}: {{.PrettyChecksum}}
{{end}} `