diff --git a/.gitignore b/.gitignore index ebf6203..56517d1 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ dist .sl -output \ No newline at end of file +output +.cache \ No newline at end of file diff --git a/Makefile b/Makefile index 67cdc3e..b3a49d1 100644 --- a/Makefile +++ b/Makefile @@ -19,5 +19,8 @@ consolidate: mkdir ./output/data cp ./dist/bundle.json ./output/data/index.json +extend: + deno run --unstable --allow-read --allow-write --allow-net utils/extend.js + fmt: deno fmt utils/*.js \ No newline at end of file diff --git a/config.yaml b/config.yaml index 0ef08c6..43bdd95 100644 --- a/config.yaml +++ b/config.yaml @@ -7,4 +7,6 @@ collections: companies: {} people: model: person - projects: {} \ No newline at end of file + projects: {} +extenders: + eips: {} \ No newline at end of file diff --git a/data/collectives/w3pn/eegid b/data/collectives/web3privacy/eegid similarity index 100% rename from data/collectives/w3pn/eegid rename to data/collectives/web3privacy/eegid diff --git a/data/collectives/w3pn/index.yaml b/data/collectives/web3privacy/index.yaml similarity index 100% rename from data/collectives/w3pn/index.yaml rename to data/collectives/web3privacy/index.yaml diff --git a/data/people/mario-havel/index.yaml b/data/people/mario-havel/index.yaml index c90e623..e71ae98 100644 --- a/data/people/mario-havel/index.yaml +++ b/data/people/mario-havel/index.yaml @@ -1,3 +1,4 @@ name: Mario Havel links: - twitter: https://twitter.com/TMIYChao \ No newline at end of file + twitter: https://twitter.com/TMIYChao + github: https://github.com/taxmeifyoucan \ No newline at end of file diff --git a/data/people/micah-zoltu/index.yaml b/data/people/micah-zoltu/index.yaml new file mode 100644 index 0000000..902059d --- /dev/null +++ b/data/people/micah-zoltu/index.yaml @@ -0,0 +1,3 @@ +name: Micah Zoltu +links: + github: https://github.com/MicahZoltu \ No newline at end of file diff --git a/data/people/peter-szilagyi/index.yaml b/data/people/peter-szilagyi/index.yaml new file mode 100644 index 0000000..be41984 --- /dev/null +++ b/data/people/peter-szilagyi/index.yaml @@ -0,0 +1,4 @@ +name: Péter Szilágyi +emails: + - peterke@gmail.com + - peter@ethereum.org \ No newline at end of file diff --git a/data/people/vitalik-buterin/index.yaml b/data/people/vitalik-buterin/index.yaml index 9f2abf5..f2f6a4d 100644 --- a/data/people/vitalik-buterin/index.yaml +++ b/data/people/vitalik-buterin/index.yaml @@ -1,3 +1,7 @@ name: Vitalik Buterin links: - twitter: https://twitter.com/VitalikButerin \ No newline at end of file + github: https://github.com/vbuterin + twitter: https://twitter.com/VitalikButerin +emails: + - vitalik.buterin@ethereum.org + - vitalik@ethereum.org \ No newline at end of file diff --git a/data/projects/eas/index.yaml b/data/projects/eas/index.yaml new file mode 100644 index 0000000..26413b9 --- /dev/null +++ b/data/projects/eas/index.yaml @@ -0,0 +1,5 @@ +name: Ethereum Attestation Service +abbreviations: + - EAS +links: + web: https://attest.sh/ \ No newline at end of file diff --git a/schema/person.yaml b/schema/person.yaml index 1de723f..ad0100d 100644 --- a/schema/person.yaml +++ b/schema/person.yaml @@ -29,4 +29,9 @@ properties: type: object additionalProperties: type: string - format: uri \ No newline at end of file + format: uri + emails: + type: array + items: + type: string + format: email \ No newline at end of file diff --git a/utils/extend.js b/utils/extend.js new file mode 100644 index 0000000..1750a97 --- /dev/null +++ b/utils/extend.js @@ -0,0 +1,44 @@ +import Engine from "./engine.js"; +import cheerio from "npm:cheerio@1.0.0-rc.12"; +import { ensureDir, exists } from "https://deno.land/std@0.173.0/fs/mod.ts"; + +const e = new Engine(); +await e.init(); + +const CACHE_DIR = "./.cache"; + +const tools = { + async loadHtmlUrl(url) { + await ensureDir(CACHE_DIR); + const hash = Array.from( + new Uint8Array( + await crypto.subtle.digest("SHA-256", (new TextEncoder()).encode(url)), + ), + ).map((b) => b.toString(16).padStart(2, "0")).join(""); + const cacheFn = `${CACHE_DIR}/${hash}`; + + if (await exists(cacheFn)) { + console.log(`Cache found! ${hash}`); + return cheerio.load(await Deno.readTextFile(cacheFn)); + } + + console.log(`Getting ${url}`); + const resp = await fetch(url, { + headers: { + "User-Agent": + "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/16.1 Safari/605.1.15", + }, + }); + const output = await resp.text(); + await Deno.writeTextFile(cacheFn, output); + return cheerio.load(output); + } +} + +for (const extId in e.config.extenders) { + console.log(`Running extender: ${extId}`) + const ext = await import(`./extenders/${extId}.js`) + await ext.process(e, tools) +} + +console.log(`Extending done`) \ No newline at end of file diff --git a/utils/extenders/eips.js b/utils/extenders/eips.js new file mode 100644 index 0000000..709ccac --- /dev/null +++ b/utils/extenders/eips.js @@ -0,0 +1,83 @@ +export async function process(db, _) { + const authors = {} + const $ = await _.loadHtmlUrl("https://eips.ethereum.org/all") + for (const el of $('table.eiptable tr').toArray()) { + const eipnum = $('td.eipnum a', el).text() + for (const a of $('td.author', el).text().split(', ')) { + if (!a) { + continue + } + if (!authors[a]) { + authors[a] = [] + } + authors[a].push(eipnum) + } + } + + const matrix = [] + + for (const a of Object.keys(authors)) { + const info = {} + + // name + const nameMatch = a.match(/^([^<^\()]+)/) + if (!nameMatch) { + console.log(`Bad name? ${a}`) + } + info.name = nameMatch[1].trim() + + // github handle + const ghMatch = a.match(/\(@([^\)]+)\)/) + if (ghMatch) { + info.github = ghMatch[1] + } + // email + const emailMatch = a.match(/<([^>]+)>/) + if (emailMatch) { + info.email = emailMatch[1] + } + //console.log(`${a} - ${JSON.stringify(info)}`) + + const dbFind = db.collections.people.find(p => { + if (info.github && p.index.links?.github?.toLowerCase() === `https://github.com/${info.github.toLowerCase()}`) { + return true + } + if (info.email && p.index.emails?.includes(info.email)) { + return true + } + }) + if (dbFind) { + let matrixItem = matrix.find(mi => mi.slug === dbFind.index.slug) + if (!matrixItem) { + matrixItem = { + slug: dbFind.index.slug, + info, + eips: [], + } + matrix.push(matrixItem) + } + matrixItem.eips = matrixItem.eips.concat(authors[a]).sort() + } else { + matrix.push({ + slug: null, + info, + eips: authors[a] + }) + } + //console.log(`${info.name} -> ${dbFind ? dbFind.index.slug : 'x'}`) + } + //console.log(matrix) + + // finishing, modify or create people + + for (const p of matrix) { + if (p.slug) { + console.log(`${p.info.name} => ${p.slug} (auto)`) + continue + } + const duplicates = [] + + console.log(`-----\n${p.info.name} (${JSON.stringify(p)})\n`) + prompt("Do you want to create new one?") + } +} \ No newline at end of file diff --git a/web/src/layouts/Layout.astro b/web/src/layouts/Layout.astro index d7cd3f4..0c55938 100644 --- a/web/src/layouts/Layout.astro +++ b/web/src/layouts/Layout.astro @@ -21,7 +21,7 @@ const bundle = await loadBundle();
{JSON.stringify(item, null, 2)}
+
+ Edit this item