fix img gen
2
Makefile
|
@ -4,7 +4,7 @@ build:
|
||||||
deno run --allow-all utils/build.js
|
deno run --allow-all utils/build.js
|
||||||
|
|
||||||
images:
|
images:
|
||||||
# deno run --allow-all utils/images.js
|
deno run --allow-all utils/images.js
|
||||||
|
|
||||||
frontend:
|
frontend:
|
||||||
cd web && npm install && npm run build
|
cd web && npm install && npm run build
|
||||||
|
|
|
@ -1,31 +1,37 @@
|
||||||
import { join } from "https://deno.land/std@0.208.0/path/mod.ts";
|
import { join } from "https://deno.land/std@0.208.0/path/mod.ts";
|
||||||
import { emptyDir } from "https://deno.land/std@0.196.0/fs/empty_dir.ts";
|
import { ensureDir } from "https://deno.land/std@0.224.0/fs/ensure_dir.ts";
|
||||||
|
import { existsSync } from "https://deno.land/std@0.224.0/fs/exists.ts";
|
||||||
|
|
||||||
const DEST_DIR = "./dist";
|
const DATA_DIR = "./data";
|
||||||
|
|
||||||
const imgDir = join(DEST_DIR, "img");
|
const imgDir = "./web/public/img";
|
||||||
await emptyDir(imgDir);
|
await ensureDir(imgDir);
|
||||||
|
|
||||||
const issues = JSON.parse(
|
|
||||||
await Deno.readTextFile(join(DEST_DIR, "index.json")),
|
|
||||||
);
|
|
||||||
|
|
||||||
// get images
|
// get images
|
||||||
for (const issue of issues) {
|
for (const { name: year } of Deno.readDirSync(DATA_DIR)) {
|
||||||
await genImage(
|
for (const { name: fn } of Deno.readDirSync(join(DATA_DIR, year))) {
|
||||||
`https://news.web3privacy.info/image/${issue.week}?${new Date().valueOf()}`,
|
const week = fn.match(/^week(\d+)/)?.[1];
|
||||||
join(imgDir, `${issue.week}.png`),
|
if (!week) continue;
|
||||||
);
|
const yearWeek = `${year}-${week}`;
|
||||||
|
const imgn = `https://news.web3privacy.info/image/${yearWeek}?${new Date().valueOf()}`;
|
||||||
|
const outputFn = join(imgDir, `${yearWeek}.png`);
|
||||||
|
if (existsSync(outputFn)) continue;
|
||||||
|
console.log('Processing:', imgn);
|
||||||
|
await genImage(imgn, outputFn);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// make cover
|
// make cover
|
||||||
await genImage(
|
const coverFn = join(imgDir, "cover.png");
|
||||||
`https://news.web3privacy.info/cover`,
|
if (!existsSync(coverFn)) {
|
||||||
join(imgDir, "cover.png"),
|
await genImage(`https://news.web3privacy.info/cover`, coverFn);
|
||||||
);
|
}
|
||||||
|
|
||||||
console.log("Done");
|
console.log("Done");
|
||||||
|
|
||||||
|
// ---------
|
||||||
|
|
||||||
async function genImage(url, fn) {
|
async function genImage(url, fn) {
|
||||||
const imgResp = await fetch("https://html2svg.gwei.cz", {
|
const imgResp = await fetch("https://html2svg.gwei.cz", {
|
||||||
method: "POST",
|
method: "POST",
|
||||||
|
@ -35,6 +41,9 @@ async function genImage(url, fn) {
|
||||||
width: 1920,
|
width: 1920,
|
||||||
height: 960,
|
height: 960,
|
||||||
}),
|
}),
|
||||||
|
headers: {
|
||||||
|
"content-type": "application/json",
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
if (imgResp.body) {
|
if (imgResp.body) {
|
||||||
|
|
BIN
web/public/img/2024-05.png
Normal file
After Width: | Height: | Size: 61 KiB |
BIN
web/public/img/2024-06.png
Normal file
After Width: | Height: | Size: 59 KiB |
BIN
web/public/img/2024-07.png
Normal file
After Width: | Height: | Size: 59 KiB |
BIN
web/public/img/2024-08.png
Normal file
After Width: | Height: | Size: 61 KiB |
BIN
web/public/img/2024-09.png
Normal file
After Width: | Height: | Size: 62 KiB |
BIN
web/public/img/2024-10.png
Normal file
After Width: | Height: | Size: 58 KiB |
BIN
web/public/img/2024-13.png
Normal file
After Width: | Height: | Size: 61 KiB |
BIN
web/public/img/2024-14.png
Normal file
After Width: | Height: | Size: 58 KiB |
BIN
web/public/img/2024-15.png
Normal file
After Width: | Height: | Size: 60 KiB |
BIN
web/public/img/2024-16.png
Normal file
After Width: | Height: | Size: 60 KiB |
BIN
web/public/img/2024-17.png
Normal file
After Width: | Height: | Size: 59 KiB |
BIN
web/public/img/2024-18.png
Normal file
After Width: | Height: | Size: 64 KiB |
BIN
web/public/img/cover.png
Normal file
After Width: | Height: | Size: 47 KiB |