Skip to content

Commit

Permalink
Add avatar url
Browse files Browse the repository at this point in the history
  • Loading branch information
slhmy committed Jul 29, 2024
1 parent f90582a commit 532ecbb
Show file tree
Hide file tree
Showing 5 changed files with 64 additions and 4 deletions.
41 changes: 41 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
"axios": "^1.3.4",
"framer-motion": "^11.0.24",
"i18next": "^23.5.1",
"md5": "^2.3.0",
"monaco-editor": "^0.39.0",
"msw": "^2.1.7",
"react": "^18.2.0",
Expand All @@ -32,6 +33,7 @@
"rehype-katex": "^6.0.3",
"rehype-mathjax": "^6.0.0",
"remark-math": "^5.1.1",
"ts-md5": "^1.3.1",
"typescript": "^5.3.3",
"uuid": "^9.0.1",
"web-vitals": "^2.1.4"
Expand Down
17 changes: 14 additions & 3 deletions src/components/judge/JudgeTable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,12 @@ import { joinClasses } from "../../utils/common";
import { JudgeServiceModel } from "../../typings/judge";
import BrandCPPIcon from "../icons/tabler/BrandCPPIcon";
import BrandPythonIcon from "../icons/tabler/BrandPythonIcon";
import { getGravatarUrl } from "@/utils/avatar_url";

const columns = [
{ name: "User", uid: "user" },
{ name: "Problem Title", uid: "problem" },
{ name: "Language", uid: "language" },
{ name: "User", uid: "user" },
{ name: "Status", uid: "status" },
];

Expand Down Expand Up @@ -43,9 +44,19 @@ const JudgeTable: React.FC<JudgeTableProps> = (props) => {
}}
key={idx}
>
<th>{judge.problem?.title}</th>
<td className="flex items-center gap-2 py-2">
<div className="avatar">
<div className="w-8 rounded-full">
<img
src={getGravatarUrl(judge.user?.name)}
alt={`avatar-${judge.user?.name}`}
/>
</div>
</div>
{judge.user?.name}
</td>
<td>{judge.problem?.title}</td>
<td>{RenderLanguage(judge.language)}</td>
<td>{judge.user?.name}</td>
<td>
<div
className={joinClasses(
Expand Down
1 change: 0 additions & 1 deletion src/logo.svg

This file was deleted.

7 changes: 7 additions & 0 deletions src/utils/avatar_url.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import { Md5 } from "ts-md5";

export function getGravatarUrl(email: string, size: number = 200) {
var md5 = new Md5();
var hash = md5.appendStr(email).end()?.toString();
return `https://www.gravatar.com/avatar/${hash}?d=identicon&s=${size}`;
}

0 comments on commit 532ecbb

Please sign in to comment.