1
0
mirror of https://github.com/laurent22/joplin.git synced 2024-12-24 10:27:10 +02:00

Doc: Update sponsors

This commit is contained in:
Laurent Cozic 2023-03-12 12:38:08 +00:00
parent 75ad454971
commit bcb578c933
3 changed files with 59 additions and 83 deletions

View File

@ -1,120 +1,61 @@
{ {
"github": [ "github": [
{ {
"name": "nicholashead", "name": "tateisu"
"id": "1168659"
}, },
{ {
"name": "avanderberg", "name": "matmoly"
"id": "215668"
}, },
{ {
"name": "fbloise", "name": "KentBrockman"
"id": "1439535"
}, },
{ {
"name": "thomasbroussard", "name": "CyberXZT"
"id": "15859362"
}, },
{ {
"name": "dbrandonjohnson", "name": "avanderberg"
"id": "1307332"
}, },
{ {
"name": "c-nagy", "name": "dbrandonjohnson"
"id": "3061769"
}, },
{ {
"name": "mcejp", "name": "mcejp"
"id": "29300939"
}, },
{ {
"name": "joesfer", "name": "chr15m"
"id": "1248504"
}, },
{ {
"name": "chr15m", "name": "maxtruxa"
"id": "67130"
}, },
{ {
"name": "piccobit", "name": "konishi-t"
"id": "5782817"
}, },
{ {
"name": "chrootlogin", "name": "iamwillbar"
"id": "4862947"
}, },
{ {
"name": "maxtruxa", "name": "marcdw1289"
"id": "1788010"
}, },
{ {
"name": "Jesssullivan", "name": "kianenigma"
"id": "37297218"
}, },
{ {
"name": "cabottech", "name": "taskcruncher"
"id": "70780798"
}, },
{ {
"name": "h4sh5", "name": "fourstepper"
"id": "38898566"
}, },
{ {
"name": "ravenscroftj", "name": "sif"
"id": "47742"
}, },
{ {
"name": "thismarty", "name": "saarantras"
"id": "73081837"
}, },
{ {
"name": "konishi-t", "name": "Hegghammer"
"id": "24908652"
}, },
{ {
"name": "clmntsl", "name": "jknowles"
"id": "82579431"
},
{
"name": "cuongtransc",
"id": "808091"
},
{
"name": "iamwillbar",
"id": "3266447"
},
{
"name": "marcdw1289",
"id": "42319182"
},
{
"name": "kianenigma",
"id": "5588131"
},
{
"name": "taskcruncher",
"id": "765564"
},
{
"name": "fourstepper",
"id": "49439044"
},
{
"name": "Polymathic-Company",
"id": "77214738"
},
{
"name": "sif",
"id": "327998"
},
{
"name": "skyrunner15",
"id": "54626606"
},
{
"name": "jknowles",
"id": "1310474"
} }
], ],
"orgs": [ "orgs": [

View File

@ -1,12 +1,44 @@
import { readFile } from 'fs-extra'; import { readFile } from 'fs-extra';
import { insertContentIntoFile, rootDir } from './tool-utils'; import { insertContentIntoFile, rootDir } from './tool-utils';
import markdownUtils, { MarkdownTableHeader, MarkdownTableJustify, MarkdownTableRow } from '@joplin/lib/markdownUtils'; import markdownUtils, { MarkdownTableHeader, MarkdownTableJustify, MarkdownTableRow } from '@joplin/lib/markdownUtils';
import { GithubSponsor, OrgSponsor, Sponsors } from './website/utils/types'; import { GithubSponsor, GithubUser, OrgSponsor, Sponsors } from './website/utils/types';
import fetch from 'node-fetch';
const { escapeHtml } = require('@joplin/lib/string-utils'); const { escapeHtml } = require('@joplin/lib/string-utils');
const readmePath = `${rootDir}/README.md`; const readmePath = `${rootDir}/README.md`;
const sponsorsPath = `${rootDir}/packages/tools/sponsors.json`; const sponsorsPath = `${rootDir}/packages/tools/sponsors.json`;
const sleep = (ms: number) => {
return new Promise(resolve => setTimeout(resolve, ms));
};
const fetchWithRetry = async (url: string, opts: any = null) => {
if (!opts) opts = {};
let retry = opts && opts.retry || 3;
while (retry > 0) {
try {
return fetch(url, opts);
} catch (e) {
if (opts && opts.callback) {
opts.callback(retry);
}
retry = retry - 1;
if (retry === 0) {
throw e;
}
if (opts && opts.pause) {
if (opts && !opts.silent) console.log('pausing..');
await sleep(opts.pause);
if (opts && !opts.silent) console.log('done pausing...');
}
}
}
return null;
};
async function createGitHubSponsorTable(sponsors: GithubSponsor[]): Promise<string> { async function createGitHubSponsorTable(sponsors: GithubSponsor[]): Promise<string> {
sponsors = sponsors.slice(); sponsors = sponsors.slice();
@ -31,14 +63,16 @@ async function createGitHubSponsorTable(sponsors: GithubSponsor[]): Promise<stri
let sponsorIndex = 0; let sponsorIndex = 0;
for (let rowIndex = 0; rowIndex < 9999; rowIndex++) { for (let rowIndex = 0; rowIndex < 9999; rowIndex++) {
let sponsor = null; let sponsor: GithubSponsor = null;
const row: MarkdownTableRow = {}; const row: MarkdownTableRow = {};
for (let colIndex = 0; colIndex < sponsorsPerRow; colIndex++) { for (let colIndex = 0; colIndex < sponsorsPerRow; colIndex++) {
sponsor = sponsors[sponsorIndex]; sponsor = sponsors[sponsorIndex];
sponsorIndex++; sponsorIndex++;
if (!sponsor) break; if (!sponsor) break;
row[`col${colIndex}`] = `<img width="50" src="https://avatars2.githubusercontent.com/u/${sponsor.id}?s=96&v=4"/></br>[${sponsor.name}](https://github.com/${sponsor.name})`; const userResponse = await fetchWithRetry(`https://api.github.com/users/${sponsor.name}`);
const user = await userResponse.json() as GithubUser;
row[`col${colIndex}`] = `<img width="50" src="https://avatars2.githubusercontent.com/u/${user.id}?s=96&v=4"/></br>[${sponsor.name}](https://github.com/${sponsor.name})`;
} }
if (Object.keys(row)) rows.push(row); if (Object.keys(row)) rows.push(row);
@ -50,8 +84,6 @@ async function createGitHubSponsorTable(sponsors: GithubSponsor[]): Promise<stri
} }
async function createOrgSponsorTable(sponsors: OrgSponsor[]): Promise<string> { async function createOrgSponsorTable(sponsors: OrgSponsor[]): Promise<string> {
// sponsors = ArrayUtils.shuffle(sponsors);
const output: string[] = []; const output: string[] = [];
for (const sponsor of sponsors) { for (const sponsor of sponsors) {

View File

@ -8,6 +8,9 @@ export enum Env {
export interface GithubSponsor { export interface GithubSponsor {
name: string; name: string;
}
export interface GithubUser {
id: string; id: string;
} }