This commit is contained in:
FonduemangVI
2024-05-03 16:28:42 +10:00
parent 6a4eb3f87d
commit c645874c76
3 changed files with 39 additions and 514 deletions

View File

@@ -1,7 +1,13 @@
const axios = require('axios');
const fs = require('fs');
let contributors = [];
// Indentation function
function indentString(string, indentation) {
return string.split('\n').map(line => indentation + line).join('\n');
}
let contributors = '<table style="width: 100%;">\n';
let index = 0;
let page = 1;
function fetchPage() {
@@ -9,21 +15,38 @@ function fetchPage() {
.then((response) => {
if (response.data.length === 0) {
// No more contributors, write the file
fs.writeFileSync('CONTRIBUTORS.json', JSON.stringify(contributors, null, 2));
if (index % 5 !== 0) {
contributors += '</tr>\n'; // Close the row if it's not already closed
}
contributors += '</table>\n';
contributors = indentString(contributors, '');
fs.writeFileSync('CONTRIBUTORS.md', `## Contributors\n\n<!-- readme: contributors -start -->\n${contributors}\n<!-- readme: contributors -end -->\n`);
return;
}
response.data.forEach((user) => {
// Exclude bots and actions-user
if (user.type === 'Bot' || user.login.toLowerCase().includes('bot') || user.login === 'actions-user') return;
if (user.type === 'Bot' || user.login.toLowerCase().includes('bot') || user.login === 'actions-user' || user.login === 'mynameisbogdan') return;
const userJson = {
"title": user.login,
"image": user.avatar_url,
"url": user.html_url,
};
if (index % 5 === 0) {
contributors += '<tr>';
}
contributors.push(userJson);
const userHtml = `
<td align="center">
<img src="${user.avatar_url}&v=4" style="width: 50px; border-radius: 50%;" alt="${user.login}"/>
<br />
<b><a href="${user.html_url}">${user.login}</a></b>
</td>`;
contributors += indentString(userHtml, ' ');
if ((index + 1) % 5 === 0 || index === response.data.length - 1) {
contributors += '\n</tr>\n';
}
index++;
});
// Fetch the next page

View File

@@ -6,7 +6,7 @@ function indentString(string, indentation) {
return string.split('\n').map(line => indentation + line).join('\n');
}
let contributors = '<table style="width: 100%;">\n';
let contributors = '<div style="display: flex; flex-wrap: wrap;">\n';
let index = 0;
let page = 1;
@@ -15,10 +15,7 @@ function fetchPage() {
.then((response) => {
if (response.data.length === 0) {
// No more contributors, write the file
if (index % 5 !== 0) {
contributors += '</tr>\n'; // Close the row if it's not already closed
}
contributors += '</table>\n';
contributors += '</div>\n';
contributors = indentString(contributors, '');
fs.writeFileSync('CONTRIBUTORS.md', `## Contributors\n\n<!-- readme: contributors -start -->\n${contributors}\n<!-- readme: contributors -end -->\n`);
@@ -29,23 +26,15 @@ function fetchPage() {
// Exclude bots and actions-user
if (user.type === 'Bot' || user.login.toLowerCase().includes('bot') || user.login === 'actions-user' || user.login === 'mynameisbogdan') return;
if (index % 5 === 0) {
contributors += '<tr>';
}
const userHtml = `
<td align="center">
<img src="${user.avatar_url}&v=4" style="width: 50px; border-radius: 50%;" alt="${user.login}"/>
<br />
<b><a href="${user.html_url}">${user.login}</a></b>
</td>`;
<div style="flex: 1 1 20%; border: 1px solid black; box-sizing: border-box; padding: 10px; text-align: center;">
<img src="${user.avatar_url}&v=4" style="width: 50px; border-radius: 50%;" alt="${user.login}"/>
<br />
<b><a href="${user.html_url}">${user.login}</a></b>
</div>`;
contributors += indentString(userHtml, ' ');
if ((index + 1) % 5 === 0 || index === response.data.length - 1) {
contributors += '\n</tr>\n';
}
index++;
});