migrate sql:
```
ALTER TABLE posts ADD COLUMN `time` datetime NULL;
ALTER TABLE posts ADD COLUMN `title` text NULL;
ALTER TABLE posts ADD COLUMN `text` text NULL;
UPDATE posts SET
time = (SELECT a.time FROM artworks a WHERE a.id = posts.artwork_posts),
title = (SELECT a.title FROM artworks a WHERE a.id = posts.artwork_posts),
text = (SELECT a.text FROM artworks a WHERE a.id = posts.artwork_posts)
WHERE EXISTS (SELECT 1 FROM artworks a WHERE a.id = posts.artwork_posts);
ALTER TABLE artworks DROP COLUMN time;
ALTER TABLE artworks DROP COLUMN title;
ALTER TABLE artworks DROP COLUMN text;
```
configs:
add `CheckArtworkIntervalInSeconds` flag to set check artwork task interval
database:
add `migrate.sql` file
artwork:
move `time`, `title` and `text` fields to `post` schema
file:
set `id_str` and `filename` fields immutable
add `source_url` optional field
post:
set `platform` field immutable
add `time`, `title` and `text` optional from `artwork` schema
social:
set `platform` field immutable
tag:
set `text` field immutable
action(new):
add action package to create and update `file`, `post`, `social` and `tag` info
api:
artworks:
adjust GET method order option to match the database
files:
adjust GET method with `artwork/tags` edge
rename GET method respond `images` field to `files`
collect:
refactor to work with new action package
task:
artwork(new):
create `CheckArtworks` function to check and update artwork info
social:
refactor `CheckSocials` to work with new action package
router:
add `/api/task/artworks/check` endpoint for `CheckArtworks` task
src/web:
artwork noscript:
adjust order option to match the database
file noscript:
rename execute template struct `Images` field to `Files`
web:
scripts:
refactor to work with new database schema
styles:
adjust some style
use `<button>` to replace `<span>` to allow keyboard control
templates:
adjust to work with new database schema
use `<button>` to replace `<span>` to allow keyboard control
50 lines
2.0 KiB
Cheetah
50 lines
2.0 KiB
Cheetah
{{ define "files_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>
|
|
<div id="gallery">
|
|
<div id="info-box">
|
|
<p style="font-size: 1.2em; font-weight: bold;">trpic</p>
|
|
<p>已浏览 <b>({{ .Offset }}/{{ .Total }})</b> 张图片</p>
|
|
<span>以 <b>{{ .Sort }}</b> 排序</span>
|
|
<p>无 JavaScript 模式</p>
|
|
{{ if ge .Offset .Limit }}<a href="?offset={{.PrevOffset}}&limit={{.Limit}}&sort={{.Sort}}">上一页</a>{{ end }}
|
|
{{ if not (ge .Viewed .Total) }}<a href="?offset={{.NextOffset}}&limit={{.Limit}}&sort={{.Sort}}">下一页</a>{{ end }}
|
|
</div>
|
|
{{range $index, $img := .Files}}
|
|
{{ $src := printf "/files/%d.%s" $img.ID $img.Ext }}
|
|
{{ if $img.Thumbed }}{{ $src = printf "/thumbnails/%d.jpg" $img.ID }}{{ end }}
|
|
<div style="width:{{$img.JWidth}}px; flex-grow:{{$img.JWidth}}">
|
|
<a href="{{printf "/files/%d.%s" $img.ID $img.Ext}}">
|
|
<i style="padding-bottom:{{$img.JPadding}}%">
|
|
{{ if eq $.Sort "size" }}
|
|
<span><p>{{ $img.Ext }} | {{ if $img.Thumbed }}☇ {{ end }}{{$img.SizeStr}}</p></span>
|
|
{{ else if eq $.Sort "size-down" }}
|
|
<span><p>{{ $img.Ext }} | {{ if $img.Thumbed }}☇ {{ end }}{{$img.SizeStr}}</p></span>
|
|
{{ end }}
|
|
</i>
|
|
<img src="{{$src}}" loading="lazy" decoding="async" />
|
|
</a>
|
|
</div>
|
|
{{end}}
|
|
<div id="info-box">
|
|
<p>已浏览 ({{ .Viewed }}/{{ .Total }})</p>
|
|
{{ if gt .Offset 0 }}
|
|
<a href="?offset={{.PrevOffset}}&limit={{.Limit}}&sort={{.Sort}}">上一页</a>
|
|
{{ end }}
|
|
{{ if not (ge .Viewed .Total) }}
|
|
<a href="?offset={{.NextOffset}}&limit={{.Limit}}&sort={{.Sort}}">下一页</a>
|
|
{{ end }}
|
|
</div>
|
|
</div>
|
|
</body>
|
|
</html>
|
|
{{ end }}
|