Skip to content

Commit

Permalink
GitHub user pages at /user/github/{username}
Browse files Browse the repository at this point in the history
  • Loading branch information
hnasheralneam committed Jul 16, 2024
1 parent b41faa2 commit cb1bb77
Show file tree
Hide file tree
Showing 15 changed files with 442 additions and 344 deletions.
9 changes: 4 additions & 5 deletions app.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,18 +47,17 @@ app.get("/profile", (req, res) => {
if (!req.session.user) {
return res.render("pages/login", { client_id: process.env.GITHUB_CLIENT_ID });
}
console.log(req.session.user)
return res.render("pages/profile", { userData: req.session.user });
});

app.get("/user/github/:username", (req, res) => {
const username = req.params.username;
res.render("pages/user-profile", { username: username })
});

// Token fetching stuff
app.get("/token/:service", (req, res) => {
const service = req.params.service;
console.log(
service.toUpperCase() + "_TOKEN",
process.env[service.toUpperCase() + "_TOKEN"],
);
res.send(process.env[service.toUpperCase() + "_TOKEN"] || "No token found");
});

Expand Down
70 changes: 4 additions & 66 deletions public/pages/gh-username-search.ejs
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,14 @@
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="stylesheet" type="text/css" href="styles/tailwind.css">
<link rel="stylesheet" href="styles/profile-styles.css">
<link rel="stylesheet"
href="https://fonts.googleapis.com/css2?family=Material+Symbols+Rounded:opsz,wght,FILL,GRAD@20..48,100..700,0..1,-50..200" />
<link rel="icon" type="images/svg" href="images/logo.svg">
<link rel="stylesheet" type='text/css' href="https://cdn.jsdelivr.net/gh/devicons/devicon@latest/devicon.min.css">

<title>GitHub Username Search | FetchCV</title>
</head>

<body class="px-8 flex justify-center bg-zinc-50 dark:bg-zinc-900 dark:text-white">
<body class="h-[100vh] px-8 flex justify-center items-center bg-zinc-50 dark:bg-zinc-900 dark:text-white">
<div class="mb-20">
<!-- top bar -->
<div class="flex my-2">
Expand All @@ -27,73 +25,13 @@
<!-- User search (will be replaced when accounts are added) -->
<div
class="flex w-full justify-center items-center shadow-lg bg-zinc-100 dark:bg-zinc-800 border-[1px] border-zinc-300 dark:border-zinc-700 border-t-zinc-100 dark:border-t-zinc-600 rounded-md">
<input class="px-6 py-2 text-base bg-transparent w-[100%]" type="text" id="username"
placeholder="Enter your username">
<input class="px-6 py-2 text-base bg-transparent md:w-[400px] sm:w-[80vw]" type="text" id="username"
placeholder="Enter a GitHub username">
<span tabindex="0" class="material-symbols-rounded text-public mr-2"
onclick="newUsername()">person_search</span>
</div>
</div>
<!-- Error box - hidden by default -->
<div
class="error-box shadow-2xl py-4 px-8 my-2 border-[1px] border-zinc-300 dark:border-zinc-700 border-t-zinc-100 dark:border-t-zinc-600 rounded-md hidden bg-blue-800 bg-red-800 bg-green-800">
<h1 class="error-title text-2xl font-mono">Oh no! Token retriavl error</h1>
<h1 class="error-text font-mono">We could not fetch your data</h1>
</div>


<!-- this should be working -->
<div id="root"></div>


<!-- Profile Card -->
<div
class="shadow-2xl py-4 px-8 my-2 bg-zinc-100 dark:bg-zinc-800 border-[1px] border-zinc-300 dark:border-zinc-700 border-t-zinc-100 dark:border-t-zinc-600 rounded-md hidden user-info">
<div class="grid gap-6" style="grid-template-columns: 300px auto;">
<img
class="profile-picture w-[300px] shadow-2xl border-[1px] border-zinc-300 dark:border-zinc-700 border-t-zinc-100 dark:border-t-zinc-600 rounded-full"
alt="Profile Picture">
<div class="max-w-[45vw]">
<h1 class="profile-name text-3xl font-bold">Name</h1>
<h1 class="profile-handle text-xl dark:text-zinc-600 font-bold">handle</h1>
<div class="profile-langs py-2 align-top"></div>
<p class="profile-desc text-lg"></p>
<br>
<hr>
<br>
<div>
<p><span class="profile-repos"></span> repositories</p>
</div>
<br>
<hr>
<br>
<p><span class="profile-followers"></span> followers</p>
<p><span class="profile-following"></span> following</p>
<p><span class="profile-stars"></span> stars</p>
<p>location: <span class="profile-location"></span></p>
<p class="profile-email">Email</p>
<a class="profile-website text-theme underline">Website (ur/)</a><br>
<a class="profile-github text-theme underline">Github</a><br>
<br>
<div class="github-stats"></div>
</div>
</div>
</div>
<!-- Branding -->
<div
class="flex w-full py-4 justify-center items-center shadow-lg dark:bg-zinc-800 border-[1px] border-zinc-300 dark:border-zinc-700 border-t-zinc-100 dark:border-t-zinc-600 rounded-md">
<p>Created with <code class="text-theme">FetchCV</code></p>

</div>
</div>
</body>
<style>
p {
max-width: 700px;
}
</style>

<script src="scripts/main.js"></script>
<script src="scripts/github.js"></script>
<script src="scripts/gitlab.js"></script>

