Archived
1
0

Added small git history

This commit is contained in:
2020-01-09 22:27:55 +01:00
parent d8763fa455
commit ad4c8d4999
3 changed files with 57 additions and 0 deletions

1
gatsby-browser.js Normal file
View File

@@ -0,0 +1 @@
import "./src/styles/global.css"

53
src/pages/history.js Normal file
View File

@@ -0,0 +1,53 @@
import React from "react"
import Header from "../components/header"
const GIT_NAME = "creyD"
const GIT_REPO = "urban_website"
const GIT_URL =
"https://api.github.com/repos/" + GIT_NAME + "/" + GIT_REPO + "/events"
const GIT_COMMIT_URL =
"https://github.com/" + GIT_NAME + "/" + GIT_REPO + "/commit/"
// Adds Git History to the site
function addGitHistory(data) {
for (var push in data) {
for (var commit in data[push]["payload"]["commits"]) {
var new_li = document.createElement("li")
var url = GIT_COMMIT_URL + data[push]["payload"]["commits"][commit].sha
new_li.innerHTML =
data[push]["payload"]["commits"][commit].author.name +
" committed " +
getDate(data[push].created_at) +
": " +
data[push]["payload"]["commits"][commit].message +
" <a href=" +
url +
" target='_blanc'>(Link)</a>"
document.getElementById("log").appendChild(new_li)
}
}
}
// Send HTTP request to the GitHub API to get information about this repo
const Http = new XMLHttpRequest()
Http.open("GET", GIT_URL)
Http.send()
// If the API responds call the addGitHistory function
Http.onreadystatechange = function() {
if (this.readyState === 4 && this.status === 200) {
addGitHistory(JSON.parse(Http.responseText))
}
}
export default () => (
<div>
<Header headline="git log" />
<p>
You can see the full commit history{" "}
<a href="https://github.com/creyD/urban_website/commits/master">here</a>.
</p>
<ul id="log"></ul>
</div>
)

3
src/styles/global.css Normal file
View File

@@ -0,0 +1,3 @@
html {
background-color: lightgrey;
}