From 5223d7c38c5f956b205fd949818bb00d77bda22e Mon Sep 17 00:00:00 2001 From: Hamza Nasher-Alneam Date: Fri, 23 May 2025 03:09:22 -0400 Subject: [PATCH] Add friends links, add recent github activity and stats, add padding to bottom to show footer --- index.html | 34 ++++++++- scripts/github-activity.js | 112 +++++++++++++++++++++++++++ styles/home.css | 151 ++++++++++++++++++++++++++++--------- styles/styles.css | 21 +++--- 4 files changed, 268 insertions(+), 50 deletions(-) create mode 100644 scripts/github-activity.js diff --git a/index.html b/index.html index f5f58a6..1c3da20 100644 --- a/index.html +++ b/index.html @@ -23,6 +23,7 @@

About me

When not doing student things, I enjoy writing unoptimized JavaScript code and messing around with Linux on desktop and server. Over the summer, I plan on working on projects, connecting with people, and getting employed.

+


@@ -65,7 +66,37 @@
-

+
+
+

Friends

+
+
+

Urdons

+ Website + GitHub +
+
+

Sai

+ GitHub +
+
+

Kai

+ GitHub +
+
+

Raiyan Zaman

+ Website + GitHub +
+
+
+
+
+

Recent GitHub Activity

+
+ +
+