<script src="scripts/github-username-search.js"></script>
</html>
103 changes: 103 additions & 0 deletions public/pages/user-profile.ejs
Original file line number Diff line number Diff line change
@@ -0,0 +1,103 @@
<!DOCTYPE html>
<html lang="en">

<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="stylesheet" type="text/css" href="/styles/tailwind.css">
<link rel="stylesheet" href="/styles/profile-styles.css">
<link rel="stylesheet"
href="https://fonts.googleapis.com/css2?family=Material+Symbols+Rounded:opsz,wght,FILL,GRAD@20..48,100..700,0..1,-50..200" />
<link rel="icon" type="images/svg" href="/images/logo.svg">
<link rel="stylesheet" type='text/css' href="https://cdn.jsdelivr.net/gh/devicons/devicon@latest/devicon.min.css">

<title>My Profile | FetchCV</title>
</head>

<body class="px-8 flex justify-center bg-zinc-50 dark:bg-zinc-900 dark:text-white">
<div class="mb-20">
<!-- top bar -->
<div class="flex my-2">
<a href="/">
<div
class="inline-flex justify-center transition-all p-2 mr-2 shadow-lg bg-zinc-100 dark:bg-zinc-800 border-[1px] border-zinc-300 dark:border-zinc-700 border-t-zinc-100 dark:border-t-zinc-600 hover:bg-zinc-200 dark:hover:bg-zinc-700 rounded-md dark:text-white">
<span class="material-symbols-rounded text-public">home</span>
</div>
</a>
<!-- User search (will be replaced when accounts are added) -->
<div
class="flex w-full justify-center items-center shadow-lg bg-zinc-100 dark:bg-zinc-800 border-[1px] border-zinc-300 dark:border-zinc-700 border-t-zinc-100 dark:border-t-zinc-600 rounded-md">
<input class="px-6 py-2 text-base bg-transparent w-[100%]" type="text" id="username"
placeholder="Enter a GitHub username">
<span tabindex="0" class="material-symbols-rounded text-public mr-2"
onclick="newUsername()">person_search</span>
</div>
<script>
let usernameJSON = `<%- JSON.stringify(username) %>`;
let username = JSON.parse(usernameJSON);
</script>
</div>
<!-- Error box - hidden by default -->
<div
class="error-box shadow-2xl py-4 px-8 my-2 border-[1px] border-zinc-300 dark:border-zinc-700 border-t-zinc-100 dark:border-t-zinc-600 rounded-md hidden bg-blue-800 bg-red-800 bg-green-800">
<h1 class="error-title text-2xl font-mono">Oh no! Token retrival error</h1>
<h1 class="error-text font-mono">We could not fetch your data</h1>
</div>


<!-- this should be working -->
<div id="root"></div>


<!-- Profile Card -->
<div
class="shadow-2xl py-4 px-8 my-2 bg-zinc-100 dark:bg-zinc-800 border-[1px] border-zinc-300 dark:border-zinc-700 border-t-zinc-100 dark:border-t-zinc-600 rounded-md hidden user-info">
<div class="grid gap-6" style="grid-template-columns: 300px auto;">
<img
class="profile-picture w-[300px] shadow-2xl border-[1px] border-zinc-300 dark:border-zinc-700 border-t-zinc-100 dark:border-t-zinc-600 rounded-full"
alt="Profile Picture">
<div class="max-w-[45vw]">
<h1 class="profile-name text-3xl font-bold">Name</h1>
<h1 class="profile-handle text-xl dark:text-zinc-600 font-bold">handle</h1>
<div class="profile-langs py-2 align-top"></div>
<p class="profile-desc text-lg"></p>
<br>
<hr>
<br>
<div>
<p><span class="profile-repos"></span> repositories</p>
</div>
<br>
<hr>
<br>
<p><span class="profile-followers"></span> followers</p>
<p><span class="profile-following"></span> following</p>
<p><span class="profile-stars"></span> stars</p>
<p>location: <span class="profile-location"></span></p>
<p class="profile-email">Email</p>
<a class="profile-website text-theme underline">Website (ur/)</a><br>
<a class="profile-github text-theme underline">Github</a><br>
<br>
<div class="github-stats"></div>
</div>
</div>
</div>
<!-- Branding -->
<div
class="flex w-full py-4 justify-center items-center shadow-lg dark:bg-zinc-800 border-[1px] border-zinc-300 dark:border-zinc-700 border-t-zinc-100 dark:border-t-zinc-600 rounded-md">
<p>Created with <code class="text-theme">FetchCV</code></p>

</div>
</div>
</body>
<style>
p {
max-width: 700px;
}
</style>

<script src="/scripts/user-profile.js"></script>
<script src="/scripts/user-profile-github.js"></script>
<script src="/scripts/gitlab.js"></script>

</html>
21 changes: 21 additions & 0 deletions public/scripts-src/github-username-search.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
//===============================================
// Username search
//===============================================

function newUsername() {
let usernameElement = document.getElementById("username") as HTMLInputElement;
if (usernameElement) {
username = usernameElement.value;
window.location.href = window.location.origin + "/user/github/" + username;
}
}

const usernameInput = document.getElementById("username");
if (usernameInput) {
usernameInput.addEventListener("keydown", function (event) {
if (event.key == "Enter") {
newUsername();
}
});
}

File renamed without changes.
File renamed without changes.
File renamed without changes.
Loading

0 comments on commit cb1bb77

Please sign in to comment.