Projects collection

This commit is contained in:
tree 2022-01-19 01:15:57 +01:00
rodič 76935c6393
revize 21a43f3e4d
10 změnil soubory, kde provedl 60 přidání a 38 odebrání

Zobrazit soubor

@ -48,6 +48,7 @@ Veřejný HTTP endpoint s datovými soubory ve formátu JSON naleznete na adrese
| **events** | Události | [https://spec.utxo.cz/22/events.json](https://spec.utxo.cz/22/events.json) |
| **faqs** | Často kladené dotazy (FAQ) | [https://spec.utxo.cz/22/faqs.json](https://spec.utxo.cz/22/faqs.json) |
| **partners** | Partneři (sponzoři, mediální partneři atp.) | [https://spec.utxo.cz/22/partners.json](https://spec.utxo.cz/22/partners.json) |
| **projects** | Projekty | [https://spec.utxo.cz/22/projects.json](https://spec.utxo.cz/22/projects.json) |
| **bundle** | Vše v jednom souboru | [https://spec.utxo.cz/22/bundle.json](https://spec.utxo.cz/22/bundle.json) |
## Detaily k jednotlivým ročníkům

Zobrazit soubor

@ -21,3 +21,4 @@ specDef:
- type: events
- type: faqs
- type: partners
- type: projects

Binární soubor nebyl zobrazen.

Za

Šířka:  |  Výška:  |  Velikost: 24 KiB

Binární soubor nebyl zobrazen.

Za

Šířka:  |  Výška:  |  Velikost: 18 KiB

Binární soubor nebyl zobrazen.

Za

Šířka:  |  Výška:  |  Velikost: 18 KiB

Binární soubor nebyl zobrazen.

Za

Šířka:  |  Výška:  |  Velikost: 12 KiB

15
spec/22/projects.yaml Normal file
Zobrazit soubor

@ -0,0 +1,15 @@
- id: bitcoin
name: Bitcoin
twitter: Bitcoin
- id: ethereum
name: Ethereum
twitter: Ethereum
- id: polkadot
name: Polkadot
twitter: Polkadot
- id: cardano
name: Cardano
twitter: Cardano

Zobrazit soubor

@ -53,6 +53,7 @@ export class UTXOEngine {
// post processing of sub-specs
switch (sp.type) {
case "speakers":
case "projects":
case "partners":
for (const s of entry.specs[sp.type]) {
if (!s.photos) {

Zobrazit soubor

@ -0,0 +1,18 @@
type: array
items:
type: object
additionalProperties: false
required:
- id
- name
properties:
id:
type: string
pattern: "^[a-z0-9-]+$"
name:
type: string
twitter:
type: string
pattern: "^[a-zA-Z0-9_]+$"
photos:
type: array

Zobrazit soubor

@ -10,8 +10,7 @@ await utxo.init();
config({ path: ".env", export: true });
const twitterImagesPath = "./spec/22/photos/speakers/";
const twitterPartnersImagesPath = "./spec/22/photos/partners/";
const twitterImagesPath = "./spec/22/photos/";
const simple_twitter = new SimpleTwitter({
consumer_key: Deno.env.get("CONSUMER_KEY"),
@ -24,59 +23,46 @@ const simple_twitter = new SimpleTwitter({
const entryId = "22";
const entry = utxo.entries[entryId];
const collections = ["speakers", "partners", "projects"];
const arr = [];
let total = 0;
let items = [];
// partners
for (const sp of entry.specs.partners) {
if (!sp.twitter) {
continue;
}
const tw = await twitterUser(sp.twitter);
if (!tw) {
continue;
}
const imageFn = twitterPartnersImagesPath + sp.id + "-twitter.jpg";
async function fetchImageAndSave(tw, imageFn) {
if (!await exists(imageFn)) {
const url = tw.profile_image_url_https.replace("_normal", "");
console.log(url);
const res = await fetch(url);
const file = await Deno.open(imageFn, { create: true, write: true });
const reader = fromStreamReader(res.body.getReader());
await Deno.copy(reader, file);
file.close();
console.log(`Saved file: ${imageFn} (url=${url})`);
}
items.push([`partner:${sp.type}`, tw.screen_name, tw.followers_count]);
total += tw.followers_count;
}
// speakers
for (const col of collections) {
for (const sp of entry.specs[col]) {
if (!sp.twitter) {
continue;
}
const tw = await twitterUser(sp.twitter);
if (!tw) {
continue;
}
for (const sp of entry.specs.speakers) {
if (!sp.twitter) {
continue;
}
const tw = await twitterUser(sp.twitter);
if (!tw) {
continue;
}
await fetchImageAndSave(
tw,
twitterImagesPath + col + "/" + sp.id + "-twitter.jpg",
);
const imageFn = twitterImagesPath + sp.id + "-twitter.jpg";
if (!await exists(imageFn)) {
const url = tw.profile_image_url_https.replace("_normal", "");
console.log(url);
const res = await fetch(url);
const file = await Deno.open(imageFn, { create: true, write: true });
const reader = fromStreamReader(res.body.getReader());
await Deno.copy(reader, file);
file.close();
items.push([
`${col}${sp.type ? ":" + sp.type : ""}`,
tw.screen_name,
tw.followers_count,
]);
total += tw.followers_count;
}
items.push(["speaker", tw.screen_name, Number(tw.followers_count)]);
total += tw.followers_count;
}
arr.push(...items.sort((x, y) => x[2] < y[2] ? 1 : -1));