-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
159 lines (148 loc) · 5.59 KB
/
index.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
<!DOCTYPE html
PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Loading... - GitHub Pages</title>
<link rel="icon" href="https://github.githubassets.com/images/modules/logos_page/Octocat.png">
<link href="https://fonts.googleapis.com/css2?family=Rajdhani:wght@300&display=swap" rel="stylesheet">
<style>
body {
background: #5a48ac; /* fallback for old browsers */
background: -webkit-linear-gradient(to top right, #3f2b96, #a8c0ff);
background: linear-gradient(to top right, #3f2b96, #a8c0ff);
background-attachment: fixed;
color: white;
overflow: -moz-scrollbars-none;
-ms-overflow-style: none;
font-family: 'Rajdhani', sans-serif;
}
body::-webkit-scrollbar {
width: 0 !important;
display: none;
}
.main {
height: auto;
margin: 20px auto;
width: 98%;
padding: 5px;
background: rgba(0, 55, 122, 0.2);
backdrop-filter: blur(10px);
}
.header {
margin: 10px auto;
width: 98%;
padding: 5px 10px;
background: rgba(0, 55, 122, 0.2);
backdrop-filter: blur(10px);
}
h1 {
text-align: center;
}
a {
color: lightgray;
text-decoration: none;
}
#links h1 {
font-size: large;
}
</style>
</head>
<body>
<div class="main">
<div class="header">
<h1 class="heading"><span id="titleheader">Loading... - GitHub Pages</span></h1>
<h1 class="heading"><span id="titlelink">Loading...</span></h1>
</div>
<br><br>
<div class="content">
<table width="100%" cellspacing="0" cellpadding="20px" border="0">
<tr>
<td width="100%" id="bodycontent">
<hr><br>
<div style="text-align: center;" id="projectlist">Loading...</div>
<br><hr>
<div id="links">
<table width="100%" cellspacing="0" cellpadding="20px" border="0">
<tr>
<td width="50%">
<h1>
<img src="https://raw.githubusercontent.com/feathericons/feather/master/icons/user.svg" style="filter: invert(1) hue-rotate(180deg);" alt="Profile">
<br><br>
<span id="profilelink">Loading...</span>
</h1>
</td>
<td width="50%">
<h1>
<img src="https://raw.githubusercontent.com/feathericons/feather/master/icons/globe.svg" style="filter: invert(1) hue-rotate(180deg);" alt="Blog">
<br><br>
<span id="bloglink">Loading...</span>
</h1>
</td>
</tr>
</table>
</div>
</td>
</tr>
</table>
</div>
</div>
<script>
const username = location.hostname.split('.')[0];
console.log('username:', username);
const getLastCommitDate = async identifier => {
try {
const res = await fetch(`https://api.github.com/repos/${identifier}/commits`);
const data = await res.json();
if (data.message && data.message.includes('rate limit exceeded')) {
console.log(`GitHub API rate limit exceeded for '${identifier}'. Please wait for a while.`);
return 'null';
}
return data[0].commit.committer.date;
} catch (err) {
console.log(err);
}
}
const sortByDate = array => array.sort((a, b) => {
if (a.date < b.date) return 1;
else return -1;
});
const dateString = value => {
const stringdate = new Date(value);
return (stringdate.getDate() + ' ' + stringdate.toLocaleString('default', { month: 'long' }) + ' ' + stringdate.getFullYear());
};
(async () => {
try {
const res1 = await fetch(`https://api.github.com/users/${username}`);
const info = await res1.json();
document.getElementById('titleheader').innerHTML = document.title = `${info.name} - GitHub Pages`;
document.getElementById('titlelink').innerHTML = `<a href="#">${username}<span style="color: white;">.github.io</span></a>`;
document.getElementById('profilelink').innerHTML = `<a href="https://github.com/${username}"><span style="color: white;">github.com/</span>${username}</a>`;
document.getElementById('bloglink').innerHTML = `<a href="https://${info.blog}">${info.blog}</a>`;
const pageCount = Math.ceil(info.public_repos / 100);
var data = [];
for (var page = 1; page <= pageCount; page++) {
const res2 = await fetch(`https://api.github.com/users/${username}/repos?per_page=100&page=${page}`);
const currentdata = await res2.json();
data.push(...currentdata);
};
const repos = data.filter(item => item.has_pages);
for (var item of repos)
item.date = await getLastCommitDate(item.full_name);
const reqrepos = sortByDate(repos)
var reqdiv = document.getElementById('projectlist');
reqdiv.innerHTML = '';
for (var item of reqrepos)
if (item.name !== `${username}.github.io`)
reqdiv.insertAdjacentHTML('beforeend', `
<h3><a href="${item.name}">/${item.name}</a></h3>
${item.description}<br>
<a href="${item.html_url}"><i> - Last commit: ${dateString(item.date)}</a></i><br><br>
`);
} catch (err) {
console.log(err);
}
})();
</script>
</body>
</html>