mirror of
https://github.com/web3privacy/web
synced 2024-10-15 18:26:27 +02:00
utils: deno fmt
This commit is contained in:
parent
2884a56045
commit
0cbbddd561
5 changed files with 106 additions and 89 deletions
|
@ -1,23 +1,28 @@
|
|||
import { parseFeed } from "https://deno.land/x/rss/mod.ts";
|
||||
import * as cheerio from "https://esm.sh/cheerio@1.0.0-rc.12";
|
||||
|
||||
const resp = await fetch("https://mirror.xyz/0x0f1F3DAf416B74DB3DE55Eb4D7513a80F4841073/feed/atom")
|
||||
const xml = await resp.text()
|
||||
const feed = await parseFeed(xml)
|
||||
const resp = await fetch(
|
||||
"https://mirror.xyz/0x0f1F3DAf416B74DB3DE55Eb4D7513a80F4841073/feed/atom",
|
||||
);
|
||||
const xml = await resp.text();
|
||||
const feed = await parseFeed(xml);
|
||||
|
||||
const articles = []
|
||||
const articles = [];
|
||||
for (const entry of feed.entries) {
|
||||
//console.log(entry)
|
||||
//console.log(entry)
|
||||
|
||||
const $ = cheerio.load(entry.content.value)
|
||||
articles.push({
|
||||
url: entry.id,
|
||||
title: entry.title.value,
|
||||
img: $("img").attr("src"),
|
||||
date: entry.updated,
|
||||
})
|
||||
const $ = cheerio.load(entry.content.value);
|
||||
articles.push({
|
||||
url: entry.id,
|
||||
title: entry.title.value,
|
||||
img: $("img").attr("src"),
|
||||
date: entry.updated,
|
||||
});
|
||||
}
|
||||
|
||||
//console.log(articles)
|
||||
await Deno.writeTextFile("./src/articles.json", JSON.stringify(articles, null, 2))
|
||||
console.log(`File ./src/articles.json saved`)
|
||||
await Deno.writeTextFile(
|
||||
"./src/articles.json",
|
||||
JSON.stringify(articles, null, 2),
|
||||
);
|
||||
console.log(`File ./src/articles.json saved`);
|
||||
|
|
|
@ -1,61 +1,65 @@
|
|||
import "https://deno.land/std@0.206.0/dotenv/load.ts";
|
||||
|
||||
const contributorRepos = [
|
||||
// main repos
|
||||
"web3privacy/web3privacy",
|
||||
"web3privacy/data",
|
||||
"web3privacy/docs",
|
||||
"web3privacy/web",
|
||||
"web3privacy/brand",
|
||||
|
||||
// main repos
|
||||
"web3privacy/web3privacy",
|
||||
"web3privacy/data",
|
||||
"web3privacy/docs",
|
||||
"web3privacy/web",
|
||||
"web3privacy/brand",
|
||||
// events workgroup
|
||||
"web3privacy/events",
|
||||
|
||||
// events workgroup
|
||||
"web3privacy/events",
|
||||
// explorer
|
||||
"web3privacy/explorer",
|
||||
"web3privacy/explorer-data",
|
||||
"web3privacy/explorer-app",
|
||||
|
||||
// explorer
|
||||
"web3privacy/explorer",
|
||||
"web3privacy/explorer-data",
|
||||
"web3privacy/explorer-app",
|
||||
// old - deprecated
|
||||
"web3privacy/w3ps1",
|
||||
"web3privacy/grants",
|
||||
"web3privacy/old-website",
|
||||
"web3privacy/web3privacy-app-old",
|
||||
];
|
||||
|
||||
// old - deprecated
|
||||
"web3privacy/w3ps1",
|
||||
"web3privacy/grants",
|
||||
"web3privacy/old-website",
|
||||
"web3privacy/web3privacy-app-old",
|
||||
|
||||
]
|
||||
|
||||
function isBlacklisted (login) {
|
||||
if (login.match(/\[bot\]$/)) {
|
||||
return true;
|
||||
}
|
||||
function isBlacklisted(login) {
|
||||
if (login.match(/\[bot\]$/)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
async function getContributors () {
|
||||
const output = [];
|
||||
for (const cr of contributorRepos) {
|
||||
const response = await fetch(`https://api.github.com/repos/${cr}/contributors`, {
|
||||
//headers: {
|
||||
// "Authorization": `Token ${Deno.env.get('GITHUB_TOKEN')}`
|
||||
//}
|
||||
});
|
||||
const arr = await response.json();
|
||||
for (const item of arr) {
|
||||
if (isBlacklisted(item.login)) {
|
||||
continue;
|
||||
}
|
||||
async function getContributors() {
|
||||
const output = [];
|
||||
for (const cr of contributorRepos) {
|
||||
const response = await fetch(
|
||||
`https://api.github.com/repos/${cr}/contributors`,
|
||||
{
|
||||
//headers: {
|
||||
// "Authorization": `Token ${Deno.env.get('GITHUB_TOKEN')}`
|
||||
//}
|
||||
},
|
||||
);
|
||||
const arr = await response.json();
|
||||
for (const item of arr) {
|
||||
if (isBlacklisted(item.login)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
const found = output.find(i => i.login === item.login)
|
||||
if (!found) {
|
||||
output.push(item)
|
||||
} else {
|
||||
found.contributions += item.contributions
|
||||
}
|
||||
}
|
||||
}
|
||||
return output.sort((x, y) => y.contributions > x.contributions ? 1 : -1);
|
||||
const found = output.find((i) => i.login === item.login);
|
||||
if (!found) {
|
||||
output.push(item);
|
||||
} else {
|
||||
found.contributions += item.contributions;
|
||||
}
|
||||
}
|
||||
}
|
||||
return output.sort((x, y) => y.contributions > x.contributions ? 1 : -1);
|
||||
}
|
||||
|
||||
const contributors = await getContributors()
|
||||
await Deno.writeTextFile("./src/contributors.json", JSON.stringify(contributors, null, 2))
|
||||
console.log(`File ./src/contributors.json saved`)
|
||||
const contributors = await getContributors();
|
||||
await Deno.writeTextFile(
|
||||
"./src/contributors.json",
|
||||
JSON.stringify(contributors, null, 2),
|
||||
);
|
||||
console.log(`File ./src/contributors.json saved`);
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
const response = await fetch("https://data.web3privacy.info/")
|
||||
const data = await response.json()
|
||||
await Deno.writeTextFile("./src/core.json", JSON.stringify(data, null, 2))
|
||||
console.log(`File ./src/core.json saved`)
|
||||
const response = await fetch("https://data.web3privacy.info/");
|
||||
const data = await response.json();
|
||||
await Deno.writeTextFile("./src/core.json", JSON.stringify(data, null, 2));
|
||||
console.log(`File ./src/core.json saved`);
|
||||
|
|
|
@ -1,15 +1,18 @@
|
|||
|
||||
|
||||
const resp = await fetch("https://explorer-data.web3privacy.info/");
|
||||
const data = await resp.json();
|
||||
|
||||
const respContribs = await fetch(`https://api.github.com/repos/web3privacy/explorer-data/contributors`)
|
||||
const respContribs = await fetch(
|
||||
`https://api.github.com/repos/web3privacy/explorer-data/contributors`,
|
||||
);
|
||||
const respContribsData = await respContribs.json();
|
||||
|
||||
const explorer = {
|
||||
projects: data.projects.length,
|
||||
contributors: respContribsData.length,
|
||||
}
|
||||
projects: data.projects.length,
|
||||
contributors: respContribsData.length,
|
||||
};
|
||||
|
||||
await Deno.writeTextFile("./src/explorer.json", JSON.stringify(explorer, null, 2))
|
||||
console.log(`File ./src/explorer.json saved`)
|
||||
await Deno.writeTextFile(
|
||||
"./src/explorer.json",
|
||||
JSON.stringify(explorer, null, 2),
|
||||
);
|
||||
console.log(`File ./src/explorer.json saved`);
|
||||
|
|
|
@ -1,23 +1,28 @@
|
|||
import { parseFeed } from "https://deno.land/x/rss/mod.ts";
|
||||
import * as cheerio from "https://esm.sh/cheerio@1.0.0-rc.12";
|
||||
|
||||
const resp = await fetch("https://www.youtube.com/feeds/videos.xml?channel_id=UCaO_vLpj164um5maEsCuEbw")
|
||||
const xml = await resp.text()
|
||||
const feed = await parseFeed(xml)
|
||||
const resp = await fetch(
|
||||
"https://www.youtube.com/feeds/videos.xml?channel_id=UCaO_vLpj164um5maEsCuEbw",
|
||||
);
|
||||
const xml = await resp.text();
|
||||
const feed = await parseFeed(xml);
|
||||
|
||||
const talks = []
|
||||
const talks = [];
|
||||
for (const entry of feed.entries) {
|
||||
console.log(entry)
|
||||
console.log(entry);
|
||||
|
||||
//const $ = cheerio.load(entry.content.value)
|
||||
talks.push({
|
||||
url: entry.links[0].href,
|
||||
title: entry.title.value,
|
||||
img: entry["media:group"]["media:thumbnail"].url.replace("hqdefault", "maxresdefault"),
|
||||
date: entry.published,
|
||||
})
|
||||
//const $ = cheerio.load(entry.content.value)
|
||||
talks.push({
|
||||
url: entry.links[0].href,
|
||||
title: entry.title.value,
|
||||
img: entry["media:group"]["media:thumbnail"].url.replace(
|
||||
"hqdefault",
|
||||
"maxresdefault",
|
||||
),
|
||||
date: entry.published,
|
||||
});
|
||||
}
|
||||
|
||||
//console.log(articles)
|
||||
await Deno.writeTextFile("./src/talks.json", JSON.stringify(talks, null, 2))
|
||||
console.log(`File ./src/talks.json saved`)
|
||||
await Deno.writeTextFile("./src/talks.json", JSON.stringify(talks, null, 2));
|
||||
console.log(`File ./src/talks.json saved`);
|
||||
|
|
Loading…
Reference in a new issue