diff --git a/docs/todo.md b/docs/todo.md index 08d0cc44..568d486f 100644 --- a/docs/todo.md +++ b/docs/todo.md @@ -4,8 +4,6 @@ * Repack zips that contain programs with bad filenames, for example: http://localhost:1323/f/ab252e4 * _Thumbnail assets_ links need better separation. -* `` -* * Does not work, need to use `img` tag. * 404 errors :/ /editor/thumbnail/top/ ~ /editor/preview/crop11/ etc. * Local file timestamp for file uploads is not being set. * Redirect `/link/list` to wayback.defacto2.net. diff --git a/handler/app/internal/simple/simple.go b/handler/app/internal/simple/simple.go index 196e6d2b..5a802505 100644 --- a/handler/app/internal/simple/simple.go +++ b/handler/app/internal/simple/simple.go @@ -475,45 +475,50 @@ func Screenshot(unid, desc, previewDir string) template.HTML { sizeJ := helper.Size(filepath.Join(previewDir, unid+jpg)) sizeA := helper.Size(filepath.Join(previewDir, unid+avif)) + hashW, _ := helper.IntegrityFile(filepath.Join(previewDir, unid+webp)) + hashP, _ := helper.IntegrityFile(filepath.Join(previewDir, unid+png)) + hashJ, _ := helper.IntegrityFile(filepath.Join(previewDir, unid+jpg)) + hashA, _ := helper.IntegrityFile(filepath.Join(previewDir, unid+avif)) + usePicture := (sizeA > 0 || sizeW > 0) && (sizeJ > 0 || sizeP > 0) if usePicture { elm := template.HTML("") switch { case sizeA > 0: - elm += template.HTML(fmt.Sprintf("", srcA)) + elm += template.HTML(fmt.Sprintf("", srcA, hashA, hashA)) case sizeW > 0: - elm += template.HTML(fmt.Sprintf("", srcW)) + elm += template.HTML(fmt.Sprintf("", srcW, hashW, hashW)) } // the element is used to provide multiple sources for an image. // if no element is provided, the element won't be rendered by the browser. useSmallerJpg := sizeJ > 0 && sizeJ < sizeP switch { case useSmallerJpg: - elm += img(srcJ, alt, class, "") + elm += img(srcJ, alt, class, hashJ) case sizeP > 0: - elm += img(srcP, alt, class, "") + elm += img(srcP, alt, class, hashP) default: - elm += img(srcJ, alt, class, "") + elm += img(srcJ, alt, class, hashJ) } return elm + "" } switch { case sizeA > 0: - return img(srcA, alt, class, "") + return img(srcA, alt, class, hashA) case sizeW > 0: - return img(srcW, alt, class, "") + return img(srcW, alt, class, hashW) case sizeJ > 0: - return img(srcJ, alt, class, "") + return img(srcJ, alt, class, hashJ) case sizeP > 0: - return img(srcP, alt, class, "") + return img(srcP, alt, class, hashP) } return "" } // img returns a HTML image tag. -func img(src, alt, class, style string) template.HTML { - return template.HTML(fmt.Sprintf("\"%s\"", - src, alt, class, style)) +func img(src, alt, class, integrity string) template.HTML { + return template.HTML(fmt.Sprintf("\"%s\"", + src, integrity, alt, class, integrity)) } // StatHumanize returns the last modified date, size in bytes and size formatted @@ -562,7 +567,7 @@ func Thumb(unid, desc, thumbDir string, bottom bool) template.HTML { if w && p { elm := "" + fmt.Sprintf("", webp) + - string(img(png, alt, class, style)) + + string(thumb(png, alt, class, style)) + "" return template.HTML(elm) } @@ -570,7 +575,13 @@ func Thumb(unid, desc, thumbDir string, bottom bool) template.HTML { if p { src = png } - return img(src, alt, class, style) + return thumb(src, alt, class, style) +} + +// img returns a HTML image tag. +func thumb(src, alt, class, style string) template.HTML { + return template.HTML(fmt.Sprintf("\"%s\"", + src, alt, class, style)) } // ThumbSample returns a HTML image tag for the given unid. diff --git a/view/app/artifactfile.tmpl b/view/app/artifactfile.tmpl index 0c5f0788..0492d58b 100644 --- a/view/app/artifactfile.tmpl +++ b/view/app/artifactfile.tmpl @@ -210,16 +210,16 @@ {{- end}}
- Top - Middle + Top   + Middle   Bottom crop
- Left + Left   Right crop
- Pixel art + Pixel art   Photograph thumbnail
Delete
diff --git a/view/app/artifactfooter.tmpl b/view/app/artifactfooter.tmpl index ad945682..e63bf0fc 100644 --- a/view/app/artifactfooter.tmpl +++ b/view/app/artifactfooter.tmpl @@ -12,7 +12,7 @@ Delete forever
- Refresh & view artifact + Refresh & view artifact