Browse Source

🎉 Initial commit

master
Tiana Lemesle 6 months ago
commit
6df618af87
  1. 9
      assets/destyle.css
  2. 11
      assets/halfmoon-variables.min.css
  3. 11
      assets/halfmoon.min.js
  4. 32
      index.css
  5. 48
      index.html
  6. 148
      index.js

9
assets/destyle.css

@ -0,0 +1,9 @@
/**
* Minified by jsDelivr using clean-css v4.2.3.
* Original file: /npm/destyle.css@2.0.2/destyle.css
*
* Do NOT use SRI with dynamically generated files! More information: https://www.jsdelivr.com/using-sri-with-dynamic-files
*/
/*! destyle.css v2.0.2 | MIT License | https://github.com/nicolas-cusan/destyle.css */
*,::after,::before{box-sizing:border-box;border-style:solid;border-width:0}html{line-height:1.15;-webkit-text-size-adjust:100%;-webkit-tap-highlight-color:transparent}body{margin:0}main{display:block}address,blockquote,dl,figure,form,iframe,p,pre,table{margin:0}h1,h2,h3,h4,h5,h6{font-size:inherit;line-height:inherit;font-weight:inherit;margin:0}ol,ul{margin:0;padding:0;list-style:none}dt{font-weight:700}dd{margin-left:0}hr{box-sizing:content-box;height:0;overflow:visible;border-top-width:1px;margin:0;clear:both;color:inherit}pre{font-family:monospace,monospace;font-size:inherit}address{font-style:inherit}a{background-color:transparent;text-decoration:none;color:inherit}abbr[title]{text-decoration:underline;text-decoration:underline dotted}b,strong{font-weight:bolder}code,kbd,samp{font-family:monospace,monospace;font-size:inherit}small{font-size:80%}sub,sup{font-size:75%;line-height:0;position:relative;vertical-align:baseline}sub{bottom:-.25em}sup{top:-.5em}embed,iframe,img,object{vertical-align:bottom}button,input,optgroup,select,textarea{-webkit-appearance:none;appearance:none;vertical-align:middle;color:inherit;font:inherit;background:0 0;padding:0;margin:0;outline:0;border-radius:0;text-align:inherit}[type=checkbox]{-webkit-appearance:checkbox;appearance:checkbox}[type=radio]{-webkit-appearance:radio;appearance:radio}button,input{overflow:visible}button,select{text-transform:none}[type=button],[type=reset],[type=submit],button{cursor:pointer;-webkit-appearance:none;appearance:none}[type=button][disabled],[type=reset][disabled],[type=submit][disabled],button[disabled]{cursor:default}[type=button]::-moz-focus-inner,[type=reset]::-moz-focus-inner,[type=submit]::-moz-focus-inner,button::-moz-focus-inner{border-style:none;padding:0}[type=button]:-moz-focusring,[type=reset]:-moz-focusring,[type=submit]:-moz-focusring,button:-moz-focusring{outline:1px dotted ButtonText}select::-ms-expand{display:none}option{padding:0}fieldset{margin:0;padding:0;min-width:0}legend{color:inherit;display:table;max-width:100%;padding:0;white-space:normal}progress{vertical-align:baseline}textarea{overflow:auto}[type=number]::-webkit-inner-spin-button,[type=number]::-webkit-outer-spin-button{height:auto}[type=search]{outline-offset:-2px}[type=search]::-webkit-search-decoration{-webkit-appearance:none}::-webkit-file-upload-button{-webkit-appearance:button;font:inherit}label[for]{cursor:pointer}details{display:block}summary{display:list-item}[contenteditable]{outline:0}table{border-collapse:collapse;border-spacing:0}caption{text-align:left}td,th{vertical-align:top;padding:0}th{text-align:left;font-weight:700}template{display:none}[hidden]{display:none}
/*# sourceMappingURL=/sm/fca8690f31e78977831fa1c4c9e69887e3d0803db8f0aa5e3262b970d3c177db.map */

