-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.html
More file actions
531 lines (471 loc) · 13.5 KB
/
Copy pathindex.html
File metadata and controls
531 lines (471 loc) · 13.5 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
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
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<title>Final words</title>
<meta name="description" content="Glimpses of deleting bluesky posts." />
<meta property="og:site_name" content="Final words" />
<link rel="canonical" href="https://deletions.bsky.bad-example.com/" />
<script type="application/ld+json">
{
"@context" : "https://schema.org",
"@type" : "WebSite",
"name" : "Final words",
"url" : "https://deletions.bsky.bad-example.com/",
}
</script>
<style type="text/css">
.js .no-js-ohno { display: none; }
body {
background: #323;
color: #bba;
font-family: 'Iowan Old Style', 'Palatino Linotype', 'URW Palladio L', P052, serif;
font-size: 16pt;
font-weight: normal;
line-height: 1.4em;
margin: 0;
padding: 0;
}
h1 {
font-size: 1.5em;
margin: 0.5em 0;
}
p {
margin: 0.5em 0;
}
a {
color: inherit;
}
#lang-selector {
column-gap: 0.4em;
display: flex;
flex-wrap: wrap;
gap: 0.5em;
margin: 0.5em 0;
row-gap: 0.3em;
}
.layout {
display: flex;
min-height: 100vh;
}
.layout .meta {
background: #111;
border-style: solid;
border-color: hsla(0, 0%, 100%, 0.1);
border-width: 0 2px 0 0;
box-sizing: border-box;
flex: 0 1 12em;
line-height: 1em;
padding: 1em;
}
.layout .content {
flex: 0 1 24em;
max-width: 24em;
padding: 1em 1em 4em;
position: relative;
}
.thanks {
align-items: baseline;
bottom: 0;
display: flex;
font-family: sans-serif;
font-size: 0.667em;
gap: 1em;
line-height: 1.1;
margin: 0 auto;
opacity: 0.5;
position: absolute;
}
.thanks:hover {
opacity: 0.8;
}
@media screen and (max-width: 30em) {
body {
font-size: 15pt;
}
.layout {
flex-direction: column;
}
.layout .meta {
min-height: 0;
border-width: 0 0 2px;
flex-basis: auto;
flex-shrink: 0;
flex-grow: 0;
}
.layout .content {
flex-basis: auto;
flex-grow: 1;
}
h1 {
margin-top: 0.5rem;
}
}
.info {
font-size: 0.667em;
}
.info.connection {
display: none;
}
.info.connection.timeout {
display: block;
color: #c70;
}
.posts-area {
margin: 1em auto;
}
.stack-frame {
--bottom: 50px;
box-sizing: : border-box;
margin: 0.1em 0;
overflow: hidden;
position: relative;
padding-bottom: var(--bottom);
animation:
5s ease-out 3s fade,
3s ease-in-out 5s leave;
}
.post {
background: #1f141f;
border-radius: 0.5rem;
box-sizing: border-box;
cursor: pointer;
font-style: italic;
margin: 0;
overflow-wrap: break-word;
padding: 0.5em 0.8em 0;
position: relative;
text-align: center;
width: 100%;
z-index: 1;
}
.post .wordy {
-webkit-box-orient: vertical;
box-orient: vertical;
display: -webkit-box;
display: box;
-webkit-line-clamp: 4;
line-clamp: 4;
font-size: 0.8em;
overflow: hidden;
}
.post:not(:first-child) {
position: absolute;
z-index: calc(-1 * var(--n));
bottom: calc(var(--bottom) - 2px - var(--n) * 13px);
transform: rotate(calc(var(--n) * 0.8deg));
scale: calc(1 - var(--n) * .04);
opacity: calc(.7 - var(--n) * 0.05);
}
.post:nth-child(2) { --n: 1; }
.post:nth-child(3) { --n: 2; }
.post:nth-child(4) { --n: 3; }
.post:nth-child(5) { --n: 4; }
.post:nth-child(6) { --n: 5; }
.post:nth-child(7) { --n: 6; }
.post:nth-child(8) { --n: 7; }
.post:nth-child(9) { --n: 8; }
.post:nth-child(10) { --n: 9; }
.post:nth-child(11) { --n: 10; }
.post:nth-child(12) { --n: 11; }
.post:nth-child(13) { --n: 12; }
.post .post-info {
color: #666;
font-size: 0.667em;
font-family: sans-serif;
font-style: normal;
line-height: 1;
margin: 0 -0.8rem 0 0;
padding: 0 0.2em 0.2em;
text-align: right;
}
.post:not(.waiting) {
border: 2px solid hsla(0, 0%, 100%, 0.1);
animation: 0.5s ease-in arrive;
}
.post.waiting {
background: transparent;
animation:
0.5s ease-in arrive;
}
.post.waiting.leaving {
animation:
5s ease-out fade,
3s ease-in-out 2s leave;
}
@keyframes arrive {
from { opacity: 0; }
to { opacity: 1; }
}
@keyframes fade {
from { opacity: 1; }
to { opacity: 0; }
}
@keyframes leave {
from {
margin-bottom: 0;
scale: 100%;
}
to {
margin-bottom: calc(var(--h) - 0.1em); /* 0.1em matches the frame margin */
scale: 70%;
}
}
</style>
<script type="text/javascript">document.querySelector('html').classList.add('js')</script>
</head>
<body>
<div class="layout">
<div class="meta">
<h1>Final words</h1>
<p class="info">Glimpses of deleting bluesky posts. Observing: <span id="info-observers"><em>waiting…</em></span></p>
<details id="filter-langs">
<summary>Filter language</summary>
<form id="lang-selector"></form>
</details>
<p class="info connection">
system status: missed connection
</p>
</div>
<div class="content">
<p class="no-js-ohno">Unfortunately, JavaScript is required to glimpse deleted posts as they go.</p>
<div class="posts-area">
<div class="post waiting">
<p>Listening for deletions…</p>
</div>
</div>
<div class="thanks">
<a href="https://bsky.app/profile/bad-example.com/post/3l53o5atwio2t" target="_blank">about</a>
<a href="https://docs.google.com/forms/d/e/1FAIpQLSeuV32IJL_xWKCHD6JsuWa8D60-0n10LQ6Fn5_Iw1Jj9hyKAQ/viewform" target="_blank">feedback</a>
<details>
<summary>thanks</summary>
<p>data: bluesky's public <a href="https://github.com/bluesky-social/jetstream" target="_blank">jetstream</a> instance.</p>
</details>
</div>
</div>
</div>
<script type="text/javascript">
window.onerror = (message, source, lineno, colno, e) => navigator.sendBeacon('/oops',
JSON.stringify({ message, source, lineno, colno, stack: e && e.stack }));
</script>
<script type="text/javascript">
const SHOW_WAITING_AFTER_MS = 1000;
const DISCONNECT_TIMEOUT = 25 * 1000; // server sends observers every 12s
const RECONNECT_RETRY = 3000;
const STACK_CAPTURE_TIME = 1200; // ms; posts within this will be stacked
const crel = (tagName, classes) => {
const el = document.createElement(tagName);
if (classes !== undefined) {
el.classList.add.apply(el.classList, classes);
}
return el;
};
const postsAreaEl = document.querySelector('.posts-area');
const waitingEl = document.querySelector('.post.waiting');
const langSelectorForm = document.querySelector('#lang-selector');
const includeUnsetLangInput = crel('input');
const observersInfoEl = document.querySelector('#info-observers');
const connectionStatusEl = document.querySelector('.info.connection');
// websocket connection & message handling
let ws;
const connect = langs => {
const wsProto = window.location.protocol === 'https:' ? 'wss:' : 'ws:';
const wsParams = new URLSearchParams();
langs.forEach(lang => wsParams.append('lang', lang));
const wsUrl = `${wsProto}//${window.location.host}/?${wsParams}`;
console.info('ws connect', wsUrl);
ws = new WebSocket(wsUrl);
ws.onopen = petWatchdog;
ws.onclose = () => missedU(1, 'ws.onclose');
ws.onerror = e => { ws.close(); console.error(e) };
ws.onmessage = ({ data }) => {
petWatchdog();
const content = JSON.parse(data);
const { type } = content;
if (type === 'post') {
createPost(content.post);
} else if (type == 'observers') {
updateObservers(content.observers);
} else {
console.info('other message', content);
}
};
};
let wdt;
let reconTimer;
const missedU = (n, msg) => {
console.info('missedU', msg)
connectionStatusEl.classList.add('timeout');
let t = RECONNECT_RETRY * Math.pow(1.4, (n ?? 0));
t *= Math.random() / 10 + 1;
reconTimer = setTimeout(() => {
if (ws.readyState === ws.CLOSED) {
connect(getSelectedLangs());
} else {
missedU((n ?? 0) + 1, `${msg}.reconTimer`);
}
}, t);
};
const petWatchdog = () => {
connectionStatusEl.classList.remove('timeout');
clearTimeout(wdt);
clearTimeout(reconTimer);
wdt = setTimeout(() => missedU(0, 'wdt'), DISCONNECT_TIMEOUT);
};
let initialLangs = {{ .BrowserLangs }};
try { initialLangs = JSON.parse(localStorage.getItem('langs')) || initialLangs; }
catch (e) { console.warn('could not load saved langs', e) }
connect(initialLangs);
let waitingTimer;
waitingEl.style.setProperty('--h', `-${waitingEl.getBoundingClientRect().height}px`);
waitingEl.remove(); // initially hide
waitingEl.addEventListener('animationend', event => {
if (event.animationName === 'leave') waitingEl.remove();
});
waitingTimer = setTimeout(showListeningMessage, SHOW_WAITING_AFTER_MS);
// post rendering
const getNiceAge = ms => {
const secs = Math.round(ms / 1000);
if (secs < 45) {
return `${secs} sec`;
}
const mins = Math.round(secs / 60);
if (mins < 45) {
return `${mins} min`;
}
const hrs = Math.round(mins / 60);
return `${hrs} hr`;
}
let currentStackFrame;
let currentStackTime;
function newStack() {
const myStackFrame = crel('div', ['stack-frame']);
currentStackTime = +new Date();
if (postsAreaEl.contains(waitingEl)) {
waitingEl.classList.add('leaving');
}
let cleanupTimer;
const cleanup = () => {
clearTimeout(cleanupTimer);
if (postsAreaEl.childElementCount === 1) { // we are the last one
clearTimeout(waitingTimer);
waitingTimer = setTimeout(showListeningMessage, SHOW_WAITING_AFTER_MS);
}
myStackFrame.remove();
};
myStackFrame.addEventListener('click', event => {
if (event.target.classList.contains('stack-frame')) return;
const first = myStackFrame.firstChild;
first.remove();
myStackFrame.appendChild(first);
});
myStackFrame.addEventListener('animationend', event => {
if (event.animationName === 'arrive') {
myStackFrame.style.setProperty('--h', `-${myStackFrame.getBoundingClientRect().height}px`);
} else if (event.animationName === 'leave') {
cleanup();
}
});
cleanupTimer = setTimeout(cleanup, 20000); // backup to remove nodes if we miss `animationend`
postsAreaEl.appendChild(myStackFrame);
currentStackFrame = myStackFrame;
}
function createPost(post) {
if (!currentStackFrame) {
newStack();
} else if ((+new Date() - currentStackTime) > STACK_CAPTURE_TIME) {
newStack();
} else if (currentStackFrame.childElementCount >= 13) {
return; // cap the stack
}
const { text, target } = post.value;
const postEl = crel('div', ['post']);
let wordy = text.length > 100;
const paras = text
.replace(/\n\s*\n/g, '\n')
.split('\n')
.map((p, i) => {
const postP = crel('p');
postP.textContent = p;
if (i > 3) postEl.classList.add('wordy');
return postP;
});
let postContentContainer = postEl;
if (wordy) {
postContentContainer = crel('div', ['wordy']);
postEl.appendChild(postContentContainer);
}
paras.forEach(p => postContentContainer.appendChild(p));
let postTypeName = 'post';
if (target === 'reply') postTypeName = 'reply';
else if (target === 'quote') postTypeName = 'quote post';
const postInfoEl = crel('div', ['post-info']);
postInfoEl.textContent = postTypeName;
postInfoEl.textContent += post.likes ? `, ${post.likes} like${post.likes > 1 ? 's': ''}` : '';
postInfoEl.textContent += `, age ${getNiceAge(post.age)}`;
postEl.appendChild(postInfoEl);
currentStackFrame.appendChild(postEl);
}
function showListeningMessage() {
if (postsAreaEl.children.length > 0) return;
waitingEl.classList.remove('leaving');
postsAreaEl.appendChild(waitingEl);
}
// you and who
function updateObservers(observers) {
if (observers <= 1) {
observersInfoEl.textContent = 'just you.';
} else if (observers == 2) {
observersInfoEl.textContent = 'you and one other.';
} else if (observers == 3) {
observersInfoEl.textContent = 'you and two others.';
} else if (observers == 4) {
observersInfoEl.textContent = 'you and three others.';
} else if (observers == 5) {
observersInfoEl.textContent = 'you and four others.';
} else {
observersInfoEl.textContent = `you and ${observers-1} others.`;
}
}
// controls
{{ .KnownLangs }}.forEach(lang => {
const langEl = crel('label');
langSelectorForm.appendChild(langEl);
const langBox = crel('input');
langBox.type = 'checkbox';
if (initialLangs.includes(lang)) langBox.checked = true;
langBox.name = lang;
langBox.addEventListener('input', changeLanguageSelection);
langEl.appendChild(langBox);
langEl.appendChild(document.createTextNode(lang));
langSelectorForm.appendChild(document.createTextNode(' '));
});
(includeUntaggedLangs => {
const filterLangsEl = document.querySelector('#filter-langs');
const p = crel('p');
filterLangsEl.appendChild(p);
const label = crel('label');
p.appendChild(label);
const input = crel('input');
label.appendChild(includeUnsetLangInput);
const text = document.createTextNode(' include unknown');
label.appendChild(text);
includeUnsetLangInput.type = 'checkbox';
includeUnsetLangInput.checked = includeUntaggedLangs;
includeUnsetLangInput.addEventListener('input', changeLanguageSelection);
})(initialLangs.includes(null));
function getSelectedLangs() {
const langs = Array.from(new FormData(langSelectorForm).keys());
if (includeUnsetLangInput.checked) langs.push(null);
return langs;
}
function changeLanguageSelection() {
const langs = getSelectedLangs();
try { localStorage.setItem('langs', JSON.stringify(langs)); }
catch (e) { console.error('could not save lang selection', e); }
ws.send(JSON.stringify({ type: 'setLangs', langs }));
}
</script>
</body>
</html>