add img gen
3
Makefile
|
@ -9,6 +9,9 @@ build:
|
|||
sync:
|
||||
deno run --allow-all utils/sync.js
|
||||
|
||||
images:
|
||||
deno run --allow-all utils/images.js
|
||||
|
||||
test:
|
||||
deno test --allow-all utils/test.js
|
||||
|
||||
|
|
|
@ -1,4 +1,12 @@
|
|||
$defs:
|
||||
design:
|
||||
type: object
|
||||
additionalProperties: false
|
||||
required:
|
||||
- image
|
||||
properties:
|
||||
image:
|
||||
type: string
|
||||
project:
|
||||
type: object
|
||||
additionalProperties: false
|
||||
|
@ -85,6 +93,10 @@ $defs:
|
|||
type: array
|
||||
name-extension:
|
||||
type: string
|
||||
design:
|
||||
$ref: "#/$defs/design"
|
||||
images:
|
||||
type: object
|
||||
person:
|
||||
type: object
|
||||
additionalProperties: false
|
||||
|
|
BIN
src/events/_images/2024/m24ams-poster-simple.webp
Normal file
After Width: | Height: | Size: 330 KiB |
BIN
src/events/_images/2024/m24ams-poster.webp
Normal file
After Width: | Height: | Size: 359 KiB |
BIN
src/events/_images/2024/m24ams-square.webp
Normal file
After Width: | Height: | Size: 132 KiB |
BIN
src/events/_images/2024/m24ams-wide-square.webp
Normal file
After Width: | Height: | Size: 164 KiB |
BIN
src/events/_images/2024/m24ams-wide.webp
Normal file
After Width: | Height: | Size: 162 KiB |
BIN
src/events/_images/2024/m24ath-poster-simple.webp
Normal file
After Width: | Height: | Size: 559 KiB |
BIN
src/events/_images/2024/m24ath-poster.webp
Normal file
After Width: | Height: | Size: 535 KiB |
BIN
src/events/_images/2024/m24ath-square.webp
Normal file
After Width: | Height: | Size: 172 KiB |
BIN
src/events/_images/2024/m24ath-wide-square.webp
Normal file
After Width: | Height: | Size: 212 KiB |
BIN
src/events/_images/2024/m24ath-wide.webp
Normal file
After Width: | Height: | Size: 209 KiB |
BIN
src/events/_images/2024/m24ber-poster-simple.webp
Normal file
After Width: | Height: | Size: 243 KiB |
BIN
src/events/_images/2024/m24ber-poster.webp
Normal file
After Width: | Height: | Size: 272 KiB |
BIN
src/events/_images/2024/m24ber-square.webp
Normal file
After Width: | Height: | Size: 94 KiB |
BIN
src/events/_images/2024/m24ber-wide-square.webp
Normal file
After Width: | Height: | Size: 108 KiB |
BIN
src/events/_images/2024/m24ber-wide.webp
Normal file
After Width: | Height: | Size: 91 KiB |
BIN
src/events/_images/2024/m24tll-poster-simple.webp
Normal file
After Width: | Height: | Size: 695 KiB |
BIN
src/events/_images/2024/m24tll-poster.webp
Normal file
After Width: | Height: | Size: 699 KiB |
BIN
src/events/_images/2024/m24tll-square.webp
Normal file
After Width: | Height: | Size: 280 KiB |
BIN
src/events/_images/2024/m24tll-wide-square.webp
Normal file
After Width: | Height: | Size: 314 KiB |
BIN
src/events/_images/2024/m24tll-wide.webp
Normal file
After Width: | Height: | Size: 307 KiB |
BIN
src/events/_images/2024/s24brn-poster-simple.webp
Normal file
After Width: | Height: | Size: 368 KiB |
BIN
src/events/_images/2024/s24brn-poster.webp
Normal file
After Width: | Height: | Size: 341 KiB |
BIN
src/events/_images/2024/s24brn-square.webp
Normal file
After Width: | Height: | Size: 120 KiB |
BIN
src/events/_images/2024/s24brn-wide-square.webp
Normal file
After Width: | Height: | Size: 151 KiB |
BIN
src/events/_images/2024/s24brn-wide.webp
Normal file
After Width: | Height: | Size: 158 KiB |
BIN
src/events/_images/2024/s24prg-poster-simple.webp
Normal file
After Width: | Height: | Size: 534 KiB |
BIN
src/events/_images/2024/s24prg-poster.webp
Normal file
After Width: | Height: | Size: 568 KiB |
BIN
src/events/_images/2024/s24prg-square.webp
Normal file
After Width: | Height: | Size: 174 KiB |
BIN
src/events/_images/2024/s24prg-wide-square.webp
Normal file
After Width: | Height: | Size: 254 KiB |
BIN
src/events/_images/2024/s24prg-wide.webp
Normal file
After Width: | Height: | Size: 267 KiB |
|
@ -101,6 +101,8 @@
|
|||
speakers:
|
||||
- odysseas
|
||||
- mykola-siusko
|
||||
design:
|
||||
image: athens01
|
||||
|
||||
# - id: w3pm-lib1
|
||||
# type: meetup
|
||||
|
@ -153,6 +155,8 @@
|
|||
speakers:
|
||||
- mykola-siusko
|
||||
- gabari
|
||||
design:
|
||||
image: amsterdam01
|
||||
|
||||
- id: m24tll
|
||||
issue: 10
|
||||
|
@ -167,6 +171,8 @@
|
|||
optional: true
|
||||
links:
|
||||
rsvp: https://lu.ma/w3pn-meetup-tallinn1
|
||||
design:
|
||||
image: tallinn01
|
||||
|
||||
- id: m24opo
|
||||
issue: 21
|
||||
|
@ -201,6 +207,8 @@
|
|||
links:
|
||||
rsvp: https://lu.ma/w3pn-meetup-berlin1
|
||||
signal: https://signal.group/#CjQKIHv5swzLDOrTd1QqR4L9eb-6XPZERnp3ZEoxBCJeY12fEhAPmoC2dqZzLMRWV7wlAq5A
|
||||
design:
|
||||
image: berlin02
|
||||
|
||||
- id: s24prg
|
||||
issue: 11
|
||||
|
@ -223,6 +231,8 @@
|
|||
- gabari
|
||||
- radek-svarz
|
||||
- mykola-siusko
|
||||
design:
|
||||
image: summit02
|
||||
|
||||
- id: h24ble
|
||||
issue: 7
|
||||
|
@ -396,6 +406,8 @@
|
|||
- mykola-siusko
|
||||
- pg
|
||||
- tree
|
||||
design:
|
||||
image: brno01
|
||||
|
||||
- id: c24brn
|
||||
issue: 24
|
||||
|
|
|
@ -34,7 +34,7 @@ export class Engine {
|
|||
if (await exists(join(dir, "index.yaml"))) {
|
||||
const out = await readYamlFile(join(dir, "index.yaml"));
|
||||
if (opts.loader === "events") {
|
||||
// check speaker connection
|
||||
// check speaker connection & load event images
|
||||
for (const ev of out) {
|
||||
if (ev.speakers) {
|
||||
for (const spId of ev.speakers) {
|
||||
|
@ -43,6 +43,21 @@ export class Engine {
|
|||
}
|
||||
}
|
||||
}
|
||||
// load events images
|
||||
const year = ev.date.match(/^(\d{4})/)[1];
|
||||
const yearDir = join(dir, '_images', year);
|
||||
if (!await exists(yearDir)) {
|
||||
continue
|
||||
}
|
||||
const images = {}
|
||||
for await (const ie of Deno.readDir(yearDir)) {
|
||||
const [id, ext] = ie.name.split(".");
|
||||
if (id.match(new RegExp(`^${ev.id}-`))) {
|
||||
const imgName = id.split('-').slice(1).join('-')
|
||||
images[imgName] = `https://data.web3privacy.info/img/events/${year}/${id}.${ext}`;
|
||||
}
|
||||
}
|
||||
ev.images = images
|
||||
}
|
||||
}
|
||||
return out;
|
||||
|
@ -55,6 +70,7 @@ export class Engine {
|
|||
images.push({ id, ext });
|
||||
}
|
||||
}
|
||||
|
||||
const arr = [];
|
||||
for await (const dirEntry of Deno.readDir(dir)) {
|
||||
const [fn, ext] = dirEntry.name.split(".");
|
||||
|
@ -109,6 +125,12 @@ export class Engine {
|
|||
join(DEST_DIR, "img", "people"),
|
||||
);
|
||||
|
||||
// copy event images
|
||||
await copy(
|
||||
join(SRC_DIR, "events", "_images"),
|
||||
join(DEST_DIR, "img", "events"),
|
||||
);
|
||||
|
||||
await writeJSONFile(
|
||||
join(DEST_DIR, "index.json"),
|
||||
Object.assign({}, this.rendered),
|
||||
|
|
61
utils/images.js
Normal file
|
@ -0,0 +1,61 @@
|
|||
import { Engine } from "./engine.js";
|
||||
import { join } from "https://deno.land/std@0.208.0/path/mod.ts";
|
||||
import { exists } from "https://deno.land/std@0.213.0/fs/exists.ts";
|
||||
|
||||
const engine = new Engine();
|
||||
await engine.init();
|
||||
|
||||
async function genImage (destFn, url, element) {
|
||||
|
||||
console.log(`Getting ${url} (${element}) (dest=${destFn})`)
|
||||
const file = await fetch("https://html2svg.gwei.cz", {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'Content-Type': 'application/json'
|
||||
},
|
||||
body: JSON.stringify({
|
||||
url,
|
||||
element,
|
||||
format: 'webp',
|
||||
scale: 4,
|
||||
})
|
||||
});
|
||||
|
||||
if (file.body) {
|
||||
const fileOutput = await Deno.open(destFn, { write: true, create: true });
|
||||
await file.body.pipeTo(fileOutput.writable);
|
||||
console.log(`File written: ${destFn}`)
|
||||
}
|
||||
}
|
||||
|
||||
// events
|
||||
const DEST_DIR = './src/events/_images';
|
||||
const eventFormats = [
|
||||
'square',
|
||||
'wide-square',
|
||||
'wide',
|
||||
'poster',
|
||||
'poster-simple'
|
||||
]
|
||||
|
||||
for(const event of engine.rendered.events) {
|
||||
if (!event.design) {
|
||||
continue
|
||||
}
|
||||
const year = event.date.match(/^(\d{4})/)[1]
|
||||
const design = event.design
|
||||
for (const format of eventFormats) {
|
||||
|
||||
const destFn = join(DEST_DIR, year, `${event.id}-${format}.webp`);
|
||||
if (await exists(destFn)) {
|
||||
console.log(`${destFn} existing, skipping ..`)
|
||||
continue;
|
||||
}
|
||||
|
||||
await genImage(
|
||||
destFn,
|
||||
`https://beta.web3privacy.info/gen/event?id=${event.id}&image=${design.image}`,
|
||||
`#img-${format}`
|
||||
);
|
||||
}
|
||||
}
|