11
assets/halfmoon-variables.min.css
File diff suppressed because it is too large
View File

11
assets/halfmoon.min.js
File diff suppressed because it is too large
View File

32
index.css

@ -0,0 +1,32 @@
#app {
padding: 1rem;
display: flex;
flex-direction: column;
}
#app__header__status,
#app__header__progress,
#app__header__search {
margin-bottom: 1rem;
}
#app__header__progress {
display: flex;
}
#app__header__progress__barContainer,
#app__header__search__inputContainer {
flex: 1;
}
#app__main {
flex: 1 1 auto;
display: flex;
flex-direction: column;
height: 0;
}
#app__main__resultsContainer {
flex: 1;
overflow: auto;
}

48
index.html

@ -0,0 +1,48 @@
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Active Forks</title>
<link rel="stylesheet" href="assets/destyle.css">
<link rel="stylesheet" href="assets/halfmoon-variables.min.css">
<link rel="stylesheet" href="index.css">
<script defer src="assets/halfmoon.min.js"></script>
<script defer src="index.js"></script>
</head>
<body id="app" class="with-custom-webkit-scrollbars" data-set-preferred-mode-onload="true">
<header id="app__header">
<p id="app__header__status">Status : <span id="app__header__status__value">idle</span></p>
<div id="app__header__progress" class="progress-group">
<span class="progress-group-label">Progress :</span>
<div id="app__header__progress__barContainer" class="progress">
<div id="app__header__progress__barContainer__bar" class="progress-bar progress-bar-animated" role="progressbar" style="width: 0;" aria-valuenow="0" aria-valuemin="0" aria-valuemax="100"></div>
</div>
<span id="app__header__progress__text" class="progress-group-label">000/000</span>
</div>
<fieldset id="app__header__search" class="form-inline">
<label id="app__header__search__inputContainer">Repository : &nbsp; <input id="app__header__search__inputContainer__input" class="form-control" type="text" autofocus></label>
<button id="app__header__search__button" class="btn btn-primary">Search</button>
</fieldset>
<label class="form-inline">Token : &nbsp; <input id="app__header__tokenInputContainer__input" class="form-control" type="password"></label>
</header>
<main id="app__main" style="display: none;">
<div id="app__main__resultsContainer">
<table class="table">
<thead>
<tr>
<th>Repository</th>
<th>Star count</th>
<th>Fork count</th>
<th>Default branch</th>
<th>Last default branch commit</th>
<th>Commit date</th>
<th>Commit author</th>
</tr>
</thead>
<tbody id="app__main__resultsContainer__results"></tbody>
</table>
</div>
</main>
</body>
</html>

148
index.js

