This commit is contained in:
Rodrigo Pombo 2019-02-04 22:22:48 -03:00
parent 25fe89e04d
commit 71e9263b5d
2 changed files with 12 additions and 5 deletions

View File

@ -40,6 +40,13 @@
font-family: source-code-pro, Menlo, Monaco, Consolas, "Courier New",
monospace;
}
#root {
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
}
</style>
</head>
<body>

View File

@ -25,11 +25,11 @@ const [repo, sha, path] = getParams();
const root = document.getElementById("root");
if (!repo) {
// show docs
root.innerText = `URL should be something like https://github-history.netlify.com/user/repo/commits/master/path/to/file.js `;
root.innerHTML = `<p>URL should be something like https://github-history.netlify.com/user/repo/commits/master/path/to/file.js</p>`;
} else {
// show loading
root.innerHTML = `Loading <strong>${repo}</strong> <strong>${path}</strong> history...`;
root.innerHTML = `<p>Loading <strong>${repo}</strong> <strong>${path}</strong> history...</p>`;
getHistory(repo, sha, path)
.then(commits => {
@ -37,11 +37,11 @@ if (!repo) {
})
.catch(error => {
if (error.status === 403) {
root.innerText =
"GitHub API rate limit exceeded for your IP (60 requests per hour). I need to add authentication.";
root.innerHTML =
"<p>GitHub API rate limit exceeded for your IP (60 requests per hour).</p><p>I need to add authentication.</p>";
} else {
console.error(error);
root.innerText = `Unexpected error. Check the console.`;
root.innerHTML = `<p>Unexpected error. Check the console.</p>`;
}
});
}