Files
trpic/web/templates/artwork_id/artwork_id_noscript.tmpl
Hubert Chen 85cf0aedf8 refactor
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
2026-03-27 13:37:59 +08:00

54 lines
1.7 KiB
Cheetah

{{ define "artwork_id_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>
<link rel="manifest" href="/manifest.json"/>
<style>
body {background: #222;color: #fff;margin: 1em}
p{max-width: 600px;margin: .5em 0;line-break: anywhere}
a{color: aquamarine;text-decoration: none}
#files {display: flex;flex-wrap: wrap;gap: .5em}
img{max-width: min(600px, 90vw);max-height: 90vh}
</style>
</head>
<body>
{{ if .Artwork.Edges.Posts }}
<p>作者:
{{ range .Artwork.Edges.Socials }}
<a href="{{ .URL }}"> {{ .Platform }}/{{ .DisplayName }}</a>
{{ end }}
</p>
{{ end }}
{{ if .Artwork.Edges.Posts }}
<p>来源:
{{ range .Artwork.Edges.Posts }}
<div style="padding-inline-start: 1em">
<a href="{{ .URL }}"> {{ .Platform }}/{{ .PostID }}</a>
{{ if .Title }}<p>Title: {{ .Title }}</p>{{ end }}
{{ if .Text }}<p>Text: {{ .Text }}</p>{{ end }}
</div>
{{ end }}
</p>
{{ end }}
{{ if .Artwork.Edges.Tags }}
<p>标签:
{{ range .Artwork.Edges.Tags }}
<a href="/tags/{{ .ID }}}">#{{ .Text }}</a>
{{ end }}
</p>
{{ end }}
{{/* <p>发布时间: {{ .Artwork.Time }}</p> */}}
<div id="files">
{{ range .Artwork.Edges.Files }}
<a href="/files/{{ .ID }}.{{ .Ext }}"><img src="/files/{{ .ID }}.{{ .Ext }}" loading="lazy" decoding="async" /></a>
{{ else }}
<p>没有找到图片</p>
{{ end }}
</div>
</body>
</html>
{{ end }}