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", font-family: source-code-pro, Menlo, Monaco, Consolas, "Courier New",
monospace; monospace;
} }
#root {
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
}
</style> </style>
</head> </head>
<body> <body>

View File

@ -25,11 +25,11 @@ const [repo, sha, path] = getParams();
const root = document.getElementById("root"); const root = document.getElementById("root");
if (!repo) { if (!repo) {
// show docs // 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 { } else {
// show loading // 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) getHistory(repo, sha, path)
.then(commits => { .then(commits => {
@ -37,11 +37,11 @@ if (!repo) {
}) })
.catch(error => { .catch(error => {
if (error.status === 403) { if (error.status === 403) {
root.innerText = root.innerHTML =
"GitHub API rate limit exceeded for your IP (60 requests per hour). I need to add authentication."; "<p>GitHub API rate limit exceeded for your IP (60 requests per hour).</p><p>I need to add authentication.</p>";
} else { } else {
console.error(error); console.error(error);
root.innerText = `Unexpected error. Check the console.`; root.innerHTML = `<p>Unexpected error. Check the console.</p>`;
} }
}); });
} }