fmt also event sync scripts

This commit is contained in:
tree 2023-04-07 00:09:13 +02:00
rodič e476cd9643
revize 58254c5cc9
8 změnil soubory, kde provedl 161 přidání a 149 odebrání

Zobrazit soubor

@ -11,7 +11,7 @@ link-check:
lychee spec/**/*.yaml lychee spec/**/*.yaml
format: format:
deno fmt utils/*.js README.md deno fmt utils/*.js data/*/events/*/*.js README.md
fmt: format fmt: format

Zobrazit soubor

@ -4,33 +4,39 @@ export async function data(tools) {
const out = { speakers: [] }; const out = { speakers: [] };
const peopleMapper = { const peopleMapper = {
'Dušan Matuška': { country: 'sk' } "Dušan Matuška": { country: "sk" },
} };
for (const el of $(".speaker").toArray()) { for (const el of $(".speaker").toArray()) {
const value = (path) => cleanup($(path, el).text()); const value = (path) => cleanup($(path, el).text());
const name = value("h3") const name = value("h3");
const link = $("a", el).attr("href") const link = $("a", el).attr("href");
const $$ = await tools.loadHtmlUrl(link) const $$ = await tools.loadHtmlUrl(link);
const sp = $$('.container.pt-5') const sp = $$(".container.pt-5");
const item = { const item = {
id: link.match(/speakers\/(.+)\/$/)[1], id: link.match(/speakers\/(.+)\/$/)[1],
name, name,
photoUrl: $("img", el).attr("src"), photoUrl: $("img", el).attr("src"),
caption: value(".popis"), caption: value(".popis"),
twitter: $$("a.twitter", sp).attr("href")?.replace("https://twitter.com/",""), twitter: $$("a.twitter", sp).attr("href")?.replace(
linkedin: $$("a.linkedIn", sp).attr("href")?.replace("https://www.linkedin.com/in/","").replace(/\/$/,""), "https://twitter.com/",
"",
),
linkedin: $$("a.linkedIn", sp).attr("href")?.replace(
"https://www.linkedin.com/in/",
"",
).replace(/\/$/, ""),
tag: value(".taxTag "), tag: value(".taxTag "),
//country: 'xx', //country: 'xx',
desc: $$('p', sp).text(), desc: $$("p", sp).text(),
web: { url: $$(".www", sp).attr("href") }, web: { url: $$(".www", sp).attr("href") },
link link,
} };
if (peopleMapper[name]) { if (peopleMapper[name]) {
Object.assign(item, peopleMapper[name]) Object.assign(item, peopleMapper[name]);
} }
out.speakers.push(item); out.speakers.push(item);
} }

Zobrazit soubor

@ -1,27 +1,27 @@
const peopleMapper = { const peopleMapper = {
"dcbuilder.eth": { country: "cz" }, "dcbuilder.eth": { country: "cz" },
"luc.computer": { country: "nl" }, "luc.computer": { country: "nl" },
"Ferit Tunçer": { country: "pt" }, "Ferit Tunçer": { country: "pt" },
"Puncar": { country: "us" }, "Puncar": { country: "us" },
"Miao ZhiCheng": { country: "ee" }, "Miao ZhiCheng": { country: "ee" },
"Cryptowanderer": { country: "za" }, "Cryptowanderer": { country: "za" },
//"Daniel Lumi": { country: "" }, //"Daniel Lumi": { country: "" },
"Nicolas Manea": { country: "gb" }, "Nicolas Manea": { country: "gb" },
"Tim Beiko": { country: "ca" }, "Tim Beiko": { country: "ca" },
"Abeer Sharma": { country: "hk" }, "Abeer Sharma": { country: "hk" },
"Dustin Jacobus": { country: "be" }, "Dustin Jacobus": { country: "be" },
"Rhys Williams": { country: "gb" }, "Rhys Williams": { country: "gb" },
"Sahil Sen": { country: "in" }, "Sahil Sen": { country: "in" },
"Steffen Kux": { country: "de" }, "Steffen Kux": { country: "de" },
}; };
export async function data($) { export async function data($) {
const res = await $.loadJSONUrl( const res = await $.loadJSONUrl(
"https://graphql.contentful.com/content/v1/spaces/6j1me6tz5h39/environments/master", "https://graphql.contentful.com/content/v1/spaces/6j1me6tz5h39/environments/master",
{ {
method: "POST", method: "POST",
body: JSON.stringify({ body: JSON.stringify({
query: ` query: `
{ {
ethPraguePeopleSortedCollection(limit: 1) { ethPraguePeopleSortedCollection(limit: 1) {
items { items {
@ -47,16 +47,17 @@ const peopleMapper = {
} }
} }
} }
}` }`,
}), }),
headers: { headers: {
"content-type": "application/json", "content-type": "application/json",
authorization: "Bearer 7xdKQm9l5CXQE6tXXKYxNQ_lgvanmpdUgT20pIlxfOk", 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({ Object.assign({
id: $.formatId(s.name), id: $.formatId(s.name),
name: s.name, name: s.name,
@ -65,6 +66,5 @@ const peopleMapper = {
photoUrl: s.profileImage?.url, photoUrl: s.profileImage?.url,
}, peopleMapper[s.name] || {}) }, peopleMapper[s.name] || {})
).sort((x, y) => x.id > y.id ? -1 : 1), ).sort((x, y) => x.id > y.id ? -1 : 1),
}; };
} }

Zobrazit soubor

@ -1,44 +1,46 @@
export async function data(tools) { export async function data(tools) {
const $ = await tools.loadHtmlUrl("https://gateway.events/"); const $ = await tools.loadHtmlUrl("https://gateway.events/");
const out = { speakers: [] }; 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 item = { const peopleMapper = {
id: tools.formatId(name), "Federico Kunze Küllmer": { country: "de" },
name, "Sunny Aggarwal": { country: "tw" },
photoUrl: $("div.group img", el).attr("src"), "Zaki Manian": { country: "us" },
caption: value("div.text-white"), "Sergey Gorbunov": { country: "us" },
twitter: $("div.flex a", el).attr("href")?.replace("https://twitter.com/","").replace(/\?lang=\w{2}$/, ''), "Dean Tribble": { country: "us" },
//linkedin: $$("a.linkedIn", sp).attr("href")?.replace("https://www.linkedin.com/in/","").replace(/\/$/,""), "Sean Braithwaite": { country: "de" },
//tag: value(".taxTag "), };
//country: 'xx',
//desc: $$('p', sp).text(), for (const el of $("#speakers div.w-full.relative").toArray()) {
//web: { url: $$(".www", sp).attr("href") }, const value = (path) => cleanup($(path, el).text());
//link const name = value("h3 span");
}
const item = {
if (peopleMapper[name]) { id: tools.formatId(name),
Object.assign(item, peopleMapper[name]) name,
} photoUrl: $("div.group img", el).attr("src"),
out.speakers.push(item); 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) out.speakers.push(item);
return out;
} }
//console.log(out)
function cleanup(str) { return out;
return str.replace(/(\s{2,}|\n)/g, " ").trim(); }
}
function cleanup(str) {
return str.replace(/(\s{2,}|\n)/g, " ").trim();
}

Zobrazit soubor

@ -12,45 +12,45 @@ const peopleMapper = {
"Natália Rajnohová": { country: "sk" }, "Natália Rajnohová": { country: "sk" },
"Olska Green": { country: "pt" }, "Olska Green": { country: "pt" },
"Ondrej T.": { country: "sk" }, "Ondrej T.": { country: "sk" },
"Pavla Julia Kolářová": { country: "cz" }, "Pavla Julia Kolářová": { country: "cz" },
"Sara Polak": { country: "cz" }, "Sara Polak": { country: "cz" },
"Thomas De Bruyne": { country: "be" }, "Thomas De Bruyne": { country: "be" },
"Timmu Toke": { country: "us" }, "Timmu Toke": { country: "us" },
"Julie Šislerová": { country: "cz" }, "Julie Šislerová": { country: "cz" },
"Kateřinak Škarabelová": { country: "cz" }, "Kateřinak Škarabelová": { country: "cz" },
}; };
export async function data(tools) { export async function data(tools) {
const $ = await tools.loadHtmlUrl("https://metaversefestivalprague.com/"); const $ = await tools.loadHtmlUrl("https://metaversefestivalprague.com/");
const out = { speakers: [] }; const out = { speakers: [] };
for (const el of $("div.elementor-col-16").toArray()) { for (const el of $("div.elementor-col-16").toArray()) {
const name = cleanupName($('h3 span', el).html()) const name = cleanupName($("h3 span", el).html());
if (name === "Reveal Soon") { if (name === "Reveal Soon") {
continue; 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);
} }
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 out;
return Html5Entities.decode(str.trim()) }
.replace(/\s?<br>\s?/, ' ')
.toLowerCase() function cleanupName(str) {
.split(' ') return Html5Entities.decode(str.trim())
.map(str => str.charAt(0).toUpperCase() + str.slice(1)) .replace(/\s?<br>\s?/, " ")
.join(' ') .toLowerCase()
} .split(" ")
.map((str) => str.charAt(0).toUpperCase() + str.slice(1))
.join(" ");
}

Zobrazit soubor

@ -42,7 +42,7 @@ export async function data($) {
} }
} }
} }
}` }`,
}), }),
headers: { headers: {
"content-type": "application/json", "content-type": "application/json",
@ -51,14 +51,15 @@ export async function data($) {
}, },
); );
return { return {
speakers: res.data.pragueDefiSummitPeopleSortedCollection.items[0].pdsPeopleSortedCollection.items.map((s) => speakers: res.data.pragueDefiSummitPeopleSortedCollection.items[0]
Object.assign({ .pdsPeopleSortedCollection.items.map((s) =>
id: $.formatId(s.name), Object.assign({
name: s.name, id: $.formatId(s.name),
twitter: s.twitter.replace("https://twitter.com/", ""), name: s.name,
caption: s.company || "", twitter: s.twitter.replace("https://twitter.com/", ""),
photoUrl: s.profileImage?.url, caption: s.company || "",
}, peopleMapper[s.name] || {}) photoUrl: s.profileImage?.url,
), }, peopleMapper[s.name] || {})
),
}; };
} }

Zobrazit soubor

@ -1,12 +1,13 @@
export async function data($) { export async function data($) {
const bundle = await $.loadJSONUrl("https://spec.utxo.cz/23/bundle.json"); const bundle = await $.loadJSONUrl("https://spec.utxo.cz/23/bundle.json");
return { return {
speakers: bundle.spec.speakers.map(s => { speakers: bundle.spec.speakers.map((s) => {
if (s.photos && s.photos[0]) { if (s.photos && s.photos[0]) {
const [ tp, ext ] = s.photos[0].split(":") const [tp, ext] = s.photos[0].split(":");
s.photoUrl = `https://spec.utxo.cz/23/photos/speakers/${s.id}-${tp}.${ext}` s.photoUrl =
`https://spec.utxo.cz/23/photos/speakers/${s.id}-${tp}.${ext}`;
} }
return s return s;
}), }),
tracks: bundle.spec.tracks, tracks: bundle.spec.tracks,
}; };

Zobrazit soubor

@ -1,20 +1,22 @@
const peopleMapper = { const peopleMapper = {
//"Radek Svarz": { country: "cz" }, //"Radek Svarz": { country: "cz" },
}; };
export async function data($) { export async function data($) {
const res = await $.loadJSONUrl("https://prague.web3privacy.info/config.json"); const res = await $.loadJSONUrl(
return { "https://prague.web3privacy.info/config.json",
speakers: res.speakers.map(pid => res.people.find(p => p.id === pid)).map((s) => );
Object.assign({ return {
id: $.formatId(s.name), speakers: res.speakers.map((pid) => res.people.find((p) => p.id === pid))
name: s.name, .map((s) =>
twitter: s.twitter, Object.assign({
caption: s.caption, id: $.formatId(s.name),
country: s.country, name: s.name,
photoUrl: `https://prague.web3privacy.info/people/${s.img}`, twitter: s.twitter,
}, peopleMapper[s.name] || {}) caption: s.caption,
), country: s.country,
}; photoUrl: `https://prague.web3privacy.info/people/${s.img}`,
} }, peopleMapper[s.name] || {})
),
};
}