diff --git a/package.json b/package.json index c9c2195..f8c371e 100644 --- a/package.json +++ b/package.json @@ -16,6 +16,7 @@ "explorer": "deno run --allow-all utils/explorer.js", "events-ext": "deno run --allow-all utils/events-ext.js", "db-repo": "deno run --allow-all utils/db-repo.js", + "gen-images": "deno run --allow-all utils/gen-images.js", "sync-all": "npm run core && npm run contribs && npm run articles && npm run talks && npm run explorer && npm run events-ext && npm run db-repo" }, "dependencies": { diff --git a/src/components/EventImageGenerator.svelte b/src/components/EventImageGenerator.svelte index 64c3b4e..4618eb1 100644 --- a/src/components/EventImageGenerator.svelte +++ b/src/components/EventImageGenerator.svelte @@ -1,6 +1,8 @@ @@ -179,7 +153,7 @@ onMount(updateImages); Image: diff --git a/src/components/event-formats/wide-square.svelte b/src/components/event-formats/wide-square.svelte index 09673af..9e68fc9 100644 --- a/src/components/event-formats/wide-square.svelte +++ b/src/components/event-formats/wide-square.svelte @@ -17,7 +17,7 @@
- +
diff --git a/src/components/event-formats/wide.svelte b/src/components/event-formats/wide.svelte index 29e5b9a..d7c396c 100644 --- a/src/components/event-formats/wide.svelte +++ b/src/components/event-formats/wide.svelte @@ -15,7 +15,7 @@
- +
diff --git a/src/gen-images.json b/src/gen-images.json new file mode 100644 index 0000000..fbcc51d --- /dev/null +++ b/src/gen-images.json @@ -0,0 +1,128 @@ +{ + "brno01": { + "format": "PNG", + "width": 3000, + "height": 3000, + "ratio": 1 + }, + "brussels01": { + "format": "PNG", + "width": 6951, + "height": 3502, + "ratio": 1.9848657909765848 + }, + "bucharest01": { + "format": "PNG", + "width": 7025, + "height": 3535, + "ratio": 1.9872701555869872 + }, + "porto01": { + "format": "PNG", + "width": 1024, + "height": 1024, + "ratio": 1 + }, + "summit01": { + "format": "PNG", + "width": 2100, + "height": 2100, + "ratio": 1 + }, + "summit02": { + "format": "PNG", + "width": 2600, + "height": 2600, + "ratio": 1 + }, + "ljubljana01": { + "format": "PNG", + "width": 768, + "height": 768, + "ratio": 1 + }, + "warsaw01": { + "format": "PNG", + "width": 6951, + "height": 3476, + "ratio": 1.9997123130034522 + }, + "athens01": { + "format": "PNG", + "width": 2048, + "height": 2048, + "ratio": 1 + }, + "bangkok01": { + "format": "PNG", + "width": 6995, + "height": 3511, + "ratio": 1.9923098832241526 + }, + "rome01": { + "format": "PNG", + "width": 1024, + "height": 1024, + "ratio": 1 + }, + "barcelona02": { + "format": "PNG", + "width": 7012, + "height": 3028, + "ratio": 2.3157199471598413 + }, + "rome02": { + "format": "PNG", + "width": 7025, + "height": 2876, + "ratio": 2.4426286509040334 + }, + "tallinn01": { + "format": "PNG", + "width": 2600, + "height": 2600, + "ratio": 1 + }, + "barcelona01": { + "format": "PNG", + "width": 768, + "height": 768, + "ratio": 1 + }, + "berlin01": { + "format": "PNG", + "width": 1536, + "height": 1536, + "ratio": 1 + }, + "copenhagen01": { + "format": "PNG", + "width": 768, + "height": 768, + "ratio": 1 + }, + "berlin02": { + "format": "PNG", + "width": 768, + "height": 768, + "ratio": 1 + }, + "berlin03": { + "format": "PNG", + "width": 7000, + "height": 3520, + "ratio": 1.9886363636363635 + }, + "copenhagen02": { + "format": "PNG", + "width": 7025, + "height": 3511, + "ratio": 2.0008544574195386 + }, + "amsterdam01": { + "format": "PNG", + "width": 7025, + "height": 3535, + "ratio": 1.9872701555869872 + } +} \ No newline at end of file diff --git a/utils/db-repo.js b/utils/db-repo.js index e08ce58..94cc5da 100644 --- a/utils/db-repo.js +++ b/utils/db-repo.js @@ -1,26 +1,30 @@ - - // projects count -const resp = await fetch("https://raw.githubusercontent.com/web3privacy/web3privacy/main/README.md"); +const resp = await fetch( + "https://raw.githubusercontent.com/web3privacy/web3privacy/main/README.md", +); const text = await resp.text(); -const [_, count] = text.match(/([\d\+]+) privacy projects/) +const [_, count] = text.match(/([\d\+]+) privacy projects/); // contributors -const response = await fetch(`https://api.github.com/repos/web3privacy/web3privacy/contributors`,); +const response = await fetch( + `https://api.github.com/repos/web3privacy/web3privacy/contributors`, +); const repoContributors = await response.json(); // stars -const respRepo = await fetch('https://api.github.com/repos/web3privacy/web3privacy') +const respRepo = await fetch( + "https://api.github.com/repos/web3privacy/web3privacy", +); const repo = await respRepo.json(); const data = { - count, - contributors: repoContributors.length, - stars: repo.stargazers_count, -} + count, + contributors: repoContributors.length, + stars: repo.stargazers_count, +}; await Deno.writeTextFile( - "./src/db-repo.json", - JSON.stringify(data, null, 2), - ); - console.log(`File ./src/db-repo.json saved`); \ No newline at end of file + "./src/db-repo.json", + JSON.stringify(data, null, 2), +); +console.log(`File ./src/db-repo.json saved`); diff --git a/utils/gen-images.js b/utils/gen-images.js new file mode 100644 index 0000000..2fc639c --- /dev/null +++ b/utils/gen-images.js @@ -0,0 +1,23 @@ +import { run } from "https://deno.land/x/run_simple/mod.ts"; +import { join } from "https://deno.land/std@0.208.0/path/mod.ts"; + +const IMG_DIR = "./public/gen-img/events"; + +const data = {}; +for await (const f of Deno.readDir(IMG_DIR)) { + const [name, ext] = f.name.split("."); + if (ext !== "png") { + continue; + } + const explain = await run(`identify ${join(IMG_DIR, f.name)}`); + const [_, format, resolution] = explain.split(" "); + const [width, height] = resolution.split("x").map((c) => Number(c)); + + data[name] = { format, width, height, ratio: width / height }; +} + +await Deno.writeTextFile( + "./src/gen-images.json", + JSON.stringify(data, null, 2), +); +console.log(`File ./src/gen-images.json saved`);