cache webmention pics locally to resize and alleviate the wm server (rate limiting)

This commit is contained in:
Wouter Groeneveld 2022-05-07 15:15:22 +02:00
parent 3c1a9a6aa1
commit 6841f95579
32 changed files with 79 additions and 9 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 145 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 18 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 32 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 74 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 10 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 15 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 443 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 26 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 27 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 104 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 14 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 127 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 60 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 106 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 26 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 43 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 30 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 47 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 16 KiB

View File

@ -1,4 +1,18 @@
[ [
{
"author": {
"name": "Frank Meeuwsen",
"picture": "/pictures/diggingthedigital.com"
},
"name": "Mini-update aan de abonnementspagina van de site",
"content": "Een kort huishoudelijk bericht als je me via RSS volgt. (Wat is RSS?) Het kan zijn dat de feed van dit blog wat gek doet in je feedreader deze dagen. Ik heb geknutseld aan de weergave van de feed en dat heeft zoals gewoonlijk voor onverwachte bij-eff...",
"published": "2022-05-07T09:50:05+00:00",
"url": "https://diggingthedigital.com/mini-update-rss/",
"type": "mention",
"source": "https://diggingthedigital.com/mini-update-rss/",
"target": "https://brainbaking.com/post/2022/04/cool-things-people-do-with-their-blogs/",
"relativeTarget": "/post/2022/04/cool-things-people-do-with-their-blogs/"
},
{ {
"author": { "author": {
"name": "Frank Meeuwsen", "name": "Frank Meeuwsen",

View File

@ -35,6 +35,14 @@ const rootdir = `${__dirname}/../`;
const json = JSON.stringify(mentions, null, 4) const json = JSON.stringify(mentions, null, 4)
await fsp.writeFile(`${rootdir}/data/webmentions.json`, json, 'utf-8') await fsp.writeFile(`${rootdir}/data/webmentions.json`, json, 'utf-8')
console.log("4.1 Fetching pictures from wm authors...")
await webmention.getPictures(mentions, {
endpoint: wmconfig.endpoint,
directory: `${rootdir}/assets/wmpics`,
override: false,
extension: "jpg"
})
// 5. generate youtube thumbnails // 5. generate youtube thumbnails
console.log("5. Generating YouTube thumbnails...") console.log("5. Generating YouTube thumbnails...")
await youtube.thumbify({ await youtube.thumbify({

View File

@ -29,6 +29,6 @@
"homepage": "https://brainbaking.com", "homepage": "https://brainbaking.com",
"dependencies": { "dependencies": {
"dayjs": "^1.11.1", "dayjs": "^1.11.1",
"jam-my-stack": "^1.0.22" "jam-my-stack": "^1.0.28"
} }
} }

View File

@ -35,7 +35,14 @@
<a rel="author" class="u-author h-card u-url permalink" href="{{ .source }}"> <a rel="author" class="u-author h-card u-url permalink" href="{{ .source }}">
{{ if isset .author "picture" }} {{ if isset .author "picture" }}
<div class="avatar"> <div class="avatar">
<img class="u-photo" loading="lazy" src="{{ $wmServer }}{{ .author.picture | safeHTML }}" alt="{{ $name }}" /> {{- $image := resources.Get (printf "%s%s.jpg" "wmpics/" .author.picture ) -}}
{{ if eq $image nil }}
<img class="u-photo" loading="lazy" src="/img/avatar-anonymous.jpg" alt="{{ $name }} anonymous photo" />
{{ else }}
{{- $imgsmall := $image.Resize "100x jpg q85" }}
<img class="u-photo" loading="lazy" src="{{ $imgsmall.RelPermalink }}" alt="{{ $name }}" />
{{ end }}
</div> </div>
{{ else }} {{ else }}
<div class="avatar"> <div class="avatar">

View File

@ -1550,7 +1550,7 @@ __metadata:
"@babel/core": ^7.9.6 "@babel/core": ^7.9.6
"@babel/preset-env": ^7.10.1 "@babel/preset-env": ^7.10.1
dayjs: ^1.11.1 dayjs: ^1.11.1
jam-my-stack: ^1.0.22 jam-my-stack: ^1.0.28
lodash: ">=4.17.21" lodash: ">=4.17.21"
languageName: unknown languageName: unknown
linkType: soft linkType: soft
@ -1608,6 +1608,21 @@ __metadata:
languageName: node languageName: node
linkType: hard linkType: hard
"cacheable-request@npm:^7.0.2":
version: 7.0.2
resolution: "cacheable-request@npm:7.0.2"
dependencies:
clone-response: ^1.0.2
get-stream: ^5.1.0
http-cache-semantics: ^4.0.0
keyv: ^4.0.0
lowercase-keys: ^2.0.0
normalize-url: ^6.0.1
responselike: ^2.0.0
checksum: 176a1fceb987f1fee8b512ee7908445854a0c75854a11710f0d8de104cf840fd92e3c94ecd1f9144e57a25e17f5d72056591e5b33aabb8775061f906b0696a50
languageName: node
linkType: hard
"camelcase-keys@npm:^6.2.2": "camelcase-keys@npm:^6.2.2":
version: 6.2.2 version: 6.2.2
resolution: "camelcase-keys@npm:6.2.2" resolution: "camelcase-keys@npm:6.2.2"
@ -2520,7 +2535,26 @@ fsevents@^1.2.7:
languageName: node languageName: node
linkType: hard linkType: hard
"got@npm:^11.8.2, got@npm:~11.8.2": "got@npm:11.8.3":
version: 11.8.3
resolution: "got@npm:11.8.3"
dependencies:
"@sindresorhus/is": ^4.0.0
"@szmarczak/http-timer": ^4.0.5
"@types/cacheable-request": ^6.0.1
"@types/responselike": ^1.0.0
cacheable-lookup: ^5.0.3
cacheable-request: ^7.0.2
decompress-response: ^6.0.0
http2-wrapper: ^1.0.0-beta.5.2
lowercase-keys: ^2.0.0
p-cancelable: ^2.0.0
responselike: ^2.0.0
checksum: 9c7e94bc0828f505de52451f445664394aee83c2051e033413a5fead1128814f322976de96905c3b2e74e6b91b122ab10f3c6b7806a15e49429e40440181c844
languageName: node
linkType: hard
"got@npm:~11.8.2":
version: 11.8.2 version: 11.8.2
resolution: "got@npm:11.8.2" resolution: "got@npm:11.8.2"
dependencies: dependencies:
@ -3040,21 +3074,21 @@ fsevents@^1.2.7:
languageName: node languageName: node
linkType: hard linkType: hard
"jam-my-stack@npm:^1.0.22": "jam-my-stack@npm:^1.0.28":
version: 1.0.22 version: 1.0.28
resolution: "jam-my-stack@npm:1.0.22" resolution: "jam-my-stack@npm:1.0.28"
dependencies: dependencies:
dayjs: ^1.10.4 dayjs: ^1.10.4
ejs: ^3.1.6 ejs: ^3.1.6
ent: ^2.2.0 ent: ^2.2.0
fast-xml-parser: ^3.18.0 fast-xml-parser: ^3.18.0
got: ^11.8.2 got: 11.8.3
howlongtobeat: ^1.3.1 howlongtobeat: ^1.3.1
imagemagick: ^0.1.3 imagemagick: ^0.1.3
lunr: ^2.3.9 lunr: ^2.3.9
parser-front-matter: ^1.6.4 parser-front-matter: ^1.6.4
youtube-dl-exec: ^1.2.4 youtube-dl-exec: ^1.2.4
checksum: c5e6e102121b9c7de17c9dde0a47d5cbd840a0a56540628f32cc443c6b30796d025edff454f5294a74957752f67c969dc8cac44efb385994a8fba9bc5422dade checksum: 1a21558ac5de96e9eb3454859b4a1231089bcaddda865a53e6a71396af56008e62373f46549c87f3e5d3c03ee75e2b55e1262c7bb8656b73dd4c7a0686bb05d3
languageName: node languageName: node
linkType: hard linkType: hard
@ -3631,6 +3665,13 @@ fsevents@^1.2.7:
languageName: node languageName: node
linkType: hard linkType: hard
"normalize-url@npm:^6.0.1":
version: 6.1.0
resolution: "normalize-url@npm:6.1.0"
checksum: 5fb69e98c149f4a54a7bb0f1904cc524627c0d23327a9feafacacf135d01d9595c65e80ced6f27c17c1959541ea732815b604ff8a6ec52ec3fe7a391b92cfba9
languageName: node
linkType: hard
"npm-run-path@npm:^4.0.1": "npm-run-path@npm:^4.0.1":
version: 4.0.1 version: 4.0.1
resolution: "npm-run-path@npm:4.0.1" resolution: "npm-run-path@npm:4.0.1"