add thumbhash use `github.com/galdor/go-thumbhash` and `github.com/evanw/thumbhash`
database:
add `thumbhash` column for `files` table
image:
add `EncodeThumbHash()` function use `go.n16f.net/thumbhash`
router:
add `/api/task/files/thumbhash` endpoint to check thumbhask
task:
add `CheckThumbHash()` function
web/scripts:
add thumbhash logic for `load_*` scripts
add `thumbhash.js` from `https://github.com/evanw/thumbhash/blob/main/js/thumbhash.js`, edited
web/styles/gallery:
add thumbhash transition when thumbnail loaded
adjust style for wrapped imgs
web/templates:
add `role="main"` for gallery and artwork id pages
render thumbhash script for gallery pages
39 lines
1.7 KiB
Cheetah
39 lines
1.7 KiB
Cheetah
{{ define "artworks_noscript" }}
|
|
<!DOCTYPE html>
|
|
<html lang="zh-CN">
|
|
<head>
|
|
<meta charset="UTF-8">
|
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
<title>trpic</title>
|
|
{{ "base" | .RenderStyle }}
|
|
{{ "gallery" | .RenderStyle }}
|
|
</head>
|
|
<body>
|
|
<header id="info-box">
|
|
{{ "header" | .RenderStyle }}
|
|
<span id="title">trpic</span>
|
|
<span>浏览进度 <b>({{ .Viewed }}/{{ .Total }})</b></span>
|
|
<span>以 <b>{{ .Sort }}</b> 排序</span>
|
|
<span>无 JS 模式</span>
|
|
{{ if gt .Offset 0 }}<span><a href="?offset={{.PrevOffset}}&limit={{.Limit}}&sort={{.Sort}}{{ if .Tags }}&tags={{.Tags}}{{ end }}">上一页</a></span>{{ else }}<span>上一页</span>{{ end }}
|
|
{{ if not (ge .Viewed .Total) }}<span><a href="?offset={{.NextOffset}}&limit={{.Limit}}&sort={{.Sort}}{{ if .Tags }}&tags={{.Tags}}{{ end }}">下一页</a></span>{{ else }}<span>下一页</span>{{ end }}
|
|
</header>
|
|
<div id="gallery" role="main">
|
|
{{range $artIndex, $art := .Artworks }}
|
|
{{ $file := index $art.Edges.Files 0 }}
|
|
{{ $src := printf "/files/%d.%s" $file.ID $file.Ext }}
|
|
{{ if $file.Thumbed }}{{ $src = printf "/thumbnails/%d.jpg" $file.ID }}{{ end }}
|
|
<div style="width:{{$file.JWidth}}px; flex-grow:{{$file.JWidth}}">
|
|
<a href="/noscript/artworks/{{$art.ID}}">
|
|
<i style="padding-bottom:{{$file.JPadding}}%">
|
|
{{if gt (len $art.Edges.Files) 1}}<span><p>{{len $art.Edges.Files}} pic</p></span>{{end}}
|
|
</i>
|
|
<img src="{{$src}}" loading="lazy" decoding="async" />
|
|
</a>
|
|
</div>
|
|
{{end}}
|
|
</div>
|
|
</body>
|
|
</html>
|
|
{{ end }}
|