-
Notifications
You must be signed in to change notification settings - Fork 0
/
search.html
438 lines (416 loc) · 10.2 KB
/
search.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
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
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta name="description" content="An ASG website">
<meta name="author" content="vanyle">
<meta name="keywords" content="blog, asg, vanyle">
<title>Antoine's blog</title>
<style>
body,html{
font-family: sans-serif;
display: flex;
flex-direction: column;
margin: 0;
padding: 0;
width: 100%;
height: 100%;
}
header{
display: flex;
align-items: stretch;
justify-content: center;
}
header a{
text-decoration: none;
}
a{
color: inherit;
cursor: pointer;
}
main{
padding: 10px;
}
header > div{
width: min(max(60%, 500px), 100%);
height: 100%;
display: flex;
align-items: stretch;
justify-content: space-between;
}
nav{
display: flex;
align-items: center;
height: 100%;
}
header h1{
display: flex;
align-items: center;
font-size: 2em;
font-weight: normal;
}
</style>
<style>
@import url('https://fonts.cdnfonts.com/css/oswald-4');
header{
padding: 30px 0px;
border-top: 4px solid #36f;
background-color: white;
margin-bottom:15px;
box-shadow:0 3px 1px 0px #333;
}
h2{
color: #36f;
}
body{
background-color:#36f;
justify-content: space-between;
}
nav > *{
font-family: "Oswald", sans-serif;
padding: 10px 10px;
margin: 0 10px;
font-size: 1.3em;
display: flex;
justify-content: center;
align-items: center;
height: 100%;
cursor: pointer;
box-sizing: content-box;
border-bottom: 5px solid transparent;
transition: 300ms;
}
nav > *:hover{
border-bottom: 5px solid #36f;
}
nav > *:active{
transform: scale(0.9);
}
h1,h2,h3,h4,h5,h6{
margin: 5px;
font-family: "Oswald", sans-serif;
}
p{
font-size: 20px;
}
section{
width: min(max(60%, 500px), 100%);
box-sizing: border-box;
padding:20px;
background-color:white;
margin: auto;
display:flex;
flex-direction: column;
}
.card{
padding: 15px;
margin: 10px;
text-decoration:none;
transition:300ms;
}
a{
text-decoration:none;
}
p a{
text-decoration:underline;
}
.card:hover{
box-shadow:inset 0px 0px 0px 2px #333;
}
.card .title{
cursor: pointer;
font-weight: bold;
display: inline-block;
text-decoration: none;
font-size: 1.4em;
color: inherit;
transition:300ms;
}
.card .title:active{
transform: scale(0.9);
}
.card .title:hover{
color:#333;
}
.card .time{
color: #666;
}
footer{
background-color: white;
box-shadow:0 -3px 1px 0px #333;
padding:5px 15px;
}
</style>
</head>
<body>
<header>
<div>
<h1>Antoine's blog</h1>
<nav>
<a href="/">Home</a>
<a href="/about.html">About</a>
<a href="/search.html">Search</a>
</nav>
</div>
</header>
<section>
<h2>Search for a post</h2>
<style>
input[type=text]#search{
border: none;
outline: none;
border-bottom: 3px solid #36f;
padding: 5px;
margin: 5px;
font-size: 1.2em;
}
</style>
<input id="search" placeholder="Search" type="text"/>
<div id="results"></div>
<script>
let posts = [
{
title: `Stop wasting my time`,
url: `./posts/do_not_waste_my_time.html`,
description: `Why I think a lot of open-source software is in a very bad state and what we can do about it.`
},
{
title: `Emscripten`,
url: `./posts/emscripten.html`,
description: `Writing cross-platform code with Nim, C and Emscripten.`
},
{
title: `How to make compelling games?`,
url: `./posts/game_design_tips.html`,
description: `A game design idea concept I realized`
},
{
title: `Making the computer do math`,
url: `./posts/sat_solving.html`,
description: `How I wrote a sat solver, and what I learnt along the way.`
},
{
title: `Layout Algorithms`,
url: `./posts/layout_algorithms.html`,
description: `A story about shuffling rectangles around`
},
{
title: `Cooking and chemistry`,
url: `./posts/cooking_chemistry.html`,
description: `Like most people except this guy, I like food.`
},
{
title: `Top 5 of the best data structures`,
url: `./posts/best_datastructures.html`,
description: `Number 2 might surprise you!`
},
{
title: `Building a programming language`,
url: `./posts/building_programming_languages.html`,
description: `If you want to build your own programming language and have no idea where to start, there is this cool website / book`
},
{
title: ` Sudoku
`,
url: `./posts/sudoku.html`,
description: ` A sudoku solver.
`
},
{
title: ` Projectile
`,
url: `./posts/projectile.html`,
description: ` The curve of a projectile based on initial angle with no velocity. The maximal height range makes a cool shape.
`
},
{
title: ` Rings
`,
url: `./posts/rings.html`,
description: ` A trippy animation based on circles.
`
},
{
title: `A critique of content feeds curated by "Popularity"`,
url: `./posts/critique_of_algo_feeds.html`,
description: `Like a lot of people, I spend a lot of time online.`
},
{
title: ` Bouncy
`,
url: `./posts/physics.html`,
description: ` Click anywhere to spawn a bouncing ball!
`
},
{
title: ` Texts
`,
url: `./posts/texts.html`,
description: ` An autological word renderer
`
},
{
title: ` OuterSpace
`,
url: `./posts/outerspace.html`,
description: ` A physics simulation of planets with Newtonian physics.
`
},
{
title: ` Cute
`,
url: `./posts/galaxy.html`,
description: ` A cool looking animation using follower curves
`
},
{
title: ` Fields
`,
url: `./posts/flux.html`,
description: ` Ce jeu est une introduction interactive aux champs de vecteurs. Vous voilà prévenus !
`
},
{
title: ` Fractalo 2
`,
url: `./posts/fractalo_2.html`,
description: ` Recursive fractal renderer
`
},
{
title: ` Neural networks
`,
url: `./posts/neuraldoc_fancy.html`,
description: ` A basic interactive introduction to neural networks
`
},
{
title: ` ODE
`,
url: `./posts/ode.html`,
description: ` A representation of an object moving in a position/speed
`
},
{
title: ` Cube
`,
url: `./posts/cube.html`,
description: ` A Cube rendered with a custom minimal 3d engine.
`
},
{
title: ` Fractalo!
`,
url: `./posts/fractalo.html`,
description: ` Julia style fractal renderer
`
},
{
title: ` Droplets
`,
url: `./posts/droplets.html`,
description: ` A colorful water droplet animation
`
},
];
search.onkeyup = () => {
let query = search.value;
let s = [];
if(query === ""){
results.innerHTML = "";
return;
}
for(let i = 0;i < posts.length;i++){
if(
posts[i].title.indexOf(query) !== -1 ||
posts[i].description.indexOf(query) !== -1
){
s.push(`
<a href="${posts[i].url}">
<div class='card'>
<h3 class='title'>${posts[i].title}</h3>
<p>
${posts[i].description}
</p>
</div>
</a>
`)
}
}
results.innerHTML = s.join("");
}
</script>
</section>
<footer>
<p> © 2024 - Antoine Delègue - Powered by ASG</p>
</footer>
</body>
<script>
addEventListener("DOMContentLoaded", () => {
if(typeof window.hljs !== "undefined"){
document.body.querySelectorAll("code.language-mermaid").forEach((el) => {
el.className = "mermaid";
let tempId = "tempId51432";
el.id = tempId;
let prevParent = el.parentElement;
let fn = (svgCode, bindFunctions) => {
let d = document.createElement("div");
d.innerHTML = svgCode;
prevParent.append(d); // for some reason, el get's removed from the DOM, so we add it back.
};
mermaid.mermaidAPI.render(tempId,el.innerText+"",fn);
el.id = "";
});
}
if(typeof window.hljs !== "undefined"){
window.hljs.highlightAll();
}
if(typeof window.renderMathInElement !== "undefined"){
renderMathInElement(document.body, {
delimiters: [
{left: '$$', right: '$$', display: true},
{left: '$', right: '$', display: false},
{left: '\\(', right: '\\)', display: true},
{left: '\\[', right: '\\]', display: false}
],
throwOnError : false
});
}
// Live reload. Try to reconnect when the connection fails.
if(location.hostname === "localhost"){
window.ws = null;
window.wsIsClosed = true;
let connectionMaker = () => {
if(wsIsClosed){
wsIsClosed = false;
try{
console.log("connecting...");
ws = new WebSocket("ws://"+location.host+"/ws");
}catch(err){} // don't spam the console.
ws.onmessage = (msg) => {
wsIsClosed = false;
if(msg.data == "reload"){
location.reload();
}else{
console.log(msg);
}
}
ws.onopen = () => {
console.log("Connected!");
wsIsClosed = false;
}
ws.onerror = () => {
wsIsClosed = true;
};
ws.onclose = () => {
wsIsClosed = true;
};
}
};
setInterval(connectionMaker, 1000);
connectionMaker();
}
});
</script>
</html>