Skip to content

Commit 7c95601

Browse files
committed
Added Badges and Contributor Tracking
Improved contributor tracking Added Predefined Badges Added Special Badges Added a /badge route and tooltips
1 parent aaae9bc commit 7c95601

27 files changed

+806
-190
lines changed

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,3 +91,6 @@ backend/__pycache__/
9191

9292
# Config files
9393
.prettierrc.js
94+
95+
# Visual Studio
96+
/.vs
2.41 KB
Loading
28.5 KB
Loading
1.16 KB
Loading
24.6 KB
Loading
1.95 KB
Loading

public/index.html

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
<head>
55
<meta charset="utf-8" />
66
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
7-
<meta name="viewport" content="width=device-width, initial-scale=1.0, shrink-to-fit=yes" />
7+
<meta name="viewport" content="width=device-width, initial-scale=1.0, shrink-to-fit=no" />
88
<link rel="icon" href="<%= BASE_URL %>favicon.ico" />
99
<title>CodeBadge</title>
1010
<link
@@ -19,6 +19,9 @@
1919
href="https://fonts.googleapis.com/css?family=Roboto+Condensed&display=swap"
2020
rel="stylesheet"
2121
/>
22+
<link
23+
href="https://fonts.googleapis.com/css?family=Raleway&display=swap"
24+
rel="stylesheet">
2225
<link
2326
href="https://fonts.googleapis.com/css?family=Material+Icons"
2427
rel="stylesheet"
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
[
2+
{
3+
"name": "Baby Steps",
4+
"min_commits": 0,
5+
"max_commits": 10000,
6+
"badge": "babysteps.png",
7+
"tooltip": "10000 commits or less",
8+
"information": {
9+
"title": "Baby Steps",
10+
"description": "Assigned to all beginners."
11+
}
12+
}
13+
]
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
import rawdata from "./badges";
2+
3+
const json = JSON.parse(JSON.stringify(rawdata));
4+
const badgeURLPrefix = "/assets/badges/predefined/";
5+
6+
export default class PredefinedBadges {
7+
getBadge(commits) {
8+
let url = "";
9+
let tooltip = "";
10+
json.forEach(function(badge) {
11+
if (commits >= badge.min_commits && commits <= badge.max_commits) {
12+
url = badgeURLPrefix + badge.badge;
13+
tooltip = badge.tooltip;
14+
}
15+
});
16+
return {url: url, tooltip: tooltip};
17+
}
18+
19+
getBadgeFromName(name) {
20+
let data = {};
21+
json.forEach(function(badge) {
22+
if(badge.name === name)
23+
{
24+
data = badge;
25+
}
26+
});
27+
return data;
28+
}
29+
30+
getBadgeURLPrefix()
31+
{
32+
return badgeURLPrefix;
33+
}
34+
35+
getAllBadgeIDs()
36+
{
37+
let keys = [];
38+
for(let i in json)
39+
keys.push(json[i].name);
40+
return keys;
41+
}
42+
}

src/assets/badges/special/badges.json

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
{
2+
"topContributor": {
3+
"badge": "topcommits.png",
4+
"tooltip": "Awarded to the top contributor of your organization!",
5+
"information": {
6+
"title": "Top Contributor of All Time",
7+
"description": "Assigned to the person who has the highest commits in your organization!"
8+
}
9+
},
10+
"topWeekContributor": {
11+
"badge": "topweekcommits.png",
12+
"tooltip": "Awarded to the one with with highest commits last week!",
13+
"information": {
14+
"title": "Top Contributor this Week",
15+
"description": "Assigned to the person who had the highest commits last week in your organization!"
16+
}
17+
},
18+
"topMonthContributor": {
19+
"badge": "topmonthcommits.png",
20+
"tooltip": "Awarded to the one with with highest commits this month!",
21+
"information": {
22+
"title": "Top Contributor this Month",
23+
"description": "Assigned to the person who has the highest commits this month in your organization!"
24+
}
25+
},
26+
"topYearContributor": {
27+
"badge": "topyearcommits.png",
28+
"tooltip": "Awarded to the one with with highest commits this year!",
29+
"information": {
30+
"title": "Top Contributor this Year",
31+
"description": "Assigned to the person who has the highest commits this year in your organization!"
32+
}
33+
}
34+
}

0 commit comments

Comments
 (0)