@ -0,0 +1,148 @@
const numberToText = (number, intDigits, floatDigits) => Intl.NumberFormat(
'en-US',
{ minimumIntegerDigits: intDigits, minimumFractionDigits: floatDigits, maximumFractionDigits: floatDigits }
).format(number);
document.addEventListener('DOMContentLoaded', () => {
halfmoonOnDOMContentLoaded();
document.querySelector('#app__header__search__inputContainer__input').addEventListener('keydown', event => {
if(event.key.endsWith('Enter'))
document.querySelector('#app__header__search__button').click();
});
document.querySelector('#app__header__search__button').addEventListener('click', async () => {
document.querySelector('#app__header__search').setAttribute('disabled', '');
document.querySelector('#app__header__status__value').textContent = 'searching';
document.querySelector('#app__main').style.display = 'none';
document.querySelector('#app__main__resultsContainer__results').innerHTML = '';
const
token = localStorage.getItem('token'),
repository = document.querySelector('#app__header__search__inputContainer__input').value,
config = token ? {
headers: {
authorization: `token ${token}`
}
} : {},
{
html_url: repositoryLink,
default_branch: repositoryDefaultBranch,
stargazers_count: repositoryStarCount,
forks_count: repositoryForkCount,
size: repositorySize
} = await (await fetch(`https://api.github.com/repos/${repository}`, config)).json(),
[{
sha,
html_url: commitLink,
commit: {
author: {
name: commitAuthorName,
date: commitDate
},
message: commitMessage
},
author
}] = await (await fetch(`https://api.github.com/repos/${repository}/commits?per_page=1`, config)).json(),
{
login: commitAuthorLogin,
html_url: commitAuthorLink
} = author || {},
forks = [],
results = [{
isOriginalRepo: true,
repository,
repositoryLink,
repositoryDefaultBranch,
repositoryStarCount,
repositoryForkCount,
repositorySize,
commitId: sha.slice(0, 7),
commitLink,
commitDate: new Date(commitDate).valueOf(),
commitAuthor: commitAuthorLogin || commitAuthorName,
commitAuthorLink,
commitMessage
}];
{
let currentPage = 1, lastPageCount;
do {
const _forks = await (await fetch(
`https://api.github.com/repos/${repository}/forks?per_page=100&page=${currentPage++}`,
config
)).json();
lastPageCount = _forks.length;
forks.push(..._forks);
} while(lastPageCount);
}
let notFoundCount = 0;
for(const [index, {
full_name: repository,
html_url: repositoryLink,
default_branch: repositoryDefaultBranch,
stargazers_count: repositoryStarCount,
forks_count: repositoryForkCount,
size: repositorySize
}] of forks.entries()){
const res = await fetch(`https://api.github.com/repos/${repository}/commits?per_page=1`, config);
if(res.status === 200){
const
[{
sha,
html_url: commitLink,
commit: {
author: {
name: commitAuthorName,
date: commitDate
},
message: commitMessage
},
author
}] = await res.json(),
{
login: commitAuthorLogin,
html_url: commitAuthorLink
} = author || {};
results.push({
repository,
repositoryLink,
repositoryDefaultBranch,
repositoryStarCount,
repositoryForkCount,
repositorySize,
commitId: sha.slice(0, 7),
commitLink,
commitDate: new Date(commitDate).valueOf(),
commitAuthor: commitAuthorLogin || commitAuthorName,
commitAuthorLink,
commitMessage
});
}
else notFoundCount++;
const
progressBar = document.querySelector('#app__header__progress__barContainer__bar'),
progressPercent = (index + 1) / forks.length * 100;
progressBar.style.width = `${progressPercent}%`;
progressBar.setAttribute('aria-valuenow', progressPercent.toString());
document.querySelector('#app__header__progress__text').textContent = `${numberToText(index + 1 - notFoundCount, 3)}/${numberToText(forks.length - notFoundCount, 3)}`;
}
document.querySelector('#app__main').style.removeProperty('display');
document.querySelector('#app__main__resultsContainer__results').innerHTML = results.sort((a, b) => b.commitDate - a.commitDate).map(item => `
<tr>
<td><a href="${item.repositoryLink}" target="_blank">${item.repository}</a>${item.isOriginalRepo ? ' (original repo)' : ''}</td>
<td>${item.repositoryStarCount}</td>
<td>${item.repositoryForkCount}</td>
<td>${item.repositoryDefaultBranch}</td>
<td><a href="${item.commitLink}" target="_blank" title="${item.commitMessage}">${item.commitId}</a></td>
<td>${new Date(item.commitDate).toLocaleString()}</td>
<td>${item.commitAuthorLink ? `<a href="${item.commitAuthorLink}" target="_blank">${item.commitAuthor}</a>` : item.commitAuthor}</td>
</tr>
`).join('');
document.querySelector('#app__header__search').removeAttribute('disabled');
document.querySelector('#app__header__status__value').textContent = 'idle';
});
document.querySelector('#app__header__tokenInputContainer__input').value = localStorage.getItem('token') || null;
document.querySelector('#app__header__tokenInputContainer__input').addEventListener('input', () =>
localStorage.setItem('token', document.querySelector('#app__header__tokenInputContainer__input').value));
});