-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathcitizen.html
More file actions
661 lines (618 loc) · 25.6 KB
/
Copy pathcitizen.html
File metadata and controls
661 lines (618 loc) · 25.6 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
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Character Sheet | Git Kingdom</title>
<meta name="robots" content="index, follow" />
<meta name="description" content="View this citizen's RPG character sheet on Git Kingdom — stats, badges, kingdoms, and repos all derived from real GitHub activity." />
<link rel="icon" href="/favicon.ico" />
<link rel="canonical" id="canonical-link" />
<!-- OG / Twitter (defaults, updated dynamically by JS) -->
<meta property="og:type" content="profile" />
<meta property="og:site_name" content="Git Kingdom" />
<meta property="og:title" id="og-title" content="Character Sheet | Git Kingdom" />
<meta property="og:description" id="og-desc" content="View this citizen's RPG character sheet — stats, badges, and kingdoms derived from real GitHub data." />
<meta property="og:image" id="og-image" content="https://www.gitkingdom.com/assets/og-image.jpg" />
<meta property="og:url" id="og-url" />
<meta name="twitter:card" content="summary_large_image" />
<meta name="twitter:title" id="tw-title" content="Character Sheet | Git Kingdom" />
<meta name="twitter:description" id="tw-desc" content="View this citizen's RPG character sheet — stats, badges, and kingdoms derived from real GitHub data." />
<meta name="twitter:image" id="tw-image" content="https://www.gitkingdom.com/assets/og-image.jpg" />
<link href="https://fonts.googleapis.com/css2?family=Silkscreen&display=swap" rel="stylesheet" />
<link href="/vendor/rpgui/rpgui.min.css" rel="stylesheet" />
<script src="/vendor/rpgui/rpgui.min.js"></script>
<style>
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
/* Blurred tiled town background */
body {
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
color: #e0d8b8;
line-height: 1.5;
min-height: 100vh;
background: #1a1508;
overflow-x: hidden;
}
.bg-layer {
position: fixed;
top: -20px; left: -20px; right: -20px; bottom: -20px;
background: url('/assets/town/town_B.png') repeat;
background-size: 512px;
filter: blur(6px) brightness(0.35);
z-index: 0;
}
.bg-overlay {
position: fixed;
top: 0; left: 0; right: 0; bottom: 0;
background: radial-gradient(ellipse at center, rgba(26,21,8,0.4) 0%, rgba(26,21,8,0.75) 100%);
z-index: 1;
}
/* Header bar */
.page-header {
position: relative;
z-index: 10;
background: linear-gradient(180deg, rgba(26,21,8,0.95), rgba(26,21,8,0.85));
border-bottom: 3px solid #8b6914;
padding: 12px 24px;
display: flex;
align-items: center;
justify-content: space-between;
backdrop-filter: blur(4px);
}
.page-header a { text-decoration: none; }
.logo {
font-family: 'Silkscreen', monospace;
color: #ffd700;
font-size: 18px;
letter-spacing: 2px;
text-shadow: 0 0 10px rgba(255,215,0,0.3);
}
.logo span {
background: #8b6914;
color: #fff;
padding: 2px 6px;
border-radius: 3px;
font-size: 9px;
margin-left: 8px;
letter-spacing: 1px;
}
.back-link {
font-family: 'Silkscreen', monospace;
color: #c0a870;
text-decoration: none;
font-size: 11px;
letter-spacing: 1px;
}
.back-link:hover { color: #ffd700; }
/* Sheet container */
.sheet-wrap {
position: relative;
z-index: 10;
max-width: 820px;
margin: 32px auto;
padding: 0 20px 100px;
}
.sheet.rpgui-container.framed-golden {
position: relative !important;
display: block !important;
width: auto !important;
padding: 0 !important;
overflow: hidden;
}
/* Header section */
.cs-header {
display: flex;
align-items: center;
gap: 18px;
padding: 24px 28px;
background: linear-gradient(180deg, rgba(139,105,20,0.15) 0%, transparent 100%);
border-bottom: 1px solid #3a3020;
position: relative;
}
.cs-avatar {
width: 80px;
height: 80px;
border-radius: 50%;
border: 3px solid #8b6914;
box-shadow: 0 0 16px rgba(255,215,0,0.2);
}
.cs-identity { flex: 1; min-width: 0; }
.cs-login {
font-family: 'Silkscreen', monospace;
font-size: 20px;
color: #ffd700;
letter-spacing: 1px;
}
.cs-title {
font-size: 15px;
color: #f0e8cc;
margin-top: 3px;
}
.cs-level {
font-family: 'Silkscreen', monospace;
font-size: 12px;
color: #d0c090;
margin-top: 4px;
letter-spacing: 1px;
}
.cs-contribs {
font-size: 13px;
color: #b8a878;
margin-top: 2px;
}
/* Sections */
.cs-section {
padding: 16px 28px;
border-bottom: 1px solid #2a2418;
}
.cs-section:last-child { border-bottom: none; }
.cs-section-title {
font-family: 'Silkscreen', monospace;
font-size: 11px;
color: #f0e8cc;
letter-spacing: 2px;
text-transform: uppercase;
margin-bottom: 10px;
}
/* Badges */
.cs-badges {
display: flex;
flex-wrap: wrap;
gap: 6px;
}
.cs-badge {
display: inline-flex;
align-items: center;
gap: 4px;
background: rgba(139,105,20,0.2);
border: 1px solid #4a3a18;
border-radius: 12px;
padding: 4px 12px 4px 7px;
font-size: 13px;
color: #e0d8b8;
cursor: help;
position: relative;
}
.cs-badge[data-tip]:hover::after {
content: attr(data-tip);
position: absolute;
bottom: calc(100% + 6px);
left: 50%;
transform: translateX(-50%);
background: #1a1508;
color: #e8dbb0;
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
font-size: 11px;
padding: 5px 10px;
border-radius: 4px;
border: 1px solid #5a4a20;
white-space: nowrap;
z-index: 400;
pointer-events: none;
box-shadow: 0 2px 8px rgba(0,0,0,0.5);
}
.cs-badge-icon { font-size: 15px; }
/* Stats */
.cs-stat-row {
display: flex;
align-items: center;
gap: 10px;
margin-bottom: 8px;
}
.cs-stat-label {
font-family: 'Silkscreen', monospace;
font-size: 11px;
color: #d0b878;
width: 130px;
letter-spacing: 0.5px;
white-space: nowrap;
}
.cs-stat-bar {
flex: 1;
height: 14px;
background: rgba(255,255,255,0.06);
border-radius: 7px;
overflow: hidden;
}
.cs-stat-fill {
height: 100%;
border-radius: 7px;
transition: width 0.6s ease-out;
}
.cs-stat-fill.power { background: linear-gradient(90deg, #c07818, #e8a020); }
.cs-stat-fill.reach { background: linear-gradient(90deg, #b8860b, #ffd700); }
.cs-stat-fill.versatility { background: linear-gradient(90deg, #2e8b57, #3cb371); }
.cs-stat-val {
font-family: 'Silkscreen', monospace;
font-size: 12px;
color: #e0d0a0;
width: 26px;
text-align: right;
}
/* Kingdoms */
.cs-kingdoms {
display: flex;
flex-wrap: wrap;
gap: 6px;
}
.cs-kingdom {
font-family: 'Silkscreen', monospace;
font-size: 11px;
color: #dcc480;
background: rgba(255,255,255,0.06);
border: 1px solid #4a3a20;
border-radius: 4px;
padding: 3px 10px;
letter-spacing: 1px;
}
/* Repos / Inventory */
.cs-repos-scroll {
max-height: 360px;
overflow-y: auto;
scrollbar-width: thin;
scrollbar-color: #5a4a20 transparent;
}
.cs-repos-scroll::-webkit-scrollbar { width: 6px; }
.cs-repos-scroll::-webkit-scrollbar-track { background: transparent; }
.cs-repos-scroll::-webkit-scrollbar-thumb { background: #5a4a20; border-radius: 3px; }
.cs-repo {
display: flex;
align-items: center;
gap: 8px;
padding: 6px 0;
border-bottom: 1px solid rgba(255,255,255,0.04);
font-size: 13px;
}
.cs-repo:last-child { border-bottom: none; }
.cs-repo-icon { font-size: 15px; width: 22px; text-align: center; }
.cs-repo-name {
flex: 1;
min-width: 0;
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
}
.cs-repo-name a { color: #dcc480; text-decoration: none; }
.cs-repo-name a:hover { color: #ffd700; text-decoration: underline; }
.cs-repo-meta {
font-size: 11px;
color: #a09068;
white-space: nowrap;
display: flex;
gap: 8px;
}
.cs-repo-stars { color: #ffd700; }
.cs-repo-king { color: #ffd700; }
/* Footer actions + social share */
.cs-actions {
display: flex;
gap: 10px;
padding: 16px 28px;
justify-content: center;
flex-wrap: wrap;
}
.cs-btn {
font-family: 'Silkscreen', monospace;
font-size: 10px;
letter-spacing: 1px;
text-decoration: none;
padding: 8px 16px;
border-radius: 4px;
border: 1px solid #6a5a28;
color: #dcc480;
background: rgba(255,255,255,0.04);
cursor: pointer;
transition: all 0.2s;
display: inline-flex;
align-items: center;
gap: 5px;
}
.cs-btn:hover { background: rgba(139,105,20,0.2); color: #ffd700; border-color: #8b6914; }
.cs-btn.primary {
background: linear-gradient(180deg, #e8a020, #c07818);
color: #1a1508;
border: none;
font-weight: bold;
}
.cs-btn.primary:hover { transform: scale(1.03); }
.cs-btn svg { width: 14px; height: 14px; fill: currentColor; vertical-align: middle; }
/* Share icons — top-right of header */
.cs-share-icons {
position: absolute;
top: 12px;
right: 16px;
display: flex;
gap: 6px;
}
.cs-share-icon {
display: flex;
align-items: center;
justify-content: center;
width: 28px;
height: 28px;
border-radius: 50%;
border: 1px solid rgba(255,255,255,0.1);
color: #a09068;
background: rgba(0,0,0,0.15);
cursor: pointer;
transition: all 0.2s;
text-decoration: none;
}
.cs-share-icon:hover { color: #ffd700; background: rgba(139,105,20,0.3); border-color: #8b6914; }
.cs-share-icon svg { width: 14px; height: 14px; fill: currentColor; }
/* Loading / error */
.loading { text-align: center; padding: 64px; color: #b0a070; font-size: 14px; }
.error { text-align: center; padding: 64px; color: #c04040; font-size: 14px; }
.error a { color: #ffd700; text-decoration: none; }
/* Floating bar */
.floating-bar {
position: fixed;
bottom: 0;
left: 0;
right: 0;
background: linear-gradient(180deg, rgba(26,21,8,0.95), rgba(26,21,8,0.98));
border-top: 2px solid #8b6914;
padding: 10px 24px;
display: flex;
align-items: center;
justify-content: space-between;
z-index: 100;
backdrop-filter: blur(8px);
-webkit-backdrop-filter: blur(8px);
}
.floating-bar .bar-copy { font-size: 10px; color: #a09068; white-space: nowrap; }
.floating-bar .bar-copy a { font-size: inherit; color: #c0a870; }
.floating-bar .bar-links { display: flex; align-items: center; gap: 20px; }
.floating-bar a {
font-family: 'Silkscreen', monospace;
color: #a89060;
text-decoration: none;
font-size: 10px;
letter-spacing: 1px;
transition: color 0.2s;
}
.floating-bar a:hover { color: #ffd700; }
.floating-bar .bar-cta {
background: linear-gradient(180deg, #e8a020, #c07818);
color: #1a1508;
padding: 6px 16px;
border-radius: 4px;
font-weight: bold;
}
.floating-bar .bar-cta:hover { color: #1a1508; }
@media (max-width: 600px) {
.cs-header { flex-direction: column; text-align: center; padding: 16px; }
.cs-avatar { width: 64px; height: 64px; }
.cs-stat-label { width: 100px; font-size: 10px; }
.cs-section { padding: 14px 16px; }
.cs-actions { padding: 14px 16px; }
.floating-bar { flex-direction: column; gap: 8px; padding: 8px 16px; }
}
</style>
</head>
<body>
<div class="bg-layer"></div>
<div class="bg-overlay"></div>
<header class="page-header">
<a href="/"><div class="logo">GIT KINGDOM <span>CHARACTER SHEET</span></div></a>
<a href="/" class="back-link">← Back to Kingdom</a>
</header>
<div class="sheet-wrap">
<div id="sheet">
<div class="rpgui-container framed-golden" style="padding:0">
<div class="loading">Summoning citizen...</div>
</div>
</div>
</div>
<div class="floating-bar">
<div class="bar-copy">© 2026 GitKingdom. Created by <a href="https://github.com/rgourley">Rob Gourley</a></div>
<div class="bar-links">
<a href="/about">About</a>
<a href="/how-it-works">How It Works</a>
<a href="/" class="bar-cta">Play</a>
</div>
</div>
<script>
(function() {
var el = document.getElementById('sheet');
var BADGE_TIPS = {
titan: '1,000+ total contributions',
centurion: '100+ total contributions',
crown: 'Top contributor to at least one repo',
founder: 'Owns a repo in the kingdom',
on_fire: 'Contributed to a repo pushed in the last 3 days',
polyglot: 'Contributes across 3+ languages',
star_bearer: '1,000+ total stars across repos',
team_player: 'Contributes to 5+ repos',
lone_wolf: 'Contributes to exactly 1 repo',
};
function repoIcon(stars) {
if (stars >= 10000) return '\u{1F5E1}';
if (stars >= 1000) return '\u{1F6E1}';
if (stars >= 100) return '\u2694';
if (stars >= 10) return '\u{1F4DC}';
return '\u2697';
}
function esc(s) {
return String(s || '').replace(/&/g, '&').replace(/</g, '<')
.replace(/>/g, '>').replace(/"/g, '"');
}
function fmtNum(n) {
if (n >= 1000000) return (n / 1000000).toFixed(1) + 'M';
if (n >= 1000) return (n / 1000).toFixed(1) + 'K';
return String(n);
}
// Set OG/SEO meta dynamically
function setMeta(d) {
var title = d.login + ' — ' + d.title.name + ' of ' + d.title.kingdom + ' | Git Kingdom';
var desc = d.title.icon + ' Level ' + d.level + ' ' + d.title.name + ' with ' + d.totalContributions.toLocaleString() + ' contributions across ' + d.repos.length + ' repos. Badges: ' + d.badges.map(function(b) { return b.label; }).join(', ') + '.';
var ogImage = 'https://www.gitkingdom.com/api/citizen-og?username=' + encodeURIComponent(d.login);
var url = window.location.href;
document.title = title;
// Update meta tags
var m = function(id, val) { var e = document.getElementById(id); if (e) e.setAttribute('content', val); };
m('og-title', title);
m('og-desc', desc);
m('og-image', ogImage);
m('og-url', url);
m('tw-title', title);
m('tw-desc', desc);
m('tw-image', ogImage);
// Set canonical
var canon = document.getElementById('canonical-link');
if (canon) canon.setAttribute('href', url);
// Add structured data
var ld = document.createElement('script');
ld.type = 'application/ld+json';
ld.textContent = JSON.stringify({
'@context': 'https://schema.org',
'@type': 'ProfilePage',
name: title,
description: desc,
url: url,
mainEntity: {
'@type': 'Person',
name: d.login,
image: d.avatar_url || ('https://github.com/' + d.login + '.png?size=400'),
url: 'https://github.com/' + d.login,
},
});
document.head.appendChild(ld);
}
// Build social share URLs
function shareIcons(d) {
var url = encodeURIComponent(window.location.href);
var text = encodeURIComponent(d.title.icon + ' ' + d.login + ' is a Level ' + d.level + ' ' + d.title.name + ' of ' + d.title.kingdom + ' in Git Kingdom!');
var h = '<div class="cs-share-icons">';
h += '<a class="cs-share-icon" title="Share on Twitter" href="https://twitter.com/intent/tweet?text=' + text + '&url=' + url + '" target="_blank" rel="noopener"><svg viewBox="0 0 24 24"><path d="M18.244 2.25h3.308l-7.227 8.26 8.502 11.24H16.17l-5.214-6.817L4.99 21.75H1.68l7.73-8.835L1.254 2.25H8.08l4.713 6.231zm-1.161 17.52h1.833L7.084 4.126H5.117z"/></svg></a>';
h += '<a class="cs-share-icon" title="Share on Facebook" href="https://www.facebook.com/sharer/sharer.php?u=' + url + '" target="_blank" rel="noopener"><svg viewBox="0 0 24 24"><path d="M24 12.073c0-6.627-5.373-12-12-12s-12 5.373-12 12c0 5.99 4.388 10.954 10.125 11.854v-8.385H7.078v-3.47h3.047V9.43c0-3.007 1.792-4.669 4.533-4.669 1.312 0 2.686.235 2.686.235v2.953H15.83c-1.491 0-1.956.925-1.956 1.874v2.25h3.328l-.532 3.47h-2.796v8.385C19.612 23.027 24 18.062 24 12.073z"/></svg></a>';
h += '<a class="cs-share-icon" title="Share on LinkedIn" href="https://www.linkedin.com/sharing/share-offsite/?url=' + url + '" target="_blank" rel="noopener"><svg viewBox="0 0 24 24"><path d="M20.447 20.452h-3.554v-5.569c0-1.328-.027-3.037-1.852-3.037-1.853 0-2.136 1.445-2.136 2.939v5.667H9.351V9h3.414v1.561h.046c.477-.9 1.637-1.85 3.37-1.85 3.601 0 4.267 2.37 4.267 5.455v6.286zM5.337 7.433c-1.144 0-2.063-.926-2.063-2.065 0-1.138.92-2.063 2.063-2.063 1.14 0 2.064.925 2.064 2.063 0 1.139-.925 2.065-2.064 2.065zm1.782 13.019H3.555V9h3.564v11.452zM22.225 0H1.771C.792 0 0 .774 0 1.729v20.542C0 23.227.792 24 1.771 24h20.451C23.2 24 24 23.227 24 22.271V1.729C24 .774 23.2 0 22.222 0h.003z"/></svg></a>';
h += '<a class="cs-share-icon" title="Share on Reddit" href="https://reddit.com/submit?url=' + url + '&title=' + text + '" target="_blank" rel="noopener"><svg viewBox="0 0 24 24"><path d="M12 0A12 12 0 0 0 0 12a12 12 0 0 0 12 12 12 12 0 0 0 12-12A12 12 0 0 0 12 0zm5.01 4.744c.688 0 1.25.561 1.25 1.249a1.25 1.25 0 0 1-2.498.056l-2.597-.547-.8 3.747c1.824.07 3.48.632 4.674 1.488.308-.309.73-.491 1.207-.491.968 0 1.754.786 1.754 1.754 0 .716-.435 1.333-1.01 1.614a3.111 3.111 0 0 1 .042.52c0 2.694-3.13 4.87-7.004 4.87-3.874 0-7.004-2.176-7.004-4.87 0-.183.015-.366.043-.534A1.748 1.748 0 0 1 4.028 12c0-.968.786-1.754 1.754-1.754.463 0 .898.196 1.207.49 1.207-.883 2.878-1.43 4.744-1.487l.885-4.182a.342.342 0 0 1 .14-.197.35.35 0 0 1 .238-.042l2.906.617a1.214 1.214 0 0 1 1.108-.701zM9.25 12C8.561 12 8 12.562 8 13.25c0 .687.561 1.248 1.25 1.248.687 0 1.248-.561 1.248-1.249 0-.688-.561-1.249-1.249-1.249zm5.5 0c-.687 0-1.248.561-1.248 1.25 0 .687.561 1.248 1.249 1.248.688 0 1.249-.561 1.249-1.249 0-.687-.562-1.249-1.25-1.249zm-5.466 3.99a.327.327 0 0 0-.231.094.33.33 0 0 0 0 .463c.842.842 2.484.913 2.961.913.477 0 2.105-.056 2.961-.913a.361.361 0 0 0 .029-.463.33.33 0 0 0-.464 0c-.547.533-1.684.73-2.512.73-.828 0-1.979-.196-2.512-.73a.326.326 0 0 0-.232-.095z"/></svg></a>';
h += '<button class="cs-share-icon" title="Copy link" id="cs-copy-btn"><svg viewBox="0 0 24 24"><path d="M16 1H4c-1.1 0-2 .9-2 2v14h2V3h12V1zm3 4H8c-1.1 0-2 .9-2 2v14c0 1.1.9 2 2 2h11c1.1 0 2-.9 2-2V7c0-1.1-.9-2-2-2zm0 16H8V7h11v14z"/></svg></button>';
h += '</div>';
return h;
}
var path = window.location.pathname;
var parts = path.split('/').filter(Boolean);
var username = parts.length >= 2 ? parts[1] : null;
if (!username) {
el.innerHTML = '<div class="rpgui-container framed-golden" style="padding:0"><div class="error">No citizen specified. <a href="/">Return to Kingdom</a></div></div>';
return;
}
document.title = username + ' | Character Sheet | Git Kingdom';
fetch('/api/citizen?username=' + encodeURIComponent(username))
.then(function(res) {
if (res.status === 404) throw new Error('not_found');
if (!res.ok) throw new Error('fail');
return res.json();
})
.then(function(d) {
// Update OG/SEO meta
setMeta(d);
var html = '<div class="sheet rpgui-container framed-golden">';
// Header
html += '<div class="cs-header">';
html += '<img class="cs-avatar" src="https://github.com/' + esc(d.login) + '.png?size=160" alt="" />';
html += '<div class="cs-identity">';
html += '<div class="cs-login">' + esc(d.title.icon) + ' ' + esc(d.login) + '</div>';
html += '<div class="cs-title">' + esc(d.title.name) + ' of ' + esc(d.title.kingdom) + '</div>';
html += '<div class="cs-level">Level ' + d.level + ' \u00b7 ' + fmtNum(d.xp) + ' XP</div>';
html += '<div class="cs-contribs">' + d.totalContributions.toLocaleString() + ' contributions across ' + d.repos.length + ' repos</div>';
html += '</div>';
html += shareIcons(d);
html += '</div>';
// Badges
if (d.badges.length > 0) {
html += '<div class="cs-section">';
html += '<div class="cs-section-title">Badges</div>';
html += '<div class="cs-badges">';
for (var i = 0; i < d.badges.length; i++) {
var b = d.badges[i];
var tip = BADGE_TIPS[b.id] || '';
html += '<span class="cs-badge" data-tip="' + esc(tip) + '"><span class="cs-badge-icon">' + esc(b.icon) + '</span> ' + esc(b.label) + '</span>';
}
html += '</div></div>';
}
// Stats
html += '<div class="cs-section">';
html += '<div class="cs-section-title">Stats</div>';
var stats = [
{ key: 'power', label: '\u2694 Power', value: d.stats.power },
{ key: 'reach', label: '\u2B50 Reach', value: d.stats.reach },
{ key: 'versatility', label: '\uD83C\uDF10 Versatility', value: d.stats.versatility },
];
for (var si = 0; si < stats.length; si++) {
var st = stats[si];
var pct = (st.value / 20 * 100).toFixed(0);
html += '<div class="cs-stat-row">';
html += '<span class="cs-stat-label">' + st.label + '</span>';
html += '<div class="cs-stat-bar"><div class="cs-stat-fill ' + st.key + '" style="width:' + pct + '%"></div></div>';
html += '<span class="cs-stat-val">' + st.value + '</span>';
html += '</div>';
}
html += '</div>';
// Kingdoms
if (d.languages.length > 0) {
html += '<div class="cs-section">';
html += '<div class="cs-section-title">Kingdoms</div>';
html += '<div class="cs-kingdoms">';
for (var li = 0; li < d.languages.length; li++) {
html += '<span class="cs-kingdom">' + esc(d.languages[li]) + '</span>';
}
html += '</div></div>';
}
// Inventory (repos) — max 5
if (d.repos.length > 0) {
var shown = d.repos.slice(0, 5);
html += '<div class="cs-section">';
html += '<div class="cs-section-title">Inventory (' + d.repos.length + ' repos)</div>';
for (var ri = 0; ri < shown.length; ri++) {
var r = shown[ri];
html += '<div class="cs-repo">';
html += '<span class="cs-repo-icon">' + repoIcon(r.stargazers) + '</span>';
html += '<span class="cs-repo-name"><a href="https://github.com/' + esc(r.full_name) + '" target="_blank">' + esc(r.full_name) + '</a></span>';
html += '<span class="cs-repo-meta">';
if (r.is_king) html += '<span class="cs-repo-king">\uD83D\uDC51</span>';
html += '<span class="cs-repo-stars">\u2605' + fmtNum(r.stargazers) + '</span>';
if (r.language) html += '<span>' + esc(r.language) + '</span>';
html += '</span>';
html += '</div>';
}
if (d.repos.length > 5) {
html += '<div style="text-align:center;margin-top:8px"><a href="https://github.com/' + esc(d.login) + '?tab=repositories" target="_blank" style="color:#b0a070;font-size:11px;text-decoration:none">View all ' + d.repos.length + ' repos on GitHub \u2192</a></div>';
}
html += '</div>';
}
// Actions
html += '<div class="cs-actions">';
html += '<a href="https://github.com/' + esc(d.login) + '" target="_blank" class="cs-btn primary">View on GitHub</a>';
html += '</div>';
html += '</div>'; // .sheet
el.innerHTML = html;
// Wire copy link button
var copyBtn = document.getElementById('cs-copy-btn');
if (copyBtn) {
copyBtn.addEventListener('click', function() {
var url = window.location.href;
if (navigator.clipboard) {
navigator.clipboard.writeText(url).then(function() {
copyBtn.innerHTML = '<svg viewBox="0 0 24 24"><path d="M9 16.17L4.83 12l-1.42 1.41L9 19 21 7l-1.41-1.41z"/></svg> Copied!';
setTimeout(function() {
copyBtn.innerHTML = '<svg viewBox="0 0 24 24"><path d="M16 1H4c-1.1 0-2 .9-2 2v14h2V3h12V1zm3 4H8c-1.1 0-2 .9-2 2v14c0 1.1.9 2 2 2h11c1.1 0 2-.9 2-2V7c0-1.1-.9-2-2-2zm0 16H8V7h11v14z"/></svg> Copy Link';
}, 2000);
});
}
});
}
})
.catch(function(err) {
if (err.message === 'not_found') {
el.innerHTML = '<div class="rpgui-container framed-golden" style="padding:0"><div class="error">Citizen "' + esc(username) + '" not found in the kingdom.<br><br><a href="/">Return to Kingdom</a></div></div>';
} else {
el.innerHTML = '<div class="rpgui-container framed-golden" style="padding:0"><div class="error">Failed to load character sheet.<br><br><a href="/">Return to Kingdom</a></div></div>';
}
});
})();
</script>
</body>
</html>