@@ -78,4 +109,5 @@ + diff --git a/scripts/github-activity.js b/scripts/github-activity.js new file mode 100644 index 0000000..49b4859 --- /dev/null +++ b/scripts/github-activity.js @@ -0,0 +1,112 @@ +let statsElement = document.querySelector(".github-actions"); + +let userData; +let userEvents; + +getUserInfo(); +getEvents(); + +async function getUserInfo() { + try { + const response = await fetch(`https://api.github.com/users/hnasheralneam`); + if (response.ok) { + userData = await response.json(); + showData(); + } + else console.error("Failed to fetch user data. Status:", response.status, response); + } + catch (error) { console.error("Failed to request user data. Error - ", error); } +} +async function getEvents() { + try { + const response = await fetch(`https://api.github.com/users/hnasheralneam/events`); + if (response.ok) { + userEvents = await response.json(); + showEvents(); + } + else console.error("Failed to fetch user data. Status:", response.status, response); + } + catch (error) { console.error("Failed to request user data. Error - ", error); } +} + +function showData() { + document.querySelector(".github-stats").innerHTML = "GitHub stats: " + userData.followers + " followers - " + userData.following + " following - " + userData.public_repos + " repositories "; +} +function showEvents() { + const eventsToShow = userEvents.slice(0, 3); + renderEvents(eventsToShow); +} +function showAllActions() { + renderEvents(userEvents); +} + +function renderEvents(eventsToDisplay) { + let eventsHtml = '
'; + eventsToDisplay.forEach(event => { + if (event) { // Ensure event is not null/undefined + eventsHtml += showAction(event); + } + }); + eventsHtml += '
'; + statsElement.innerHTML = eventsHtml; +} + +function showAction(action) { + const type = action.type.replace("Event", ""); + const repoName = action.repo.name; + const repoUrl = `https://github.com/${repoName}`; + const eventTime = new Date(action.created_at); + let details = `
Repository:
${repoName}
`; + + switch (type) { + case "Issues": + details += `
Action:
${action.payload.action}
`; + details += `
Title:
${action.payload.issue.title}
`; + details += `
Issue:
#${action.payload.issue.number}
`; + break; + case "IssueComment": + details += `
Action:
${action.payload.action} comment
`; + if (action.payload.issue) { + details += `
On Issue:
#${action.payload.issue.number} (${action.payload.issue.title})
`; + } + details += `
Comment:
${action.payload.comment.body.substring(0, 150)}${action.payload.comment.body.length > 150 ? '...' : ''}
`; + break; + case "PullRequest": + details += `
Action:
${action.payload.action}
`; + details += `
Pull Request:
#${action.payload.pull_request.number}
`; + details += `
Title:
${action.payload.pull_request.title}
`; + break; + case "Create": + details += `
Type:
Created ${action.payload.ref_type}
`; + if (action.payload.ref) { + details += `
Name:
${action.payload.ref}
`; + } + break; + case "Push": + details += `
Branch:
${action.payload.ref.replace("refs/heads/", "")}
`; + details += `
Commits:
${action.payload.commits.length}
`; + // Optionally list first few commit messages + if (action.payload.commits && action.payload.commits.length > 0) { + details += `
Recent Commit:
${action.payload.commits[0].message.split('\n')[0]}
`; + } + break; + case "Watch": + details += `
Action:
${action.payload.action} (starred)
`; + break; + case "Fork": + details += `
Forked To:
${action.payload.forkee.full_name}
`; + break; + default: + details += `
Details:
Unhandled event type.
`; + } + + return ` +
+

+ ${type} + +

+
${details}
+

+
`; +} \ No newline at end of file diff --git a/styles/home.css b/styles/home.css index 537ec36..bc4a124 100644 --- a/styles/home.css +++ b/styles/home.css @@ -84,43 +84,6 @@ a { color: var(--theme-color); } -.thoughts-preview a { - color: initial; - text-decoration: initial; -} - -.thoughts-bit p { - padding: 0; - margin: 0; -} - -.thoughts-bit { - padding: 1rem; - border-radius: .5em; - margin: .4rem 1rem; - border: solid transparent .2rem; - transition: .25s; -} - -.thoughts-bit:hover { - background-color: #aaaaaa20; - border-color: var(--theme-color); -} - -.thoughts-bit:hover h4 { - text-decoration: underline; -} - -.thoughts { - margin: 2rem 2rem 0 0; - float: right; - color: #888; - text-decoration: none; - font-weight: 700; - font-size: 1.5rem; - font-family: monospace; -} - .funsies { padding: .5rem 2rem; } @@ -191,4 +154,118 @@ a { background-color: #77777720; } } +} + +/* People */ +.people { + margin: 0 2rem; +} +.person { + display: inline-block; + border: solid .15rem; + border-color: #444; + background-color: #2a2a2a; + width: 12rem; + border-radius: .5rem; + margin: .4rem .1rem; + padding: .6rem .7rem .8rem .7rem; + text-align: center; +} +.person h4 { + margin-bottom: .3rem; +} +.person a { + margin: .4rem .1rem; + padding: .2rem .4rem; + background-color: var(--theme-color); + color: #fff; + text-decoration: none; + border-radius: .2rem; + transition: .2s; + text-shadow: 0 0 .05rem #000; +} +.person a:hover { + background-color: #fff; + color: var(--theme-color); + text-shadow: 0 0 .05rem #000; +} + + +/* Recent github actions */ +.github-actions { + font-size: 0.9em; + line-height: 1.6; + margin: 1rem 2rem; +} + +.github-event-card { + border: .15rem solid #ddd; + border-radius: .5rem; + padding: 5px 15px; + margin-bottom: 15px; + background-color: #f9f9f9; +} + +.github-event-card .event-type { + margin: 5px 0; + font-size: 1.3em; +} + +.github-event-card .event-details dt { + font-weight: bold; + color: #333; + float: left; + width: 120px; + clear: left; +} + +.github-event-card .event-details dd { + margin-left: 130px; + color: #555; +} + +.github-event-card .event-comment-body { + white-space: pre-wrap; + word-break: break-word; + font-size: 0.9em; + padding: 5px; + max-height: 100px; + overflow-y: auto; +} + +.github-event-card .event-time { + font-size: 0.8em; + color: #777; + margin-left: 10px; + text-align: right; +} + +@media only screen and (max-width: 700px) { + .github-event-card .event-details dt { + width: 80px; + text-align: right; + } + + .github-event-card .event-details dd { + margin-left: 90px; + } +} + +@media (prefers-color-scheme: dark) { + .github-event-card { + border-color: #444; + background-color: #2a2a2a; + } + + .github-event-card .event-details dt { + color: #ccc; + } + + .github-event-card .event-details dd { + color: #bbb; + } + + .github-event-card .event-time { + color: #777; + } } \ No newline at end of file diff --git a/styles/styles.css b/styles/styles.css index 77483bd..f675bc8 100644 --- a/styles/styles.css +++ b/styles/styles.css @@ -65,18 +65,6 @@ a { color: #bbb; } -@media only screen and (max-width: 750px) { - .footer { - grid-template-columns: auto; - } -} - -@media (prefers-color-scheme: dark) { - .footer { - background-color: #000; - } -} - @@ -151,6 +139,11 @@ a { margin: auto 1rem; transform: scale(1.5); } + + .footer { + grid-template-columns: auto; + padding: 3rem 1rem 6rem 1rem; + } } @media (prefers-color-scheme: dark) { @@ -162,4 +155,8 @@ a { .menu .item img { filter: none; } + + .footer { + background-color: #000; + } } \ No newline at end of file