Skip to content
This repository was archived by the owner on May 11, 2025. It is now read-only.

Commit eee5674

Browse files
committed
0.13
1 parent f47e284 commit eee5674

3 files changed

Lines changed: 132 additions & 2 deletions

File tree

index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ app.get('/repo/:user/:repo/', async function (req, res) {
3434
return;
3535
}
3636
res.type('svg');
37-
res.send(await stats.getRepository(username, repo));
37+
res.render('repo', await stats.getRepository(username, repo));
3838
});
3939

4040

stats.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,8 @@ async function getRepository(username, repo) {
5353
// get releases (700ms): (await cache.requestWithCache(`/repos/${username}/${repo}/releases`)).length
5454
const info = await cache.requestWithCache(`/repos/${username}/${repo}`);
5555
return {
56-
repo: `${username} / ${repo}`,
56+
username: username,
57+
repo: repo,
5758
size: storeConvert(info['size'], 1),
5859
forks: info['forks'],
5960
stars: info['stargazers_count'],

views/repo.ejs

Lines changed: 129 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,129 @@
1+
<svg width="450" height="195" viewBox="0 0 450 195" fill="none" xmlns="http://www.w3.org/2000/svg" role="img" aria-labelledby="descId">
2+
<title id="titleId"><%= repo %>'s Code Stats</title>
3+
<desc id="descId">Repository Code Statistics</desc>
4+
<style>
5+
.header {
6+
font: 600 18px 'Segoe UI', Ubuntu, Sans-Serif;
7+
fill: #2f80ed;
8+
animation: fadeInAnimation 0.8s ease-in-out forwards;
9+
}
10+
@supports(-moz-appearance: auto) {
11+
/* Selector detects Firefox */
12+
.header { font-size: 15.5px; }
13+
}
14+
.stat {
15+
font: 600 14px 'Segoe UI', Ubuntu, "Helvetica Neue", Sans-Serif; fill: #434d58;
16+
}
17+
@supports(-moz-appearance: auto) {
18+
.stat { font-size:12px; }
19+
}
20+
.stagger {
21+
opacity: 0;
22+
animation: fadeInAnimation 0.3s ease-in-out forwards;
23+
}
24+
.rank-text {
25+
font: 800 24px 'Segoe UI', Ubuntu, Sans-Serif; fill: #434d58;
26+
animation: scaleInAnimation 0.3s ease-in-out forwards;
27+
}
28+
.not_bold { font-weight: 400 }
29+
.bold { font-weight: 700 }
30+
.icon {
31+
fill: #4c71f2;
32+
display: none;
33+
}
34+
.rank-circle-rim {
35+
stroke: #2f80ed;
36+
fill: none;
37+
stroke-width: 6;
38+
opacity: 0.2;
39+
}
40+
.rank-circle {
41+
stroke: #2f80ed;
42+
stroke-dasharray: 250;
43+
fill: none;
44+
stroke-width: 6;
45+
stroke-linecap: round;
46+
opacity: 0.8;
47+
transform-origin: -10px 8px;
48+
transform: rotate(-90deg);
49+
animation: rankAnimation 1s forwards ease-in-out;
50+
}
51+
@keyframes rankAnimation {
52+
from {
53+
stroke-dashoffset: 251.32741228718345;
54+
}
55+
to {
56+
stroke-dashoffset: 125.45405959298056;
57+
}
58+
}
59+
@keyframes scaleInAnimation {
60+
from {
61+
transform: translate(-5px, 5px) scale(0);
62+
}
63+
to {
64+
transform: translate(-5px, 5px) scale(1);
65+
}
66+
}
67+
@keyframes fadeInAnimation {
68+
from {
69+
opacity: 0;
70+
}
71+
to {
72+
opacity: 1;
73+
}
74+
}
75+
76+
77+
</style>
78+
<rect data-testid="card-bg" x="0.5" y="0.5" rx="4.5" height="99%" stroke="#e4e2e2" width="449" fill="#fffefe" stroke-opacity="1"/>
79+
<g data-testid="card-title" transform="translate(25, 35)">
80+
<g transform="translate(0, 0)">
81+
<text x="0" y="0" class="header" data-testid="header"><a href="https://github.com/<%= username %>/<%= repo %>/"><%= username %> / <%= repo %></a></text>
82+
</g>
83+
</g>
84+
<g data-testid="main-card-body" transform="translate(0, 55)">
85+
<g data-testid="rank-circle" transform="translate(365, 47.5)">
86+
<circle class="rank-circle-rim" cx="-10" cy="8" r="40"/>
87+
<circle class="rank-circle" cx="-10" cy="8" r="40"/>
88+
<g class="rank-text">
89+
<text x="-5" y="3" alignment-baseline="central" dominant-baseline="central" text-anchor="middle">
90+
A+
91+
</text>
92+
</g>
93+
</g>
94+
<svg x="0" y="0">
95+
<g transform="translate(0, 0)">
96+
<g class="stagger" style="animation-delay: 450ms" transform="translate(25, 0)">
97+
<svg xmlns="http://www.w3.org/2000/svg" data-testid="icon" class="icon" viewBox="0 0 16 16" version="1.1" width="16" height="16">
98+
<path fill-rule="evenodd" d="M8 .25a.75.75 0 01.673.418l1.882 3.815 4.21.612a.75.75 0 01.416 1.279l-3.046 2.97.719 4.192a.75.75 0 01-1.088.791L8 12.347l-3.766 1.98a.75.75 0 01-1.088-.79l.72-4.194L.818 6.374a.75.75 0 01.416-1.28l4.21-.611L7.327.668A.75.75 0 018 .25zm0 2.445L6.615 5.5a.75.75 0 01-.564.41l-3.097.45 2.24 2.184a.75.75 0 01.216.664l-.528 3.084 2.769-1.456a.75.75 0 01.698 0l2.77 1.456-.53-3.084a.75.75 0 01.216-.664l2.24-2.183-3.096-.45a.75.75 0 01-.564-.41L8 2.694v.001z"/>
99+
</svg>
100+
<text class="stat bold" y="12.5">Stars:</text>
101+
<text class="stat bold" x="199.01" y="12.5" data-testid="stars"><%= stars %></text>
102+
</g>
103+
</g><g transform="translate(0, 25)">
104+
<g class="stagger" style="animation-delay: 600ms" transform="translate(25, 0)">
105+
<text class="stat bold" y="12.5">Forks:</text>
106+
<text class="stat bold" x="199.01" y="12.5" data-testid="forks"><%= forks %></text>
107+
</g>
108+
</g><g transform="translate(0, 50)">
109+
<g class="stagger" style="animation-delay: 750ms" transform="translate(25, 0)">
110+
<text class="stat bold" y="12.5">Watchers:</text>
111+
<text class="stat bold" x="199.01" y="12.5" data-testid="watchers"><%= watchers %></text>
112+
</g>
113+
</g><g transform="translate(0, 75)">
114+
<g class="stagger" style="animation-delay: 900ms" transform="translate(25, 0)">
115+
116+
<text class="stat bold" y="12.5">Repo Size:</text>
117+
<text class="stat bold" x="199.01" y="12.5" data-testid="size"><%= size %></text>
118+
</g>
119+
</g><g transform="translate(0, 100)">
120+
<g class="stagger" style="animation-delay: 1050ms" transform="translate(25, 0)">
121+
122+
<text class="stat bold" y="12.5">License:</text>
123+
<text class="stat bold" x="199.01" y="12.5" data-testid="license"><%= license %></text>
124+
</g>
125+
</g>
126+
</svg>
127+
128+
</g>
129+
</svg>

0 commit comments

Comments
 (0)