-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathshrine.html
547 lines (539 loc) · 33.9 KB
/
shrine.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
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
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
<!DOCTYPE html>
<html lang="en">
<head>
<title>The (Twitter) Friends We Made Along the Way</title>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<!-- CSS -->
<style>
body {
margin: 0;
font-family: "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}
body, header {
background-color: #fff;
}
body > div {
display: flex;
flex-direction: row;
}
svg {
fill: gray;
height: 1.125rem;
width: 1.125rem;
}
.sidebar {
flex: 1 1 25%;
}
aside {
padding: 1.25rem 1rem 1rem;
}
#how-to {
margin-bottom: 75vh;
}
#how-to ol {
padding-left: 1.15rem;
}
#how-to li {
margin-top: 1.25rem;
}
#how-to ol ol {
list-style-type: lower-alpha;
padding-left: 1.5rem;
}
#how-to ol ol li {
margin-top: 0.75rem;
}
main {
border: thin gray;
border-style: none solid;
display: flex;
flex: 2 1 50%;
flex-direction: column;
min-height: 100vh;
}
#header, main > section {
padding: 0 1rem;
}
h2 { margin: 2rem 0 1rem; }
#shrine {
flex: 1 1 25%;
font-size: 0.95rem;
}
header {
border-bottom: thin solid gray;
position: -webkit-sticky;
position: sticky;
top: 0px;
z-index: 99;
}
#list-nav {
align-content: baseline;
align-items: stretch;
display: flex;
flex-direction: row;
text-align: center;
}
#list-nav a {
flex: 1 1 50%;
padding: 1rem;
}
#list-nav a:hover {
background-color: rgba(231, 233, 234, 0.5);
}
.user {
margin-top: 0.75rem;
padding: 0.9rem 0;
}
.user-about {
display: flex;
flex-direction: row;
}
.user-icon {
flex: 0 0 48px;
margin-right: 0.9rem;
}
.user-icon a {
display: inline-block;
height: 48px;
width: 48px;
}
.user-profile {
}
.user-name {
font-size: 1.15rem;
font-weight: 700;
margin-top: 0;
}
.user-name a { display: block; }
.user-handle {
display: block;
font-size: 0.9rem;
font-weight: normal;
}
.user-protecc svg {
height: 1rem;
margin: 0 0.15rem;
position: absolute;
width: 1rem;
}
.user-metadata {
align-items: baseline;
display: flex;
gap: 1.25rem;
}
.pinned-tweet {
border: thin solid gray;
border-radius: 0.5rem;
margin-left: 4rem;
margin-top: 1rem;
padding: 0.85rem 1rem 0.5rem;
}
.pinned-tweet .heading {
color: gray;
font-size: 0.925rem;
margin: 0 0 0.5rem;
}
.pinned-tweet .heading svg {
height: 0.825rem;
width: 0.825rem;
}
.pinned-tweet .content {
margin: 0 1rem 0.5rem 1.25rem;
}
.pinned-tweet-link {
font-size: 0.9rem;
text-align: right;
}
a + a {
margin-left: 0.125rem;
}
/* Dark mode styles */
@media (prefers-color-scheme: dark) {
body, header {
background-color: #000;
color: #dcdcdc;
}
a {
color: rgb(84, 177, 240);
}
a:visited {
color: rgb(151, 103, 255);
}
#list-nav a:hover {
background-color: rgba(134, 137, 138, 0.5);
}
}
</style>
<!-- Javascript -->
<!-- Use the "selection" module from d3.js. -->
<script>/*
https://d3js.org/d3-selection/ v3.0.0
Copyright 2010-2022 Mike Bostock
Permission to use, copy, modify, and/or distribute this software for any purpose
with or without fee is hereby granted, provided that the above copyright notice
and this permission notice appear in all copies.
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS
OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF
THIS SOFTWARE.
*/
!function(t,n){"object"==typeof exports&&"undefined"!=typeof module?n(exports):"function"==typeof define&&define.amd?define(["exports"],n):n((t="undefined"!=typeof globalThis?globalThis:t||self).d3=t.d3||{})}(this,(function(t){"use strict";var n="http://www.w3.org/1999/xhtml",e={svg:"http://www.w3.org/2000/svg",xhtml:n,xlink:"http://www.w3.org/1999/xlink",xml:"http://www.w3.org/XML/1998/namespace",xmlns:"http://www.w3.org/2000/xmlns/"};function r(t){var n=t+="",r=n.indexOf(":");return r>=0&&"xmlns"!==(n=t.slice(0,r))&&(t=t.slice(r+1)),e.hasOwnProperty(n)?{space:e[n],local:t}:t}function i(t){return function(){var e=this.ownerDocument,r=this.namespaceURI;return r===n&&e.documentElement.namespaceURI===n?e.createElement(t):e.createElementNS(r,t)}}function o(t){return function(){return this.ownerDocument.createElementNS(t.space,t.local)}}function u(t){var n=r(t);return(n.local?o:i)(n)}function s(){}function c(t){return null==t?s:function(){return this.querySelector(t)}}function l(t){return null==t?[]:Array.isArray(t)?t:Array.from(t)}function a(){return[]}function f(t){return null==t?a:function(){return this.querySelectorAll(t)}}function h(t){return function(){return this.matches(t)}}function p(t){return function(n){return n.matches(t)}}var _=Array.prototype.find;function d(){return this.firstElementChild}var y=Array.prototype.filter;function m(){return Array.from(this.children)}function v(t){return new Array(t.length)}function g(t,n){this.ownerDocument=t.ownerDocument,this.namespaceURI=t.namespaceURI,this._next=null,this._parent=t,this.__data__=n}function w(t){return function(){return t}}function A(t,n,e,r,i,o){for(var u,s=0,c=n.length,l=o.length;s<l;++s)(u=n[s])?(u.__data__=o[s],r[s]=u):e[s]=new g(t,o[s]);for(;s<c;++s)(u=n[s])&&(i[s]=u)}function x(t,n,e,r,i,o,u){var s,c,l,a=new Map,f=n.length,h=o.length,p=new Array(f);for(s=0;s<f;++s)(c=n[s])&&(p[s]=l=u.call(c,c.__data__,s,n)+"",a.has(l)?i[s]=c:a.set(l,c));for(s=0;s<h;++s)l=u.call(t,o[s],s,o)+"",(c=a.get(l))?(r[s]=c,c.__data__=o[s],a.delete(l)):e[s]=new g(t,o[s]);for(s=0;s<f;++s)(c=n[s])&&a.get(p[s])===c&&(i[s]=c)}function S(t){return t.__data__}function b(t){return"object"==typeof t&&"length"in t?t:Array.from(t)}function E(t,n){return t<n?-1:t>n?1:t>=n?0:NaN}function N(t){return function(){this.removeAttribute(t)}}function C(t){return function(){this.removeAttributeNS(t.space,t.local)}}function L(t,n){return function(){this.setAttribute(t,n)}}function T(t,n){return function(){this.setAttributeNS(t.space,t.local,n)}}function B(t,n){return function(){var e=n.apply(this,arguments);null==e?this.removeAttribute(t):this.setAttribute(t,e)}}function P(t,n){return function(){var e=n.apply(this,arguments);null==e?this.removeAttributeNS(t.space,t.local):this.setAttributeNS(t.space,t.local,e)}}function q(t){return t.ownerDocument&&t.ownerDocument.defaultView||t.document&&t||t.defaultView}function M(t){return function(){this.style.removeProperty(t)}}function D(t,n,e){return function(){this.style.setProperty(t,n,e)}}function V(t,n,e){return function(){var r=n.apply(this,arguments);null==r?this.style.removeProperty(t):this.style.setProperty(t,r,e)}}function O(t,n){return t.style.getPropertyValue(n)||q(t).getComputedStyle(t,null).getPropertyValue(n)}function R(t){return function(){delete this[t]}}function j(t,n){return function(){this[t]=n}}function H(t,n){return function(){var e=n.apply(this,arguments);null==e?delete this[t]:this[t]=e}}function I(t){return t.trim().split(/^|\s+/)}function U(t){return t.classList||new X(t)}function X(t){this._node=t,this._names=I(t.getAttribute("class")||"")}function G(t,n){for(var e=U(t),r=-1,i=n.length;++r<i;)e.add(n[r])}function Y(t,n){for(var e=U(t),r=-1,i=n.length;++r<i;)e.remove(n[r])}function k(t){return function(){G(this,t)}}function z(t){return function(){Y(this,t)}}function F(t,n){return function(){(n.apply(this,arguments)?G:Y)(this,t)}}function J(){this.textContent=""}function K(t){return function(){this.textContent=t}}function Q(t){return function(){var n=t.apply(this,arguments);this.textContent=null==n?"":n}}function W(){this.innerHTML=""}function Z(t){return function(){this.innerHTML=t}}function $(t){return function(){var n=t.apply(this,arguments);this.innerHTML=null==n?"":n}}function tt(){this.nextSibling&&this.parentNode.appendChild(this)}function nt(){this.previousSibling&&this.parentNode.insertBefore(this,this.parentNode.firstChild)}function et(){return null}function rt(){var t=this.parentNode;t&&t.removeChild(this)}function it(){var t=this.cloneNode(!1),n=this.parentNode;return n?n.insertBefore(t,this.nextSibling):t}function ot(){var t=this.cloneNode(!0),n=this.parentNode;return n?n.insertBefore(t,this.nextSibling):t}function ut(t){return t.trim().split(/^|\s+/).map((function(t){var n="",e=t.indexOf(".");return e>=0&&(n=t.slice(e+1),t=t.slice(0,e)),{type:t,name:n}}))}function st(t){return function(){var n=this.__on;if(n){for(var e,r=0,i=-1,o=n.length;r<o;++r)e=n[r],t.type&&e.type!==t.type||e.name!==t.name?n[++i]=e:this.removeEventListener(e.type,e.listener,e.options);++i?n.length=i:delete this.__on}}}function ct(t,n,e){return function(){var r,i=this.__on,o=function(t){return function(n){t.call(this,n,this.__data__)}}(n);if(i)for(var u=0,s=i.length;u<s;++u)if((r=i[u]).type===t.type&&r.name===t.name)return this.removeEventListener(r.type,r.listener,r.options),this.addEventListener(r.type,r.listener=o,r.options=e),void(r.value=n);this.addEventListener(t.type,o,e),r={type:t.type,name:t.name,value:n,listener:o,options:e},i?i.push(r):this.__on=[r]}}function lt(t,n,e){var r=q(t),i=r.CustomEvent;"function"==typeof i?i=new i(n,e):(i=r.document.createEvent("Event"),e?(i.initEvent(n,e.bubbles,e.cancelable),i.detail=e.detail):i.initEvent(n,!1,!1)),t.dispatchEvent(i)}function at(t,n){return function(){return lt(this,t,n)}}function ft(t,n){return function(){return lt(this,t,n.apply(this,arguments))}}g.prototype={constructor:g,appendChild:function(t){return this._parent.insertBefore(t,this._next)},insertBefore:function(t,n){return this._parent.insertBefore(t,n)},querySelector:function(t){return this._parent.querySelector(t)},querySelectorAll:function(t){return this._parent.querySelectorAll(t)}},X.prototype={add:function(t){this._names.indexOf(t)<0&&(this._names.push(t),this._node.setAttribute("class",this._names.join(" ")))},remove:function(t){var n=this._names.indexOf(t);n>=0&&(this._names.splice(n,1),this._node.setAttribute("class",this._names.join(" ")))},contains:function(t){return this._names.indexOf(t)>=0}};var ht=[null];function pt(t,n){this._groups=t,this._parents=n}function _t(){return new pt([[document.documentElement]],ht)}function dt(t){return"string"==typeof t?new pt([[document.querySelector(t)]],[document.documentElement]):new pt([[t]],ht)}pt.prototype=_t.prototype={constructor:pt,select:function(t){"function"!=typeof t&&(t=c(t));for(var n=this._groups,e=n.length,r=new Array(e),i=0;i<e;++i)for(var o,u,s=n[i],l=s.length,a=r[i]=new Array(l),f=0;f<l;++f)(o=s[f])&&(u=t.call(o,o.__data__,f,s))&&("__data__"in o&&(u.__data__=o.__data__),a[f]=u);return new pt(r,this._parents)},selectAll:function(t){t="function"==typeof t?function(t){return function(){return l(t.apply(this,arguments))}}(t):f(t);for(var n=this._groups,e=n.length,r=[],i=[],o=0;o<e;++o)for(var u,s=n[o],c=s.length,a=0;a<c;++a)(u=s[a])&&(r.push(t.call(u,u.__data__,a,s)),i.push(u));return new pt(r,i)},selectChild:function(t){return this.select(null==t?d:function(t){return function(){return _.call(this.children,t)}}("function"==typeof t?t:p(t)))},selectChildren:function(t){return this.selectAll(null==t?m:function(t){return function(){return y.call(this.children,t)}}("function"==typeof t?t:p(t)))},filter:function(t){"function"!=typeof t&&(t=h(t));for(var n=this._groups,e=n.length,r=new Array(e),i=0;i<e;++i)for(var o,u=n[i],s=u.length,c=r[i]=[],l=0;l<s;++l)(o=u[l])&&t.call(o,o.__data__,l,u)&&c.push(o);return new pt(r,this._parents)},data:function(t,n){if(!arguments.length)return Array.from(this,S);var e=n?x:A,r=this._parents,i=this._groups;"function"!=typeof t&&(t=w(t));for(var o=i.length,u=new Array(o),s=new Array(o),c=new Array(o),l=0;l<o;++l){var a=r[l],f=i[l],h=f.length,p=b(t.call(a,a&&a.__data__,l,r)),_=p.length,d=s[l]=new Array(_),y=u[l]=new Array(_),m=c[l]=new Array(h);e(a,f,d,y,m,p,n);for(var v,g,E=0,N=0;E<_;++E)if(v=d[E]){for(E>=N&&(N=E+1);!(g=y[N])&&++N<_;);v._next=g||null}}return(u=new pt(u,r))._enter=s,u._exit=c,u},enter:function(){return new pt(this._enter||this._groups.map(v),this._parents)},exit:function(){return new pt(this._exit||this._groups.map(v),this._parents)},join:function(t,n,e){var r=this.enter(),i=this,o=this.exit();return"function"==typeof t?(r=t(r))&&(r=r.selection()):r=r.append(t+""),null!=n&&(i=n(i))&&(i=i.selection()),null==e?o.remove():e(o),r&&i?r.merge(i).order():i},merge:function(t){for(var n=t.selection?t.selection():t,e=this._groups,r=n._groups,i=e.length,o=r.length,u=Math.min(i,o),s=new Array(i),c=0;c<u;++c)for(var l,a=e[c],f=r[c],h=a.length,p=s[c]=new Array(h),_=0;_<h;++_)(l=a[_]||f[_])&&(p[_]=l);for(;c<i;++c)s[c]=e[c];return new pt(s,this._parents)},selection:function(){return this},order:function(){for(var t=this._groups,n=-1,e=t.length;++n<e;)for(var r,i=t[n],o=i.length-1,u=i[o];--o>=0;)(r=i[o])&&(u&&4^r.compareDocumentPosition(u)&&u.parentNode.insertBefore(r,u),u=r);return this},sort:function(t){function n(n,e){return n&&e?t(n.__data__,e.__data__):!n-!e}t||(t=E);for(var e=this._groups,r=e.length,i=new Array(r),o=0;o<r;++o){for(var u,s=e[o],c=s.length,l=i[o]=new Array(c),a=0;a<c;++a)(u=s[a])&&(l[a]=u);l.sort(n)}return new pt(i,this._parents).order()},call:function(){var t=arguments[0];return arguments[0]=this,t.apply(null,arguments),this},nodes:function(){return Array.from(this)},node:function(){for(var t=this._groups,n=0,e=t.length;n<e;++n)for(var r=t[n],i=0,o=r.length;i<o;++i){var u=r[i];if(u)return u}return null},size:function(){let t=0;for(const n of this)++t;return t},empty:function(){return!this.node()},each:function(t){for(var n=this._groups,e=0,r=n.length;e<r;++e)for(var i,o=n[e],u=0,s=o.length;u<s;++u)(i=o[u])&&t.call(i,i.__data__,u,o);return this},attr:function(t,n){var e=r(t);if(arguments.length<2){var i=this.node();return e.local?i.getAttributeNS(e.space,e.local):i.getAttribute(e)}return this.each((null==n?e.local?C:N:"function"==typeof n?e.local?P:B:e.local?T:L)(e,n))},style:function(t,n,e){return arguments.length>1?this.each((null==n?M:"function"==typeof n?V:D)(t,n,null==e?"":e)):O(this.node(),t)},property:function(t,n){return arguments.length>1?this.each((null==n?R:"function"==typeof n?H:j)(t,n)):this.node()[t]},classed:function(t,n){var e=I(t+"");if(arguments.length<2){for(var r=U(this.node()),i=-1,o=e.length;++i<o;)if(!r.contains(e[i]))return!1;return!0}return this.each(("function"==typeof n?F:n?k:z)(e,n))},text:function(t){return arguments.length?this.each(null==t?J:("function"==typeof t?Q:K)(t)):this.node().textContent},html:function(t){return arguments.length?this.each(null==t?W:("function"==typeof t?$:Z)(t)):this.node().innerHTML},raise:function(){return this.each(tt)},lower:function(){return this.each(nt)},append:function(t){var n="function"==typeof t?t:u(t);return this.select((function(){return this.appendChild(n.apply(this,arguments))}))},insert:function(t,n){var e="function"==typeof t?t:u(t),r=null==n?et:"function"==typeof n?n:c(n);return this.select((function(){return this.insertBefore(e.apply(this,arguments),r.apply(this,arguments)||null)}))},remove:function(){return this.each(rt)},clone:function(t){return this.select(t?ot:it)},datum:function(t){return arguments.length?this.property("__data__",t):this.node().__data__},on:function(t,n,e){var r,i,o=ut(t+""),u=o.length;if(!(arguments.length<2)){for(s=n?ct:st,r=0;r<u;++r)this.each(s(o[r],n,e));return this}var s=this.node().__on;if(s)for(var c,l=0,a=s.length;l<a;++l)for(r=0,c=s[l];r<u;++r)if((i=o[r]).type===c.type&&i.name===c.name)return c.value},dispatch:function(t,n){return this.each(("function"==typeof n?ft:at)(t,n))},[Symbol.iterator]:function*(){for(var t=this._groups,n=0,e=t.length;n<e;++n)for(var r,i=t[n],o=0,u=i.length;o<u;++o)(r=i[o])&&(yield r)}};var yt=0;function mt(){return new vt}function vt(){this._="@"+(++yt).toString(36)}function gt(t){let n;for(;n=t.sourceEvent;)t=n;return t}function wt(t,n){if(t=gt(t),void 0===n&&(n=t.currentTarget),n){var e=n.ownerSVGElement||n;if(e.createSVGPoint){var r=e.createSVGPoint();return r.x=t.clientX,r.y=t.clientY,[(r=r.matrixTransform(n.getScreenCTM().inverse())).x,r.y]}if(n.getBoundingClientRect){var i=n.getBoundingClientRect();return[t.clientX-i.left-n.clientLeft,t.clientY-i.top-n.clientTop]}}return[t.pageX,t.pageY]}vt.prototype=mt.prototype={constructor:vt,get:function(t){for(var n=this._;!(n in t);)if(!(t=t.parentNode))return;return t[n]},set:function(t,n){return t[this._]=n},remove:function(t){return this._ in t&&delete t[this._]},toString:function(){return this._}},t.create=function(t){return dt(u(t).call(document.documentElement))},t.creator=u,t.local=mt,t.matcher=h,t.namespace=r,t.namespaces=e,t.pointer=wt,t.pointers=function(t,n){return t.target&&(t=gt(t),void 0===n&&(n=t.currentTarget),t=t.touches||[t]),Array.from(t,(t=>wt(t,n)))},t.select=dt,t.selectAll=function(t){return"string"==typeof t?new pt([document.querySelectorAll(t)],[document.documentElement]):new pt([l(t)],ht)},t.selection=_t,t.selector=c,t.selectorAll=f,t.style=O,t.window=q}));
</script>
<script src="following.js"></script>
<script src="followers.js"></script>
<script>
/* When to show the "How to" guide in the sidebar. Can be set to "always",
"never", or "sometimes". If "sometimes" is chosen, the guide will only be
shown if data is missing. */
const showHowTo = "sometimes";
</script>
<script>
/* Try to load data from the JS files referenced above. If they don't exist or
don't set the expected variables, fall back by using a null value. */
let followersData, followingData;
try { followersData = followers; } catch { followersData = null; }
try { followingData = following; } catch { followingData = null; }
</script>
</head>
<body>
<div>
<div class="sidebar">
<!-- Instructions on how to get data for the Javascript to load. Hidden
unless data is missing. -->
<aside id="how-to" style="display:none;">
<h2>How to load your tweeps</h2>
<ol>
<li>Get your data!
<ol>
<li>Visit the <a href="https://unflwrs.syfaro.com/"
target="_blank">unflwrs Twitter follower tracker</a> (opens in a
new tab).</li>
<li>Select the option to “download profile pictures”.</li>
<li>Select the option to “export json instead of csv”.</li>
<li>Click the button “friends & followers export”.</li>
<li>Twitter will ask if you want to authorize the application to
access your data. Click “Authorize app”.</li>
<li>Back on the tracker site, click “start”.</li>
<li>When prompted, save the zip file to your computer.</li>
</ol>
</li>
<li>Extract everything from the zip file. (On many operating systems,
double-clicking or “opening” the zip file will start the extraction
process.)</li>
<li>Save this HTML file into the same directory as your extracted data.</li>
<li id="how-to-list-followers">Prepare the list of <em>your followers</em>:
<ol>
<li>Use a text editor (<strong>not</strong> Microsoft Word) to open
the file “followers.json”.</li>
<li>Before the first bracket, paste this:
<pre><code>const followers = </code></pre></li>
<li>In your editor’s File menu, select “Save As...”</li>
<li>Save the copy to the same directory, with the name
“followers.js”. Make sure the editor doesn't try to tack “.json”
on at the end.</li>
</ol>
</li>
<li id="how-to-list-following">Prepare the list of <em>users you
follow</em>:
<ol>
<li>Use a text editor (<strong>not</strong> Microsoft Word) to open
the file “following.json”.</li>
<li>Before the first bracket, paste this:
<pre><code>const following = </code></pre></li>
<li>In your editor’s File menu, select “Save As...”</li>
<li>Save the copy to the same directory, with the name
“following.js”. Make sure the editor doesn’t try to tack “.json”
on at the end.</li>
</ol>
</li>
<li>Open this HTML file in your browser! This list will be hidden if the
expected data is available.</li>
</ol>
</aside>
</div>
<main>
<header>
<div id="header">
<h1>Maybe the Real Twitter Was the Friends We Made Along the Way</h1>
</div>
<nav id="list-nav">
<a href="#followers">Followers</a>
<a href="#following">Following</a>
</nav>
</header>
<section aria-labelledby="followers">
<h2 id="followers">Followers</h2>
<div id="list-followers" aria-label="Timeline: followers">
<!-- Javascript below will fill in follower users' info here. -->
</div>
</section>
<section aria-labelledby="following">
<h2 id="following">Following</h2>
<div id="list-following" aria-label="Timeline: following">
<!-- Javascript below will fill in following users' info here. -->
</div>
</section>
</main>
<aside id="shrine">
<p><a href="https://github.com/amclark42/tweep-shrine" target="_blank">Tweep
Shrine</a> by Ash C.</p>
</aside>
</div>
<!-- SVG icons -->
<div style="display: none;">
<div id="pin">
<svg xmlns="http://www.w3.org/2000/svg"
viewBox="0 0 24 24" aria-hidden="true">
<g><path d="M7 4.5C7 3.12 8.12 2 9.5 2h5C15.88 2 17 3.12 17 4.5v5.26L20.12 16H13v5l-1 2-1-2v-5H3.88L7 9.76V4.5z"></path></g>
</svg>
</div>
<div id="lock">
<svg xmlns="http://www.w3.org/2000/svg"
viewBox="0 0 24 24" aria-label="Protected account" role="img">
<g><path d="M17.5 7H17v-.25c0-2.76-2.24-5-5-5s-5 2.24-5 5V7h-.5C5.12 7 4 8.12 4 9.5v9C4 19.88 5.12 21 6.5 21h11c1.39 0 2.5-1.12 2.5-2.5v-9C20 8.12 18.89 7 17.5 7zM13 14.73V17h-2v-2.27c-.59-.34-1-.99-1-1.73 0-1.1.9-2 2-2 1.11 0 2 .9 2 2 0 .74-.4 1.39-1 1.73zM15 7H9v-.25c0-1.66 1.35-3 3-3 1.66 0 3 1.34 3 3V7z"></path></g>
</svg>
</div>
<div id="location">
<svg xmlns="http://www.w3.org/2000/svg"
viewBox="0 0 24 24" aria-label="User location" role="img">
<g><path d="M12 7c-1.93 0-3.5 1.57-3.5 3.5S10.07 14 12 14s3.5-1.57 3.5-3.5S13.93 7 12 7zm0 5c-.827 0-1.5-.673-1.5-1.5S11.173 9 12 9s1.5.673 1.5 1.5S12.827 12 12 12zm0-10c-4.687 0-8.5 3.813-8.5 8.5 0 5.967 7.621 11.116 7.945 11.332l.555.37.555-.37c.324-.216 7.945-5.365 7.945-11.332C20.5 5.813 16.687 2 12 2zm0 17.77c-1.665-1.241-6.5-5.196-6.5-9.27C5.5 6.916 8.416 4 12 4s6.5 2.916 6.5 6.5c0 4.073-4.835 8.028-6.5 9.27z"></path></g>
</svg>
</div>
<div id="link">
<svg xmlns="http://www.w3.org/2000/svg"
viewBox="0 0 24 24" aria-hidden="true">
<g><path d="M18.36 5.64c-1.95-1.96-5.11-1.96-7.07 0L9.88 7.05 8.46 5.64l1.42-1.42c2.73-2.73 7.16-2.73 9.9 0 2.73 2.74 2.73 7.17 0 9.9l-1.42 1.42-1.41-1.42 1.41-1.41c1.96-1.96 1.96-5.12 0-7.07zm-2.12 3.53l-7.07 7.07-1.41-1.41 7.07-7.07 1.41 1.41zm-12.02.71l1.42-1.42 1.41 1.42-1.41 1.41c-1.96 1.96-1.96 5.12 0 7.07 1.95 1.96 5.11 1.96 7.07 0l1.41-1.41 1.42 1.41-1.42 1.42c-2.73 2.73-7.16 2.73-9.9 0-2.73-2.74-2.73-7.17 0-9.9z"></path></g>
</svg>
</div>
<div id="calendar">
<svg xmlns="http://www.w3.org/2000/svg"
viewBox="0 0 24 24" aria-hidden="true">
<g><path d="M7 4V3h2v1h6V3h2v1h1.5C19.89 4 21 5.12 21 6.5v12c0 1.38-1.11 2.5-2.5 2.5h-13C4.12 21 3 19.88 3 18.5v-12C3 5.12 4.12 4 5.5 4H7zm0 2H5.5c-.27 0-.5.22-.5.5v12c0 .28.23.5.5.5h13c.28 0 .5-.22.5-.5v-12c0-.28-.22-.5-.5-.5H17v1h-2V6H9v1H7V6zm0 6h2v-2H7v2zm0 4h2v-2H7v2zm4-4h2v-2h-2v2zm0 4h2v-2h-2v2zm4-4h2v-2h-2v2z"></path></g>
</svg>
</div>
</div>
<script>
if ( showHowTo === 'always' ) {
d3.select('#how-to')
.style('display', null);
}
/* Gather SVG icons for programmatic reuse. */
const icons = {
'pin': document.getElementById('pin').children[0].outerHTML,
'lock': document.getElementById('lock').children[0].outerHTML,
'location': document.getElementById('location').children[0].outerHTML,
'link': document.getElementById('link').children[0].outerHTML,
'calendar': document.getElementById('calendar').children[0].outerHTML
};
/* Generate a string of HTML, given a plaintext string and an object of
complex entities (link fodder). */
const generateHtml = function(plaintext, entities) {
let htmlStr = '';
let strIndices = [];
if ( entities === undefined ) {
htmlStr = plaintext;
} else {
// Process all the links first.
for (const type in entities) {
// Skip annotations
if ( type !== 'annotations' ) {
// Links are constructed differently depending on the entity type.
let getUrl, getText;
switch (type) {
case 'urls':
getUrl = (o => o.expanded_url);
getText = (o => o.display_url);
break;
case 'hashtags':
getUrl = (o => 'https://twitter.com/hashtag/'+o.tag);
getText = (o => '#'+o.tag);
break;
case 'mentions':
getUrl = (o => 'https://twitter.com/'+o.username);
getText = (o => '@'+o.username);
break;
default:
console.log(type);
}
/* For each entity object of this type, note its string indices and generate
the link. */
for (const obj of entities[type] ) {
let strDesc = { 'start': obj.start, 'end': obj.end };
strDesc.html =
`<a href="${getUrl(obj)}" target="_blank">${getText(obj)}</a>`;
strIndices.push(strDesc);
}
}
}
// Sort the array of link entities so they appear in order of appearance.
strIndices.sort((v, u) => v.start - u.start);
/* The substring() function will mangle emoji, so instead we create an array of
all characters within the string, and use its indices when replacing
plaintext with functional links. */
let characters = Array.from(plaintext),
arrIndex = 0, strIndex = 0;
// Replace newlines with HTML breaks.
characters.forEach(
(char, i) => characters[i] = char.match(/\n/) ? "<br />" : char );
for (const obj of strIndices) {
if ( obj.start > strIndex ) {
htmlStr += characters.slice(strIndex, obj.start - 1).join('');
}
htmlStr += " " + obj.html;
strIndex = obj.end;
arrIndex++;
}
if ( strIndex !== characters.length - 1 ) {
htmlStr += characters.slice(strIndex).join('');
}
}
//console.log(htmlStr);
return htmlStr;
}; // END generateHtml()
/* If the current user has a pinned tweet, display it. */
const pinTweet = function(data) {
if ( data !== null ) {
let tweetEl = d3.select(this)
.classed('pinned-tweet', true);
tweetEl.append('h4')
.classed('heading', true)
.html(`${icons.pin} Pinned Tweet`);
tweetEl.append('div')
.classed('content', true)
.html(d => generateHtml(d.text, d.entities));
tweetEl.append('div')
.classed('pinned-tweet-link', true)
.append('a')
.attr('target', '_blank')
.text("View tweet");
}
}; // END pinTweet()
/* For the given user list, generate HTML for each person's data. */
const listUsers = function(tweepList, data) {
const listId = tweepList.attr('id');
// Function to generate an ID for a user section heading.
const setSectionId = function (d, i) {
return listId+'-u'+i;
};
// If there is no user data for this list, say so and exit the function.
if ( data === null && showHowTo === 'never' ) {
tweepList.append('p')
.text("No data found!");
return;
} else if ( data === null ) {
// If the "How to" guide is able to be shown, link to it.
d3.select('#how-to')
.style('display', null);
tweepList.append('p')
.html(`No data found! Check out the
<a href="#how-to-${listId}">instructions for loading this list</a>.`);
return;
}
let tweeps = tweepList.selectAll('section')
.data(data)
.join('section')
.attr('aria-labelledby', setSectionId)
.classed('user', true);
// Set up areas for each user.
// User info
tweeps.selectAll('div')
.data(d => d)
.join('div');
let tweepsAbout = tweeps.selectAll('div:first-child')
.classed('user-about', true);
let tweepsPinned = tweeps.selectAll('div:nth-child(2)');
// User info > Icon
tweepsAbout.call( function(selection) {
selection.append('div')
.classed('user-icon', true)
.append('a')
.attr('href', d => 'https://twitter.com/'+d.username)
.attr('aria-hidden', 'true')
.attr('tabindex', '-1')
.attr('target', '_blank')
.append('img')
.attr('src', d => 'profile_picture/'+d.username+'.jpg')
.attr('alt', '')
.attr('draggable', 'true');
})
// User info > Profile
.each( function(p) {
let profile = d3.select(this).append('div')
.classed('user-profile', true);
profile.append('h3')
//.attr('id', setSectionId)
.classed('user-name', true)
.append('a')
.attr('href', d => 'https://twitter.com/'+d.username)
.attr('target', '_blank')
.text(d => d.name+" ")
.append('span')
.classed('user-handle', true)
.text(d => '@'+d.username+" ")
.append('span')
.classed('user-protecc', true)
.html(d => d.protected ? icons.lock : '');
// User description
profile.append('p')
.classed('user-desc', true)
.html(d => generateHtml(d.description,
d.entities === undefined ? undefined : d.entities.description));
// User metadata
let metadata = profile.append('div')
.classed('user-metadata', true);
// Optional location
if ( p.location !== undefined ) {
metadata.append('span')
.classed('user-location', true)
.html(d => d.location === undefined ? '' :
icons.location + " " + d.location);
}
// Optional website URL
if ( p.entities !== undefined && p.entities.url !== undefined ) {
metadata.append('span')
.classed('user-link', true)
.html( function(d) {
if ( d.entities !== undefined && d.entities.url !== undefined ) {
const urlObj = d.entities.url.urls[0];
return icons.link + " " +
`<a href="${urlObj.expanded_url}"
target="_blank">${urlObj.display_url}</a>`;
}
});
}
// Twitter join date
metadata.append('span')
.classed('user-joined', true)
.html(d => icons.calendar + " Joined Twitter in "
+ d.created_at.substring(0, 4));
});
/* Add identifiers to user name headings in each section, so they can serve
as ARIA labels. Since the user's index is dependent on their place in the
list, the ID has to be generated using data at the "tweeps" level rather
than at the "tweepsAbout" level. */
tweeps.each( function(d, i) {
let uId = setSectionId(d, i);
d3.select(this)
.select('.user-name')
.attr('id', uId);
});
tweepsPinned.each(pinTweet);
tweeps.each( function(d, i) {
let url = 'https://twitter.com/'+d[0].username+'/status/'+d[0].pinned_tweet_id;
d3.select(this)
.select('.pinned-tweet-link a')
.attr('href', url);
});
}; // END listUsers()
</script>
<script>
/* Use the functions above to generate user lists. */
listUsers(d3.select('#list-followers'), followersData);
listUsers(d3.select('#list-following'), followingData);
</script>
</body>
</html>