From 58254c5cc9d30f5fa9fa02c455a11a6a42b52042 Mon Sep 17 00:00:00 2001 From: tree Date: Fri, 7 Apr 2023 00:09:13 +0200 Subject: [PATCH] fmt also event sync scripts --- Makefile | 2 +- data/23/events/bitcoin-prague/_sync.js | 30 ++++---- data/23/events/ethprague/_sync.js | 70 +++++++++--------- data/23/events/gateway/_sync.js | 82 +++++++++++----------- data/23/events/metaverse-festival/_sync.js | 62 ++++++++-------- data/23/events/praguedefi/_sync.js | 21 +++--- data/23/events/utxo/_sync.js | 9 +-- data/23/events/web3privacy/_sync.js | 34 ++++----- 8 files changed, 161 insertions(+), 149 deletions(-) diff --git a/Makefile b/Makefile index e4bdf7d..aa5cedc 100644 --- a/Makefile +++ b/Makefile @@ -11,7 +11,7 @@ link-check: lychee spec/**/*.yaml format: - deno fmt utils/*.js README.md + deno fmt utils/*.js data/*/events/*/*.js README.md fmt: format diff --git a/data/23/events/bitcoin-prague/_sync.js b/data/23/events/bitcoin-prague/_sync.js index f3c7985..86818ba 100644 --- a/data/23/events/bitcoin-prague/_sync.js +++ b/data/23/events/bitcoin-prague/_sync.js @@ -4,33 +4,39 @@ export async function data(tools) { const out = { speakers: [] }; const peopleMapper = { - 'Dušan Matuška': { country: 'sk' } - } + "Dušan Matuška": { country: "sk" }, + }; for (const el of $(".speaker").toArray()) { const value = (path) => cleanup($(path, el).text()); - const name = value("h3") - const link = $("a", el).attr("href") + const name = value("h3"); + const link = $("a", el).attr("href"); - const $$ = await tools.loadHtmlUrl(link) - const sp = $$('.container.pt-5') + const $$ = await tools.loadHtmlUrl(link); + const sp = $$(".container.pt-5"); const item = { id: link.match(/speakers\/(.+)\/$/)[1], name, photoUrl: $("img", el).attr("src"), caption: value(".popis"), - twitter: $$("a.twitter", sp).attr("href")?.replace("https://twitter.com/",""), - linkedin: $$("a.linkedIn", sp).attr("href")?.replace("https://www.linkedin.com/in/","").replace(/\/$/,""), + twitter: $$("a.twitter", sp).attr("href")?.replace( + "https://twitter.com/", + "", + ), + linkedin: $$("a.linkedIn", sp).attr("href")?.replace( + "https://www.linkedin.com/in/", + "", + ).replace(/\/$/, ""), tag: value(".taxTag "), //country: 'xx', - desc: $$('p', sp).text(), + desc: $$("p", sp).text(), web: { url: $$(".www", sp).attr("href") }, - link - } + link, + }; if (peopleMapper[name]) { - Object.assign(item, peopleMapper[name]) + Object.assign(item, peopleMapper[name]); } out.speakers.push(item); } diff --git a/data/23/events/ethprague/_sync.js b/data/23/events/ethprague/_sync.js index eb0e29d..117dd7b 100644 --- a/data/23/events/ethprague/_sync.js +++ b/data/23/events/ethprague/_sync.js @@ -1,27 +1,27 @@ const peopleMapper = { - "dcbuilder.eth": { country: "cz" }, - "luc.computer": { country: "nl" }, - "Ferit Tunçer": { country: "pt" }, - "Puncar": { country: "us" }, - "Miao ZhiCheng": { country: "ee" }, - "Cryptowanderer": { country: "za" }, - //"Daniel Lumi": { country: "" }, - "Nicolas Manea": { country: "gb" }, - "Tim Beiko": { country: "ca" }, - "Abeer Sharma": { country: "hk" }, - "Dustin Jacobus": { country: "be" }, - "Rhys Williams": { country: "gb" }, - "Sahil Sen": { country: "in" }, - "Steffen Kux": { country: "de" }, - }; - - export async function data($) { - const res = await $.loadJSONUrl( - "https://graphql.contentful.com/content/v1/spaces/6j1me6tz5h39/environments/master", - { - method: "POST", - body: JSON.stringify({ - query: ` + "dcbuilder.eth": { country: "cz" }, + "luc.computer": { country: "nl" }, + "Ferit Tunçer": { country: "pt" }, + "Puncar": { country: "us" }, + "Miao ZhiCheng": { country: "ee" }, + "Cryptowanderer": { country: "za" }, + //"Daniel Lumi": { country: "" }, + "Nicolas Manea": { country: "gb" }, + "Tim Beiko": { country: "ca" }, + "Abeer Sharma": { country: "hk" }, + "Dustin Jacobus": { country: "be" }, + "Rhys Williams": { country: "gb" }, + "Sahil Sen": { country: "in" }, + "Steffen Kux": { country: "de" }, +}; + +export async function data($) { + const res = await $.loadJSONUrl( + "https://graphql.contentful.com/content/v1/spaces/6j1me6tz5h39/environments/master", + { + method: "POST", + body: JSON.stringify({ + query: ` { ethPraguePeopleSortedCollection(limit: 1) { items { @@ -47,16 +47,17 @@ const peopleMapper = { } } } - }` - }), - headers: { - "content-type": "application/json", - authorization: "Bearer 7xdKQm9l5CXQE6tXXKYxNQ_lgvanmpdUgT20pIlxfOk", - }, + }`, + }), + headers: { + "content-type": "application/json", + authorization: "Bearer 7xdKQm9l5CXQE6tXXKYxNQ_lgvanmpdUgT20pIlxfOk", }, - ); - return { - speakers: res.data.ethPraguePeopleSortedCollection.items[0].ethPraguePeopleSortedCollection.items.map((s) => + }, + ); + return { + speakers: res.data.ethPraguePeopleSortedCollection.items[0] + .ethPraguePeopleSortedCollection.items.map((s) => Object.assign({ id: $.formatId(s.name), name: s.name, @@ -65,6 +66,5 @@ const peopleMapper = { photoUrl: s.profileImage?.url, }, peopleMapper[s.name] || {}) ).sort((x, y) => x.id > y.id ? -1 : 1), - }; - } - \ No newline at end of file + }; +} diff --git a/data/23/events/gateway/_sync.js b/data/23/events/gateway/_sync.js index e6b298b..a4121f5 100644 --- a/data/23/events/gateway/_sync.js +++ b/data/23/events/gateway/_sync.js @@ -1,44 +1,46 @@ export async function data(tools) { - const $ = await tools.loadHtmlUrl("https://gateway.events/"); - const out = { speakers: [] }; - - const peopleMapper = { - 'Federico Kunze Küllmer': { country: 'de' }, - 'Sunny Aggarwal': { country: 'tw' }, - 'Zaki Manian': { country: 'us' }, - 'Sergey Gorbunov': { country: 'us' }, - 'Dean Tribble': { country: 'us' }, - 'Sean Braithwaite': { country: 'de' } - } - - for (const el of $("#speakers div.w-full.relative").toArray()) { - const value = (path) => cleanup($(path, el).text()); - const name = value("h3 span") + const $ = await tools.loadHtmlUrl("https://gateway.events/"); + const out = { speakers: [] }; - const item = { - id: tools.formatId(name), - name, - photoUrl: $("div.group img", el).attr("src"), - caption: value("div.text-white"), - twitter: $("div.flex a", el).attr("href")?.replace("https://twitter.com/","").replace(/\?lang=\w{2}$/, ''), - //linkedin: $$("a.linkedIn", sp).attr("href")?.replace("https://www.linkedin.com/in/","").replace(/\/$/,""), - //tag: value(".taxTag "), - //country: 'xx', - //desc: $$('p', sp).text(), - //web: { url: $$(".www", sp).attr("href") }, - //link - } - - if (peopleMapper[name]) { - Object.assign(item, peopleMapper[name]) - } - out.speakers.push(item); + const peopleMapper = { + "Federico Kunze Küllmer": { country: "de" }, + "Sunny Aggarwal": { country: "tw" }, + "Zaki Manian": { country: "us" }, + "Sergey Gorbunov": { country: "us" }, + "Dean Tribble": { country: "us" }, + "Sean Braithwaite": { country: "de" }, + }; + + for (const el of $("#speakers div.w-full.relative").toArray()) { + const value = (path) => cleanup($(path, el).text()); + const name = value("h3 span"); + + const item = { + id: tools.formatId(name), + name, + photoUrl: $("div.group img", el).attr("src"), + caption: value("div.text-white"), + twitter: $("div.flex a", el).attr("href")?.replace( + "https://twitter.com/", + "", + ).replace(/\?lang=\w{2}$/, ""), + //linkedin: $$("a.linkedIn", sp).attr("href")?.replace("https://www.linkedin.com/in/","").replace(/\/$/,""), + //tag: value(".taxTag "), + //country: 'xx', + //desc: $$('p', sp).text(), + //web: { url: $$(".www", sp).attr("href") }, + //link + }; + + if (peopleMapper[name]) { + Object.assign(item, peopleMapper[name]); } - //console.log(out) - return out; + out.speakers.push(item); } - - function cleanup(str) { - return str.replace(/(\s{2,}|\n)/g, " ").trim(); - } - \ No newline at end of file + //console.log(out) + return out; +} + +function cleanup(str) { + return str.replace(/(\s{2,}|\n)/g, " ").trim(); +} diff --git a/data/23/events/metaverse-festival/_sync.js b/data/23/events/metaverse-festival/_sync.js index 4b1f295..28a0c0d 100644 --- a/data/23/events/metaverse-festival/_sync.js +++ b/data/23/events/metaverse-festival/_sync.js @@ -12,45 +12,45 @@ const peopleMapper = { "Natália Rajnohová": { country: "sk" }, "Olska Green": { country: "pt" }, "Ondrej T.": { country: "sk" }, - "Pavla Julia Kolářová": { country: "cz" }, - "Sara Polak": { country: "cz" }, - "Thomas De Bruyne": { country: "be" }, + "Pavla Julia Kolářová": { country: "cz" }, + "Sara Polak": { country: "cz" }, + "Thomas De Bruyne": { country: "be" }, "Timmu Toke": { country: "us" }, "Julie Šislerová": { country: "cz" }, "Kateřinak Škarabelová": { country: "cz" }, }; export async function data(tools) { - const $ = await tools.loadHtmlUrl("https://metaversefestivalprague.com/"); - const out = { speakers: [] }; + const $ = await tools.loadHtmlUrl("https://metaversefestivalprague.com/"); + const out = { speakers: [] }; - for (const el of $("div.elementor-col-16").toArray()) { - const name = cleanupName($('h3 span', el).html()) - if (name === "Reveal Soon") { - continue; - } - - const item = { - id: tools.formatId(name), - name, - caption: $('p.elementor-icon-box-description', el).text().trim(), - photoUrl: $('div.elementor-widget-container img', el).attr('src'), - } - - if (peopleMapper[name]) { - Object.assign(item, peopleMapper[name]) - } - out.speakers.push(item); + for (const el of $("div.elementor-col-16").toArray()) { + const name = cleanupName($("h3 span", el).html()); + if (name === "Reveal Soon") { + continue; } - return out; + const item = { + id: tools.formatId(name), + name, + caption: $("p.elementor-icon-box-description", el).text().trim(), + photoUrl: $("div.elementor-widget-container img", el).attr("src"), + }; + + if (peopleMapper[name]) { + Object.assign(item, peopleMapper[name]); + } + out.speakers.push(item); } - function cleanupName (str) { - return Html5Entities.decode(str.trim()) - .replace(/\s?
\s?/, ' ') - .toLowerCase() - .split(' ') - .map(str => str.charAt(0).toUpperCase() + str.slice(1)) - .join(' ') - } \ No newline at end of file + return out; +} + +function cleanupName(str) { + return Html5Entities.decode(str.trim()) + .replace(/\s?
\s?/, " ") + .toLowerCase() + .split(" ") + .map((str) => str.charAt(0).toUpperCase() + str.slice(1)) + .join(" "); +} diff --git a/data/23/events/praguedefi/_sync.js b/data/23/events/praguedefi/_sync.js index 06ead75..2685bc2 100644 --- a/data/23/events/praguedefi/_sync.js +++ b/data/23/events/praguedefi/_sync.js @@ -42,7 +42,7 @@ export async function data($) { } } } - }` + }`, }), headers: { "content-type": "application/json", @@ -51,14 +51,15 @@ export async function data($) { }, ); return { - speakers: res.data.pragueDefiSummitPeopleSortedCollection.items[0].pdsPeopleSortedCollection.items.map((s) => - Object.assign({ - id: $.formatId(s.name), - name: s.name, - twitter: s.twitter.replace("https://twitter.com/", ""), - caption: s.company || "", - photoUrl: s.profileImage?.url, - }, peopleMapper[s.name] || {}) - ), + speakers: res.data.pragueDefiSummitPeopleSortedCollection.items[0] + .pdsPeopleSortedCollection.items.map((s) => + Object.assign({ + id: $.formatId(s.name), + name: s.name, + twitter: s.twitter.replace("https://twitter.com/", ""), + caption: s.company || "", + photoUrl: s.profileImage?.url, + }, peopleMapper[s.name] || {}) + ), }; } diff --git a/data/23/events/utxo/_sync.js b/data/23/events/utxo/_sync.js index ebfd4a7..4b73aed 100644 --- a/data/23/events/utxo/_sync.js +++ b/data/23/events/utxo/_sync.js @@ -1,12 +1,13 @@ export async function data($) { const bundle = await $.loadJSONUrl("https://spec.utxo.cz/23/bundle.json"); return { - speakers: bundle.spec.speakers.map(s => { + speakers: bundle.spec.speakers.map((s) => { if (s.photos && s.photos[0]) { - const [ tp, ext ] = s.photos[0].split(":") - s.photoUrl = `https://spec.utxo.cz/23/photos/speakers/${s.id}-${tp}.${ext}` + const [tp, ext] = s.photos[0].split(":"); + s.photoUrl = + `https://spec.utxo.cz/23/photos/speakers/${s.id}-${tp}.${ext}`; } - return s + return s; }), tracks: bundle.spec.tracks, }; diff --git a/data/23/events/web3privacy/_sync.js b/data/23/events/web3privacy/_sync.js index 7038978..a5ca90a 100644 --- a/data/23/events/web3privacy/_sync.js +++ b/data/23/events/web3privacy/_sync.js @@ -1,20 +1,22 @@ - const peopleMapper = { - //"Radek Svarz": { country: "cz" }, + //"Radek Svarz": { country: "cz" }, }; export async function data($) { - const res = await $.loadJSONUrl("https://prague.web3privacy.info/config.json"); - return { - speakers: res.speakers.map(pid => res.people.find(p => p.id === pid)).map((s) => - Object.assign({ - id: $.formatId(s.name), - name: s.name, - twitter: s.twitter, - caption: s.caption, - country: s.country, - photoUrl: `https://prague.web3privacy.info/people/${s.img}`, - }, peopleMapper[s.name] || {}) - ), - }; -} \ No newline at end of file + const res = await $.loadJSONUrl( + "https://prague.web3privacy.info/config.json", + ); + return { + speakers: res.speakers.map((pid) => res.people.find((p) => p.id === pid)) + .map((s) => + Object.assign({ + id: $.formatId(s.name), + name: s.name, + twitter: s.twitter, + caption: s.caption, + country: s.country, + photoUrl: `https://prague.web3privacy.info/people/${s.img}`, + }, peopleMapper[s.name] || {}) + ), + }; +}