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

@ -13,9 +13,9 @@ const peopleMapper = {
"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",
{ {
@ -47,7 +47,7 @@ const peopleMapper = {
} }
} }
} }
}` }`,
}), }),
headers: { headers: {
"content-type": "application/json", "content-type": "application/json",
@ -56,7 +56,8 @@ const peopleMapper = {
}, },
); );
return { return {
speakers: res.data.ethPraguePeopleSortedCollection.items[0].ethPraguePeopleSortedCollection.items.map((s) => 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,
@ -66,5 +67,4 @@ const peopleMapper = {
}, 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

@ -3,42 +3,44 @@ export async function data(tools) {
const out = { speakers: [] }; const out = { speakers: [] };
const peopleMapper = { const peopleMapper = {
'Federico Kunze Küllmer': { country: 'de' }, "Federico Kunze Küllmer": { country: "de" },
'Sunny Aggarwal': { country: 'tw' }, "Sunny Aggarwal": { country: "tw" },
'Zaki Manian': { country: 'us' }, "Zaki Manian": { country: "us" },
'Sergey Gorbunov': { country: 'us' }, "Sergey Gorbunov": { country: "us" },
'Dean Tribble': { country: 'us' }, "Dean Tribble": { country: "us" },
'Sean Braithwaite': { country: 'de' } "Sean Braithwaite": { country: "de" },
} };
for (const el of $("#speakers div.w-full.relative").toArray()) { for (const el of $("#speakers div.w-full.relative").toArray()) {
const value = (path) => cleanup($(path, el).text()); const value = (path) => cleanup($(path, el).text());
const name = value("h3 span") const name = value("h3 span");
const item = { const item = {
id: tools.formatId(name), id: tools.formatId(name),
name, name,
photoUrl: $("div.group img", el).attr("src"), photoUrl: $("div.group img", el).attr("src"),
caption: value("div.text-white"), caption: value("div.text-white"),
twitter: $("div.flex a", el).attr("href")?.replace("https://twitter.com/","").replace(/\?lang=\w{2}$/, ''), 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(/\/$/,""), //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);
} }
//console.log(out) //console.log(out)
return out; return out;
} }
function cleanup(str) { function cleanup(str) {
return str.replace(/(\s{2,}|\n)/g, " ").trim(); return str.replace(/(\s{2,}|\n)/g, " ").trim();
} }

Zobrazit soubor

@ -25,7 +25,7 @@ export async function data(tools) {
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;
} }
@ -33,24 +33,24 @@ export async function data(tools) {
const item = { const item = {
id: tools.formatId(name), id: tools.formatId(name),
name, name,
caption: $('p.elementor-icon-box-description', el).text().trim(), caption: $("p.elementor-icon-box-description", el).text().trim(),
photoUrl: $('div.elementor-widget-container img', el).attr('src'), photoUrl: $("div.elementor-widget-container img", el).attr("src"),
} };
if (peopleMapper[name]) { if (peopleMapper[name]) {
Object.assign(item, peopleMapper[name]) Object.assign(item, peopleMapper[name]);
} }
out.speakers.push(item); out.speakers.push(item);
} }
return out; return out;
} }
function cleanupName (str) { function cleanupName(str) {
return Html5Entities.decode(str.trim()) return Html5Entities.decode(str.trim())
.replace(/\s?<br>\s?/, ' ') .replace(/\s?<br>\s?/, " ")
.toLowerCase() .toLowerCase()
.split(' ') .split(" ")
.map(str => str.charAt(0).toUpperCase() + str.slice(1)) .map((str) => str.charAt(0).toUpperCase() + str.slice(1))
.join(' ') .join(" ");
} }

Zobrazit soubor

@ -42,7 +42,7 @@ export async function data($) {
} }
} }
} }
}` }`,
}), }),
headers: { headers: {
"content-type": "application/json", "content-type": "application/json",
@ -51,7 +51,8 @@ export async function data($) {
}, },
); );
return { return {
speakers: res.data.pragueDefiSummitPeopleSortedCollection.items[0].pdsPeopleSortedCollection.items.map((s) => speakers: res.data.pragueDefiSummitPeopleSortedCollection.items[0]
.pdsPeopleSortedCollection.items.map((s) =>
Object.assign({ Object.assign({
id: $.formatId(s.name), id: $.formatId(s.name),
name: s.name, name: 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,12 +1,14 @@
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(
"https://prague.web3privacy.info/config.json",
);
return { return {
speakers: res.speakers.map(pid => res.people.find(p => p.id === pid)).map((s) => speakers: res.speakers.map((pid) => res.people.find((p) => p.id === pid))
.map((s) =>
Object.assign({ Object.assign({
id: $.formatId(s.name), id: $.formatId(s.name),
name: s.name, name: s.name,