-
-
Notifications
You must be signed in to change notification settings - Fork 21
Expand file tree
/
Copy pathindex.html
More file actions
275 lines (235 loc) · 7.81 KB
/
index.html
File metadata and controls
275 lines (235 loc) · 7.81 KB
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
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<meta http-equiv="X-UA-Compatible" content="ie=edge" />
<!-- Favicons -->
<link rel="apple-touch-icon" sizes="180x180" href="./src/fav/apple-touch-icon.png" />
<link rel="icon" type="image/png" sizes="32x32" href="./src/fav/favicon-32x32.png" />
<link rel="icon" type="image/png" sizes="16x16" href="./src/fav/favicon-16x16.png" />
<link rel="mask-icon" href="./src/fav/safari-pinned-tab.svg" color="#5bbad5" />
<link rel="shortcut icon" href="./src/fav/favicon.ico" />
<meta name="msapplication-TileColor" content="#da532c" />
<meta name="msapplication-config" content="./src/fav/browserconfig.xml" />
<meta name="theme-color" content="#ffffff" />
<!-- Marked.js for markdown parsing -->
<script src="https://cdn.jsdelivr.net/npm/marked@11.1.1/lib/marked.umd.min.js"></script>
<title>Design Computing</title>
<style>
@font-face {
font-family: "Blender-book";
src: url("./src/blenderpro-book-webfont.woff");
}
* {
box-sizing: border-box;
}
:root {
--header-colour: hsl(199, 100%, 9%);
--header-text-colour: hsla(175, 84%, 45%, 1);
--header-height: 5em;
--background-colour: hsl(0, 0%, 97%);
--tile-colour: hsla(0, 0%, 0%, 0.1);
--alert-colour: hsl(166, 100%, 50%);
--fontStack: "Blender-book", "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;
--edge: 0.5em;
--tile-dim: calc(98vw / 6);
--tile-dim-min: 7em;
}
body {
background-color: var(--background-colour);
font-family: var(--fontStack);
font-size: 24px;
margin: 0 auto;
}
.writing {
max-width: 30em;
margin: 0 auto;
padding: 1em;
}
.facebook {
display: flex;
flex-wrap: wrap;
justify-content: center;
gap: 0.5em;
padding: 1em;
}
.person {
display: inline-block;
height: var(--tile-dim);
min-height: var(--tile-dim-min);
padding: 0;
position: relative;
width: var(--tile-dim);
min-width: var(--tile-dim-min);
overflow: hidden;
background: var(--tile-colour);
}
.person .info {
background: #ffffff78;
bottom: var(--edge);
display: inline;
left: var(--edge);
position: absolute;
width: calc(100% - (var(--edge) * 2));
}
.person .info p,
.person .info h1 {
margin: 0;
}
.person .info p {
font-size: 70%;
}
.person .info h1 {
font-size: 110%;
}
.person .info h1 a {
text-decoration: none;
}
.person img {
width: 100%;
height: 100%;
object-fit: cover;
}
.loading {
text-align: center;
padding: 2em;
color: #666;
}
.error {
text-align: center;
padding: 2em;
color: #c33;
}
/* Loading animation */
.spinner {
border: 4px solid #f3f3f3;
border-top: 4px solid var(--alert-colour);
border-radius: 50%;
width: 40px;
height: 40px;
animation: spin 1s linear infinite;
margin: 2em auto;
}
@keyframes spin {
0% { transform: rotate(0deg); }
100% { transform: rotate(360deg); }
}
</style>
</head>
<body>
<div id="root">
<div class="loading">
<div class="spinner"></div>
<p>Loading course content...</p>
</div>
</div>
<script>
// Configuration
const API_BASE = 'https://api.github.com';
const ORG = 'design-computing';
const RATE_LIMIT_MESSAGE = `# Well, this is embarrassing, we're being rate limited 😬
It happens when a lot of people are trying to hit the GitHub API at the same time from this page.
You can still get to the content through these links:
1. [What's supposed to be on this page](https://design-computing.github.io/md/general)
1. [Week 1](https://design-computing.github.io/md/week1)
1. [Week 2](https://design-computing.github.io/md/week2)
1. [Week 3](https://design-computing.github.io/md/week3)
1. [Week 4](https://design-computing.github.io/md/week4)
1. [Week 5](https://design-computing.github.io/md/week5)
1. [Week 6](https://design-computing.github.io/md/week6)
1. [Week 7](https://design-computing.github.io/md/week7)
1. [Week 8+](https://design-computing.github.io/md/theRest)`;
// Fetch and render functions
async function fetchJSON(url) {
const response = await fetch(url, {
method: 'GET',
headers: {
'Accept': 'application/json',
'Content-Type': 'application/json'
}
});
return response.json();
}
async function loadGeneralContent() {
try {
const url = `${API_BASE}/repos/${ORG}/Design-Computing.github.io/contents/md/general.md`;
const data = await fetchJSON(url);
if (data.message && data.message.includes('API rate limit exceeded')) {
return RATE_LIMIT_MESSAGE;
}
// Decode base64 content
return atob(data.content);
} catch (error) {
console.error('Error loading general content:', error);
return '# Error Loading Content\n\nPlease try refreshing the page.';
}
}
async function loadForks() {
try {
const url = `${API_BASE}/repos/${ORG}/me/forks?per_page=60`;
const forks = await fetchJSON(url);
return Array.isArray(forks) ? forks : [];
} catch (error) {
console.error('Error loading forks:', error);
return [];
}
}
function renderPerson(forkData) {
if (!forkData.owner) return '';
const { owner } = forkData;
const name = owner.login || 'Unknown';
const avatarUrl = owner.avatar_url || '';
const profileUrl = owner.html_url || '#';
return `
<div class="person">
<img src="${avatarUrl}" alt="${name}'s avatar" loading="lazy" />
<div class="info">
<h1><a href="${profileUrl}" target="_blank" rel="noopener">${name}</a></h1>
</div>
</div>
`;
}
function renderPeople(forks) {
if (!forks || forks.length === 0) {
return '<div class="loading"><p>No student forks found yet</p></div>';
}
return forks
.filter(fork => fork.owner)
.map(renderPerson)
.join('');
}
async function initApp() {
const root = document.getElementById('root');
try {
// Load both content and forks in parallel
const [markdownContent, forks] = await Promise.all([
loadGeneralContent(),
loadForks()
]);
// Parse markdown to HTML
const htmlContent = marked.parse(markdownContent);
// Render the page
root.innerHTML = `
<div class="writing">${htmlContent}</div>
<div class="facebook">${renderPeople(forks)}</div>
`;
} catch (error) {
console.error('Error initializing app:', error);
root.innerHTML = `
<div class="error">
<h1>Error Loading Page</h1>
<p>Please try refreshing. If the problem persists, check the browser console.</p>
</div>
`;
}
}
// Start the app when the page loads
if (document.readyState === 'loading') {
document.addEventListener('DOMContentLoaded', initApp);
} else {
initApp();
}
</script>
</body>
</html>