git-retro 0.2.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- git_retro/__init__.py +2 -0
- git_retro/__main__.py +5 -0
- git_retro/cli.py +112 -0
- git_retro/core.py +388 -0
- git_retro/demo.py +72 -0
- git_retro/fonts/OFL-BricolageGrotesque.txt +93 -0
- git_retro/fonts/OFL-JetBrainsMono.txt +93 -0
- git_retro/fonts/display-800.woff2 +0 -0
- git_retro/fonts/mono-600.woff2 +0 -0
- git_retro/fonts/text-500.woff2 +0 -0
- git_retro/render.py +16 -0
- git_retro/template.html +810 -0
- git_retro-0.2.0.dist-info/METADATA +166 -0
- git_retro-0.2.0.dist-info/RECORD +20 -0
- git_retro-0.2.0.dist-info/WHEEL +5 -0
- git_retro-0.2.0.dist-info/entry_points.txt +2 -0
- git_retro-0.2.0.dist-info/licenses/LICENSE +21 -0
- git_retro-0.2.0.dist-info/licenses/git_retro/fonts/OFL-BricolageGrotesque.txt +93 -0
- git_retro-0.2.0.dist-info/licenses/git_retro/fonts/OFL-JetBrainsMono.txt +93 -0
- git_retro-0.2.0.dist-info/top_level.txt +1 -0
git_retro/template.html
ADDED
|
@@ -0,0 +1,810 @@
|
|
|
1
|
+
<!doctype html>
|
|
2
|
+
<html lang="pt-BR">
|
|
3
|
+
<head>
|
|
4
|
+
<meta charset="utf-8">
|
|
5
|
+
<meta name="viewport" content="width=device-width, initial-scale=1, viewport-fit=cover">
|
|
6
|
+
<meta name="theme-color" content="#0E0E11">
|
|
7
|
+
<title>git retro</title>
|
|
8
|
+
<style>
|
|
9
|
+
/* Formato: stories (9:16) com um slide por estatística, cada um com a sua cor.
|
|
10
|
+
Fontes embutidas (Bricolage Grotesque e JetBrains Mono, OFL): a página abre offline, igual em qualquer sistema. */
|
|
11
|
+
@font-face{font-family:"Retro";font-weight:800;font-display:block;src:url(data:font/woff2;base64,/*FONT:display-800*/) format("woff2")}
|
|
12
|
+
@font-face{font-family:"Retro";font-weight:500;font-display:block;src:url(data:font/woff2;base64,/*FONT:text-500*/) format("woff2")}
|
|
13
|
+
@font-face{font-family:"RetroMono";font-weight:600;font-display:block;src:url(data:font/woff2;base64,/*FONT:mono-600*/) format("woff2")}
|
|
14
|
+
:root{
|
|
15
|
+
--ink:#0E0E11;--paper:#F4F0E6;--lime:#C6FF3D;--violet:#6C4CF5;--orange:#FF5A1F;--blue:#1E3BFF;--pink:#FF8AD0;
|
|
16
|
+
--sans:"Retro",ui-sans-serif,system-ui,-apple-system,"Segoe UI",Roboto,"Helvetica Neue",Arial,sans-serif;
|
|
17
|
+
--mono:"RetroMono",ui-monospace,"SF Mono","Cascadia Code",Menlo,Consolas,monospace;
|
|
18
|
+
--ease:cubic-bezier(.16,1,.3,1);
|
|
19
|
+
}
|
|
20
|
+
*{box-sizing:border-box;margin:0;padding:0}
|
|
21
|
+
html,body{height:100%;background:var(--ink);color:var(--paper);font-family:var(--sans);overflow:hidden;-webkit-tap-highlight-color:transparent}
|
|
22
|
+
body{display:grid;place-items:center;user-select:none;-webkit-user-select:none}
|
|
23
|
+
.stage{position:relative;width:min(100vw,calc(100dvh * 9 / 16));height:min(100dvh,calc(100vw * 16 / 9));overflow:hidden;
|
|
24
|
+
container-type:size;background:var(--ink)}
|
|
25
|
+
@media (min-width:700px){.stage{height:min(92dvh,900px);width:calc(min(92dvh,900px) * 9 / 16);border-radius:22px;box-shadow:0 30px 120px rgba(0,0,0,.6),0 0 0 1px rgba(255,255,255,.06)}}
|
|
26
|
+
.help{position:fixed;bottom:18px;left:50%;translate:-50% 0;font:500 12px/1 var(--mono);color:rgba(244,240,230,.4);letter-spacing:.04em}
|
|
27
|
+
@media (max-width:699px){.help{display:none}}
|
|
28
|
+
|
|
29
|
+
.bars{position:absolute;top:10px;left:10px;right:10px;display:flex;gap:4px;z-index:20}
|
|
30
|
+
.bars i{flex:1;height:3px;border-radius:2px;background:color-mix(in srgb,var(--fg) 25%,transparent);overflow:hidden}
|
|
31
|
+
.bars i b{display:block;height:100%;width:100%;background:var(--fg);transform:scaleX(0);transform-origin:left}
|
|
32
|
+
.bars i.done b{transform:scaleX(1)}
|
|
33
|
+
.top{position:absolute;top:24px;left:16px;right:16px;display:flex;justify-content:space-between;align-items:center;z-index:20;
|
|
34
|
+
font:600 3.1cqw/1 var(--mono);letter-spacing:.06em;text-transform:uppercase;color:var(--fg)}
|
|
35
|
+
.top button{all:unset;cursor:pointer;padding:6px 8px;margin:-6px -8px;font:inherit}
|
|
36
|
+
|
|
37
|
+
.slide{position:absolute;inset:0;padding:19cqw 7cqw 10cqw;display:flex;flex-direction:column;justify-content:center;gap:3cqw;
|
|
38
|
+
background:var(--bg);color:var(--fg);opacity:0;visibility:hidden;transition:opacity .35s,visibility 0s .35s}
|
|
39
|
+
.slide.on{opacity:1;visibility:visible;transition:opacity .35s}
|
|
40
|
+
.th-ink{--bg:var(--ink);--fg:var(--paper);--ac:var(--lime)}
|
|
41
|
+
.th-lime{--bg:var(--lime);--fg:var(--ink);--ac:var(--ink)}
|
|
42
|
+
.th-violet{--bg:var(--violet);--fg:#fff;--ac:var(--lime)}
|
|
43
|
+
.th-orange{--bg:var(--orange);--fg:#fff;--ac:var(--ink)}
|
|
44
|
+
.th-blue{--bg:var(--blue);--fg:#fff;--ac:var(--lime)}
|
|
45
|
+
.th-pink{--bg:var(--pink);--fg:var(--ink);--ac:var(--ink)}
|
|
46
|
+
.th-paper{--bg:var(--paper);--fg:var(--ink);--ac:var(--orange)}
|
|
47
|
+
.stage{--fg:var(--paper)}
|
|
48
|
+
|
|
49
|
+
.k{font:600 3.3cqw/1.2 var(--mono);letter-spacing:.08em;text-transform:uppercase;opacity:.75}
|
|
50
|
+
.h{font-weight:800;font-size:9.5cqw;line-height:.95;letter-spacing:-.035em}
|
|
51
|
+
.huge{font-weight:800;font-size:27cqw;line-height:.82;letter-spacing:-.06em;color:var(--ac);font-variant-numeric:tabular-nums}
|
|
52
|
+
.big{font-weight:800;font-size:16cqw;line-height:.86;letter-spacing:-.05em;font-variant-numeric:tabular-nums}
|
|
53
|
+
.p{font-size:4.6cqw;line-height:1.35;font-weight:500;max-width:34ch}
|
|
54
|
+
.p b{font-weight:800}
|
|
55
|
+
.cmp{display:grid;gap:3.2cqw}
|
|
56
|
+
.cmp .r{display:grid;grid-template-columns:1fr auto;align-items:baseline;gap:0 3cqw;border-top:1px solid color-mix(in srgb,var(--fg) 25%,transparent);padding-top:2.6cqw}
|
|
57
|
+
.cmp .l{font:600 3.1cqw/1.2 var(--mono);text-transform:uppercase;letter-spacing:.06em;opacity:.8;grid-column:1/-1}
|
|
58
|
+
.cmp .v{font-weight:800;font-size:10cqw;letter-spacing:-.04em;line-height:1}
|
|
59
|
+
.cmp .d{font-weight:800;font-size:5.4cqw;padding:1.2cqw 2.6cqw;border-radius:99px;background:var(--fg);color:var(--bg)}
|
|
60
|
+
.cmp .d.dn{background:transparent;color:var(--fg);box-shadow:inset 0 0 0 1.5px var(--fg)}
|
|
61
|
+
.q{font-weight:800;font-size:6.4cqw;line-height:1.12;letter-spacing:-.02em}
|
|
62
|
+
.q::before{content:"“"}.q::after{content:"”"}
|
|
63
|
+
.meta{font:500 3.4cqw/1.3 var(--mono);opacity:.7}
|
|
64
|
+
.sp{flex:1}
|
|
65
|
+
|
|
66
|
+
/* entrada: cada .rv sobe quando o slide liga */
|
|
67
|
+
.rv{opacity:0;translate:0 7cqw}
|
|
68
|
+
.on .rv{animation:rv .9s var(--ease) both;animation-delay:var(--d,0s)}
|
|
69
|
+
@keyframes rv{from{opacity:0;translate:0 7cqw}to{opacity:1;translate:0 0}}
|
|
70
|
+
.chars .cw{display:inline-block;white-space:nowrap}
|
|
71
|
+
.chars i{display:inline-block;font-style:normal;opacity:0;translate:0 60%;rotate:8deg}
|
|
72
|
+
.on .chars i{animation:ch .8s var(--ease) both;animation-delay:calc(var(--d,0s) + var(--i) * 60ms)}
|
|
73
|
+
@keyframes ch{to{opacity:1;translate:0 0;rotate:0deg}}
|
|
74
|
+
.pop{transform:scale(.4);opacity:0}
|
|
75
|
+
.on .pop{animation:pop .7s cubic-bezier(.34,1.56,.64,1) both;animation-delay:var(--d,0s)}
|
|
76
|
+
@keyframes pop{to{transform:scale(1);opacity:1}}
|
|
77
|
+
|
|
78
|
+
/* gráficos */
|
|
79
|
+
.cal{width:100%;height:auto;display:block}
|
|
80
|
+
.cal rect{opacity:0}
|
|
81
|
+
.on .cal rect{animation:cell .5s var(--ease) both;animation-delay:calc(.3s + var(--w) * 18ms)}
|
|
82
|
+
@keyframes cell{from{opacity:0;transform:scale(.2)}to{opacity:1;transform:scale(1)}}
|
|
83
|
+
.cal rect{transform-box:fill-box;transform-origin:center}
|
|
84
|
+
.cal text{font:600 9px var(--mono);fill:currentColor;opacity:.6}
|
|
85
|
+
.clock{width:84%;align-self:center;height:auto;overflow:visible}
|
|
86
|
+
.clock line.b{stroke-dasharray:1;stroke-dashoffset:1}
|
|
87
|
+
.on .clock line.b{transition:stroke-dashoffset 1s var(--ease);transition-delay:calc(.3s + var(--i) * 35ms);stroke-dashoffset:0}
|
|
88
|
+
.clock text{font:700 11px var(--mono);fill:currentColor;text-anchor:middle;dominant-baseline:middle;opacity:.7}
|
|
89
|
+
.hb{display:grid;gap:2.6cqw}
|
|
90
|
+
.hb .r{display:grid;grid-template-columns:1fr auto;gap:1cqw 3cqw;align-items:end}
|
|
91
|
+
.hb .n{font-weight:800;font-size:5cqw;letter-spacing:-.02em;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
|
|
92
|
+
.hb .v{font:600 3.6cqw var(--mono);opacity:.8}
|
|
93
|
+
.hb .t{grid-column:1/-1;height:2.6cqw;border-radius:2cqw;background:color-mix(in srgb,var(--fg) 14%,transparent);overflow:hidden}
|
|
94
|
+
.hb .t i{display:block;height:100%;border-radius:inherit;background:var(--c,var(--ac));width:var(--w);transform:scaleX(0);transform-origin:left}
|
|
95
|
+
.on .hb .t i{transition:transform 1.2s var(--ease);transition-delay:var(--d,0s);transform:scaleX(1)}
|
|
96
|
+
.aw{display:grid;gap:4cqw}
|
|
97
|
+
.awr{display:grid;grid-template-columns:13cqw 1fr;gap:4cqw;align-items:center}
|
|
98
|
+
.ico.awi{width:13cqw;height:13cqw;color:var(--ac)}
|
|
99
|
+
.awr b{display:block;font-weight:800;font-size:6.6cqw;letter-spacing:-.03em;line-height:1.05}
|
|
100
|
+
.awr span{font:600 3.4cqw var(--mono);opacity:.7}
|
|
101
|
+
.words{display:flex;flex-wrap:wrap;gap:1.6cqw 3cqw;align-items:baseline}
|
|
102
|
+
.words span{font-weight:800;letter-spacing:-.03em;line-height:1}
|
|
103
|
+
.pm{display:flex;gap:4cqw;align-items:baseline;flex-wrap:wrap}
|
|
104
|
+
.pm .big:last-child{opacity:.55}
|
|
105
|
+
.weeks{display:flex;gap:1.4cqw;align-items:flex-end;height:22cqw}
|
|
106
|
+
.weeks div{flex:1;display:flex;flex-direction:column;align-items:center;gap:1.4cqw;height:100%;justify-content:flex-end}
|
|
107
|
+
.weeks i{display:block;width:100%;border-radius:1.4cqw;background:var(--ac);height:var(--h);transform:scaleY(0);transform-origin:bottom}
|
|
108
|
+
.on .weeks i{transition:transform 1s var(--ease);transition-delay:calc(.3s + var(--i) * 60ms);transform:scaleY(1)}
|
|
109
|
+
.weeks span{font:600 2.8cqw var(--mono);opacity:.7}
|
|
110
|
+
.ico{display:block;width:32cqw;height:32cqw;overflow:visible}
|
|
111
|
+
.ico.sm{display:inline-block;width:5.2cqw;height:5.2cqw;vertical-align:-.9cqw;margin-right:1cqw}
|
|
112
|
+
.hint{font:500 3cqw/1.4 var(--mono);opacity:.6}
|
|
113
|
+
|
|
114
|
+
.summary{gap:2.4cqw;padding-top:17cqw}
|
|
115
|
+
.grid{display:grid;grid-template-columns:1fr 1fr;gap:2.4cqw}
|
|
116
|
+
.grid div{border:1px solid color-mix(in srgb,var(--fg) 18%,transparent);border-radius:3cqw;padding:3.2cqw}
|
|
117
|
+
.grid b{display:block;font-weight:800;font-size:min(8.4cqw,var(--fs,8.4cqw));white-space:nowrap;overflow:hidden;text-overflow:ellipsis;letter-spacing:-.04em;color:var(--ac);line-height:1}
|
|
118
|
+
.grid span{font:600 2.9cqw/1.2 var(--mono);text-transform:uppercase;letter-spacing:.06em;opacity:.7}
|
|
119
|
+
.acts{display:flex;gap:2.4cqw;position:relative;z-index:30}
|
|
120
|
+
.btn{all:unset;cursor:pointer;flex:1;text-align:center;padding:3.6cqw;border-radius:99px;font-weight:800;font-size:4cqw;background:var(--ac);color:var(--bg)}
|
|
121
|
+
.btn.g{background:transparent;color:var(--fg);box-shadow:inset 0 0 0 1.5px color-mix(in srgb,var(--fg) 35%,transparent)}
|
|
122
|
+
.btn:focus-visible{outline:2px solid var(--fg);outline-offset:3px}
|
|
123
|
+
.tap{position:absolute;inset:0;z-index:10;display:grid;grid-template-columns:30% 70%}
|
|
124
|
+
.tap i{cursor:pointer}
|
|
125
|
+
.mv{position:fixed;inset:0;z-index:100;display:flex;gap:28px;align-items:center;justify-content:center;flex-wrap:wrap;padding:16px;
|
|
126
|
+
background:rgba(14,14,17,.94);--ac:var(--lime);--bg:var(--ink);--fg:var(--paper);color:var(--paper);overflow:auto}
|
|
127
|
+
.mv[hidden]{display:none}
|
|
128
|
+
.mv canvas{height:min(74dvh,760px);width:auto;aspect-ratio:9/16;border-radius:18px;box-shadow:0 0 0 1px rgba(255,255,255,.08),0 30px 90px rgba(0,0,0,.6);background:var(--ink)}
|
|
129
|
+
.mv-side{width:min(320px,100%);display:grid;gap:14px}
|
|
130
|
+
.mv-side b{font-weight:800;font-size:26px;letter-spacing:-.02em}
|
|
131
|
+
.mv-side p{font:500 13px/1.5 var(--mono);opacity:.7;min-height:1.5em}
|
|
132
|
+
.mv-bar{height:4px;border-radius:2px;background:rgba(244,240,230,.15);overflow:hidden}
|
|
133
|
+
.mv-bar i{display:block;height:100%;background:var(--lime);transform:scaleX(0);transform-origin:left}
|
|
134
|
+
.mv-acts{display:grid;gap:10px}
|
|
135
|
+
.mv .btn{font-size:16px;padding:15px 18px}
|
|
136
|
+
@media (max-width:699px){.mv{flex-direction:column;flex-wrap:nowrap;justify-content:flex-start;gap:16px}.mv canvas{height:58dvh}.mv-side{width:100%}}
|
|
137
|
+
.foot{position:absolute;bottom:4cqw;left:7cqw;right:7cqw;font:500 2.8cqw var(--mono);opacity:.5;z-index:20;color:var(--fg)}
|
|
138
|
+
@media (prefers-reduced-motion:reduce){*,*::before,*::after{animation-duration:.01s!important;animation-delay:0s!important;transition-duration:.01s!important;transition-delay:0s!important}}
|
|
139
|
+
</style>
|
|
140
|
+
</head>
|
|
141
|
+
<body>
|
|
142
|
+
<div class="stage" id="stage">
|
|
143
|
+
<div class="bars" id="bars" aria-hidden="true"></div>
|
|
144
|
+
<div class="top"><span>git retro <span id="yr"></span></span><button id="pause" aria-label="pausar">❚❚</button></div>
|
|
145
|
+
<div id="slides"></div>
|
|
146
|
+
<div class="tap" id="tap" aria-hidden="true"><i data-dir="-1"></i><i data-dir="1"></i></div>
|
|
147
|
+
</div>
|
|
148
|
+
<p class="help" id="help"></p>
|
|
149
|
+
<div class="mv" id="mv" hidden role="dialog" aria-modal="true" aria-labelledby="mvt">
|
|
150
|
+
<canvas id="mvc" width="1080" height="1920"></canvas>
|
|
151
|
+
<div class="mv-side"><b id="mvt"></b><div class="mv-bar"><i id="mvp"></i></div><p id="mvs"></p><div class="mv-acts" id="mva"></div></div>
|
|
152
|
+
</div>
|
|
153
|
+
<script>
|
|
154
|
+
const D = /*DATA*/null;
|
|
155
|
+
const L = D.lang === 'pt' ? 'pt' : 'en';
|
|
156
|
+
const T = {
|
|
157
|
+
pt: {
|
|
158
|
+
help: '← → para navegar · espaço pausa · toque segurando também pausa',
|
|
159
|
+
hi: n => `Oi${n ? ', ' + n : ''}.`, intro: 'Seu ano no git chegou. Bora ver o que você aprontou?', tapgo: 'toque para começar →',
|
|
160
|
+
youmade: 'Neste ano você fez', commits: 'commits', across: (r, d) => `em <b>${r} ${r === 1 ? 'repositório' : 'repositórios'}</b>, em <b>${d} dias</b> diferentes.`,
|
|
161
|
+
perday: n => `Uma média de <b>${n}</b> por dia em que você abriu o editor.`,
|
|
162
|
+
lines: 'Linhas', written: 'escritas', erased: 'apagadas', delgood: 'Apagar também é programar. Código bom é código que não existe.',
|
|
163
|
+
netgood: n => `Saldo de <b>${n}</b> linhas no mundo. Elas que lutem.`,
|
|
164
|
+
yearbyday: 'Seu ano, dia a dia', busiest: (d, n) => `Seu dia mais intenso foi <b>${d}</b>, com <b>${n} commits</b>.`,
|
|
165
|
+
days: 'dias seguidos', streak: (a, b) => `De ${a} a ${b} sem quebrar a corrente.`, streak1: 'Commit é tipo academia: o importante é voltar.',
|
|
166
|
+
clock: 'Seu relógio', peak: h => `Seu horário de pico é às <b>${h}h</b>.`,
|
|
167
|
+
youare: 'Você é', personas: {
|
|
168
|
+
owl: ['Coruja da madrugada', p => `${p}% dos seus commits saíram entre meia-noite e 5h. O deploy de produção agradece (ou não).`],
|
|
169
|
+
weekend: ['Guerreiro do fim de semana', p => `${p}% dos commits caíram no sábado ou no domingo. Descanso é um conceito.`],
|
|
170
|
+
marathon: ['Maratonista', p => `${p} dias seguidos commitando. Constância é o seu superpoder.`],
|
|
171
|
+
cleaner: ['Faxineiro de código', p => `Para cada 100 linhas que escreveu, você apagou ${p}. Código bom é o que sobra.`],
|
|
172
|
+
firefighter: ['Bombeiro', p => `${p}% dos seus commits foram correções. Pegou fogo, você estava lá.`],
|
|
173
|
+
polyglot: ['Poliglota', p => `${p} linguagens com peso de verdade no seu ano. Você não escolhe, você domina.`],
|
|
174
|
+
burst: ['Modo turbo', p => `${p}% dos seus commits saíram em só 10% dos dias. Quando você engata, ninguém segura.`],
|
|
175
|
+
loyal: ['Fiel ao projeto', p => `${p}% dos commits no mesmo repositório. Relacionamento sério.`],
|
|
176
|
+
early: ['Madrugador', p => `${p}% dos commits antes das 9h. Você commita antes do café esfriar.`],
|
|
177
|
+
night: ['Turno da noite', p => `${p}% dos commits depois das 18h. Seu código acorda quando o sol se põe.`],
|
|
178
|
+
office: ['Expediente comercial', p => `${p}% dos commits entre 9h e 18h. Constante como um cron job.`],
|
|
179
|
+
},
|
|
180
|
+
latest: 'O commit mais tarde', at: (d, r) => `${d} · ${r}`,
|
|
181
|
+
langs: 'Suas linguagens', lines_: 'linhas', repos: 'Onde você mais mexeu',
|
|
182
|
+
words: 'Palavras do ano', fixes: p => `<b>${p}%</b> dos seus commits foram correções. Ninguém escapa.`,
|
|
183
|
+
biggest: 'O maior commit', blines: 'linhas de uma vez',
|
|
184
|
+
weekdays: 'Seu dia da semana', wd: ['seg', 'ter', 'qua', 'qui', 'sex', 'sáb', 'dom'], bestwd: d => `<b>${d}</b> é o seu dia.`, wdFull: ['segunda', 'terça', 'quarta', 'quinta', 'sexta', 'sábado', 'domingo'],
|
|
185
|
+
months: 'Seu ano, mês a mês', bestm: (m, n) => `<b>${m}</b> foi o seu mês, com <b>${n} commits</b>.`,
|
|
186
|
+
vs: y => `Em relação a ${y}`, c_commits: 'commits', c_days: 'dias ativos', c_streak: 'maior sequência', c_added: 'linhas escritas',
|
|
187
|
+
swapped: (a, b) => `Você trocou <b>${a}</b> por <b>${b}</b>.`, kept: a => `<b>${a}</b> segue no topo.`, vsShort: y => `vs ${y}`,
|
|
188
|
+
summary: y => `Meu ${y} no git`, s_commits: 'commits', s_repos: 'repositórios', s_days: 'dias ativos', s_streak: 'dias seguidos',
|
|
189
|
+
s_added: 'linhas escritas', s_lang: 'linguagem do ano', download: 'Baixar imagem', again: 'Ver de novo', share: 'Postar no Instagram',
|
|
190
|
+
makeVideo: 'Criar vídeo para os stories', videoHint: 'Um vídeo de 13 segundos no tamanho de story. No Instagram dá para pôr música por cima.',
|
|
191
|
+
recording: 'Gravando o seu vídeo…', keepOpen: 'Deixe esta aba aberta até terminar.', ready: 'Pronto!',
|
|
192
|
+
postVideo: 'Postar no Instagram', downloadVideo: 'Baixar vídeo', close: 'Fechar',
|
|
193
|
+
musicTip: 'Dica: nos stories, toque no ícone de música para pôr uma trilha.',
|
|
194
|
+
webmNote: 'Este navegador grava em WebM, que o Instagram não aceita. No Chrome ou Safari atualizados o vídeo sai em MP4. Ou use a imagem.',
|
|
195
|
+
noVideo: 'Este navegador não grava vídeo. A imagem funciona em qualquer lugar.',
|
|
196
|
+
team: {
|
|
197
|
+
hi: n => n ? `Time ${n}.` : 'Oi, time.', intro: 'O ano do time no git chegou. Bora ver quem fez o quê?',
|
|
198
|
+
youmade: 'Neste ano o time fez', youare: 'O time é', summary: y => `Nosso ${y} no git`, cardTitle: y => `NOSSO ${y} NO GIT`,
|
|
199
|
+
vYear: 'O ano do time no git.', made: 'gerado localmente com git-retro --team · nada saiu do computador',
|
|
200
|
+
perday: n => `Uma média de <b>${n}</b> por dia em que o time commitou.`, yearbyday: 'O ano do time, dia a dia', months: 'O ano do time, mês a mês',
|
|
201
|
+
busiest: (d, n) => `O dia mais intenso do time foi <b>${d}</b>, com <b>${n} commits</b>.`, clock: 'O relógio do time',
|
|
202
|
+
peak: h => `O horário de pico do time é às <b>${h}h</b>.`, weekdays: 'O dia da semana do time', bestwd: d => `<b>${d}</b> é o dia do time.`,
|
|
203
|
+
langs: 'Linguagens do time', repos: 'Onde o time mais mexeu', fixes: p => `<b>${p}%</b> dos commits do time foram correções. Ninguém escapa.`,
|
|
204
|
+
},
|
|
205
|
+
who: 'Quem fez', people: n => `${n} ${n === 1 ? 'pessoa' : 'pessoas'} no time`, awardsT: 'Prêmios do ano',
|
|
206
|
+
aw: { commits: ['Mais commits', n => `${n} commits`], streak: ['Maior sequência', n => `${n} dias seguidos`], owl: ['Commit mais tarde', v => `às ${v}`],
|
|
207
|
+
cleaner: ['Mais linhas apagadas', n => `${nf(n)} linhas`], fixer: ['Mais correções', n => `${n} correções`] },
|
|
208
|
+
vYear: 'Seu ano no git.', streakLine: n => `maior sequência: ${n} ${n === 1 ? 'dia' : 'dias'}`,
|
|
209
|
+
shareHint: 'Para postar no Instagram: baixe a imagem e mande para o celular, ou abra este arquivo no celular e use o botão de compartilhar.',
|
|
210
|
+
shareText: y => `Meu ${y} no git. Gere o seu: github.com/Ryuks-py/git-retro`, made: 'gerado localmente com git-retro · nada saiu do seu computador',
|
|
211
|
+
cardTitle: y => `MEU ${y} NO GIT`, cardFoot: 'git-retro', peakK: 'horário de pico', langsK: 'linguagens', cardCommits: 'commits',
|
|
212
|
+
},
|
|
213
|
+
en: {
|
|
214
|
+
help: '← → to navigate · space pauses · press and hold also pauses',
|
|
215
|
+
hi: n => `Hey${n ? ' ' + n : ''}.`, intro: 'Your year in git is here. Ready to see what you shipped?', tapgo: 'tap to start →',
|
|
216
|
+
youmade: 'This year you made', commits: 'commits', across: (r, d) => `across <b>${r} ${r === 1 ? 'repository' : 'repositories'}</b>, on <b>${d} different days</b>.`,
|
|
217
|
+
perday: n => `That’s <b>${n}</b> per day you opened your editor.`,
|
|
218
|
+
lines: 'Lines', written: 'written', erased: 'deleted', delgood: 'Deleting is programming too. The best code is no code.',
|
|
219
|
+
netgood: n => `A net <b>${n}</b> lines added to the world. Good luck to them.`,
|
|
220
|
+
yearbyday: 'Your year, day by day', busiest: (d, n) => `Your busiest day was <b>${d}</b>, with <b>${n} commits</b>.`,
|
|
221
|
+
days: 'days in a row', streak: (a, b) => `From ${a} to ${b} without breaking the chain.`, streak1: 'Commits are like the gym: what matters is coming back.',
|
|
222
|
+
clock: 'Your clock', peak: h => `Your peak hour is <b>${h}:00</b>.`,
|
|
223
|
+
youare: 'You are', personas: {
|
|
224
|
+
owl: ['Night owl', p => `${p}% of your commits landed between midnight and 5am. Production says thanks (or not).`],
|
|
225
|
+
weekend: ['Weekend warrior', p => `${p}% of your commits happened on Saturday or Sunday. Rest is a concept.`],
|
|
226
|
+
marathon: ['Marathoner', p => `${p} days in a row with commits. Consistency is your superpower.`],
|
|
227
|
+
cleaner: ['Code janitor', p => `For every 100 lines you wrote, you deleted ${p}. Good code is what’s left.`],
|
|
228
|
+
firefighter: ['Firefighter', p => `${p}% of your commits were fixes. Something caught fire, you were there.`],
|
|
229
|
+
polyglot: ['Polyglot', p => `${p} languages carried real weight in your year.`],
|
|
230
|
+
burst: ['Turbo mode', p => `${p}% of your commits came out on just 10% of your days. Once you get going, nobody stops you.`],
|
|
231
|
+
loyal: ['Loyal to one', p => `${p}% of your commits went to the same repository. Serious relationship.`],
|
|
232
|
+
early: ['Early bird', p => `${p}% of your commits before 9am. Before the coffee gets cold.`],
|
|
233
|
+
night: ['Night shift', p => `${p}% of your commits after 6pm. Your code wakes up when the sun goes down.`],
|
|
234
|
+
office: ['Office hours', p => `${p}% of your commits between 9 and 6. Steady as a cron job.`],
|
|
235
|
+
},
|
|
236
|
+
latest: 'Your latest commit', at: (d, r) => `${d} · ${r}`,
|
|
237
|
+
langs: 'Your languages', lines_: 'lines', repos: 'Where you spent your time',
|
|
238
|
+
words: 'Words of the year', fixes: p => `<b>${p}%</b> of your commits were fixes. Nobody escapes.`,
|
|
239
|
+
biggest: 'Your biggest commit', blines: 'lines in one go',
|
|
240
|
+
weekdays: 'Your weekday', wd: ['mon', 'tue', 'wed', 'thu', 'fri', 'sat', 'sun'], bestwd: d => `<b>${d}</b> is your day.`, wdFull: ['Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday', 'Sunday'],
|
|
241
|
+
months: 'Your year, month by month', bestm: (m, n) => `<b>${m}</b> was your month, with <b>${n} commits</b>.`,
|
|
242
|
+
vs: y => `Compared to ${y}`, c_commits: 'commits', c_days: 'active days', c_streak: 'longest streak', c_added: 'lines written',
|
|
243
|
+
swapped: (a, b) => `You swapped <b>${a}</b> for <b>${b}</b>.`, kept: a => `<b>${a}</b> is still on top.`, vsShort: y => `vs ${y}`,
|
|
244
|
+
summary: y => `My ${y} in git`, s_commits: 'commits', s_repos: 'repositories', s_days: 'active days', s_streak: 'day streak',
|
|
245
|
+
s_added: 'lines written', s_lang: 'language of the year', download: 'Download image', again: 'Watch again', share: 'Share to Instagram',
|
|
246
|
+
makeVideo: 'Make a video for stories', videoHint: 'A 13-second video in story size. Add music on top in Instagram.',
|
|
247
|
+
recording: 'Recording your video…', keepOpen: 'Keep this tab open until it finishes.', ready: 'Done!',
|
|
248
|
+
postVideo: 'Share to Instagram', downloadVideo: 'Download video', close: 'Close',
|
|
249
|
+
musicTip: 'Tip: in stories, tap the music icon to add a soundtrack.',
|
|
250
|
+
webmNote: 'This browser records WebM, which Instagram doesn’t accept. Recent Chrome or Safari record MP4. Or use the image.',
|
|
251
|
+
noVideo: 'This browser can’t record video. The image works everywhere.',
|
|
252
|
+
team: {
|
|
253
|
+
hi: n => n ? `Team ${n}.` : 'Hey, team.', intro: 'Your team’s year in git is here. Ready to see who did what?',
|
|
254
|
+
youmade: 'This year the team made', youare: 'The team is', summary: y => `Our ${y} in git`, cardTitle: y => `OUR ${y} IN GIT`,
|
|
255
|
+
vYear: 'Your team’s year in git.', made: 'generated locally with git-retro --team · nothing left the computer',
|
|
256
|
+
perday: n => `That’s <b>${n}</b> per day the team committed.`, yearbyday: 'The team’s year, day by day', months: 'The team’s year, month by month',
|
|
257
|
+
busiest: (d, n) => `The team’s busiest day was <b>${d}</b>, with <b>${n} commits</b>.`, clock: 'The team’s clock',
|
|
258
|
+
peak: h => `The team’s peak hour is <b>${h}:00</b>.`, weekdays: 'The team’s weekday', bestwd: d => `<b>${d}</b> is the team’s day.`,
|
|
259
|
+
langs: 'The team’s languages', repos: 'Where the team spent its time', fixes: p => `<b>${p}%</b> of the team’s commits were fixes. Nobody escapes.`,
|
|
260
|
+
},
|
|
261
|
+
who: 'Who did it', people: n => `${n} ${n === 1 ? 'person' : 'people'} on the team`, awardsT: 'Awards of the year',
|
|
262
|
+
aw: { commits: ['Most commits', n => `${n} commits`], streak: ['Longest streak', n => `${n} days in a row`], owl: ['Latest commit', v => `at ${v}`],
|
|
263
|
+
cleaner: ['Most lines deleted', n => `${nf(n)} lines`], fixer: ['Most fixes', n => `${n} fixes`] },
|
|
264
|
+
vYear: 'Your year in git.', streakLine: n => `longest streak: ${n} ${n === 1 ? 'day' : 'days'}`,
|
|
265
|
+
shareHint: 'To post on Instagram: download the image and send it to your phone, or open this file on your phone and use the share button.',
|
|
266
|
+
shareText: y => `My ${y} in git. Make yours: github.com/Ryuks-py/git-retro`, made: 'generated locally with git-retro · nothing left your computer',
|
|
267
|
+
cardTitle: y => `MY ${y} IN GIT`, cardFoot: 'git-retro', peakK: 'peak hour', langsK: 'languages', cardCommits: 'commits',
|
|
268
|
+
},
|
|
269
|
+
}[L];
|
|
270
|
+
if (D.team) Object.assign(T, T.team);
|
|
271
|
+
document.documentElement.lang = L === 'pt' ? 'pt-BR' : 'en';
|
|
272
|
+
|
|
273
|
+
const $ = s => document.querySelector(s);
|
|
274
|
+
/* ícones das personalidades: traço de 7 em 100, cor do texto do slide */
|
|
275
|
+
const ICO = {
|
|
276
|
+
owl: '<path d="M18 56c0 22 14 34 32 34s32-12 32-34"/><path d="M18 34 14 12 34 26M82 34 86 12 66 26"/><circle cx="34" cy="48" r="15"/><circle cx="66" cy="48" r="15"/><circle cx="34" cy="48" r="5" fill="currentColor"/><circle cx="66" cy="48" r="5" fill="currentColor"/><path d="M44 66 50 76 56 66"/>',
|
|
277
|
+
weekend: '<rect x="12" y="18" width="76" height="70" rx="12"/><path d="M12 38h76M32 10v14M68 10v14"/><circle cx="32" cy="56" r="3" fill="currentColor"/><circle cx="50" cy="56" r="3" fill="currentColor"/><circle cx="32" cy="72" r="3" fill="currentColor"/><circle cx="50" cy="72" r="3" fill="currentColor"/><rect x="62" y="50" width="16" height="28" rx="4" fill="currentColor"/>',
|
|
278
|
+
marathon: '<path d="M22 92V10"/><path d="M22 14h58L68 32l12 18H22" fill="currentColor"/>',
|
|
279
|
+
cleaner: '<path d="M76 8 52 50"/><path d="M36 42l32 18-8 30H14z"/><path d="M28 74l-4 14M40 76l-3 13M52 78l-2 11"/>',
|
|
280
|
+
firefighter: '<path d="M50 92c-18 0-30-12-30-28 0-16 12-24 16-40 8 8 10 16 10 22 4-4 6-10 6-16 12 10 28 24 28 40 0 12-12 22-30 22z"/><path d="M50 92c-8 0-12-6-12-12 0-8 6-12 10-20 6 6 14 12 14 20 0 6-4 12-12 12z" fill="currentColor"/>',
|
|
281
|
+
polyglot: '<circle cx="50" cy="50" r="38"/><ellipse cx="50" cy="50" rx="16" ry="38"/><path d="M12 50h76M19 30h62M19 70h62"/>',
|
|
282
|
+
burst: '<path d="M58 6 20 56h28l-8 38 42-54H54z" fill="currentColor"/>',
|
|
283
|
+
loyal: '<circle cx="50" cy="62" r="28"/><path d="M36 14h28l10 12-24 18-24-18z" fill="currentColor"/>',
|
|
284
|
+
early: '<circle cx="50" cy="50" r="17" fill="currentColor"/><path d="M50 8v12M50 80v12M8 50h12M80 50h12M20 20l9 9M71 71l9 9M80 20l-9 9M29 71l-9 9"/>',
|
|
285
|
+
night: '<path d="M60 10a40 40 0 1 0 30 52A32 32 0 0 1 60 10z" fill="currentColor"/><path d="M80 14v12M74 20h12"/>',
|
|
286
|
+
office: '<rect x="10" y="30" width="80" height="56" rx="10"/><path d="M36 30v-8a6 6 0 0 1 6-6h16a6 6 0 0 1 6 6v8M10 54h80"/><rect x="43" y="47" width="14" height="14" rx="3" fill="currentColor"/>',
|
|
287
|
+
};
|
|
288
|
+
const icon = (k, cls = '') => `<svg class="ico ${cls}" viewBox="0 0 100 100" fill="none" stroke="currentColor" stroke-width="7" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true">${ICO[k] || ICO.office}</svg>`;
|
|
289
|
+
const esc = s => String(s ?? '').replace(/[&<>"']/g, c => ({ '&': '&', '<': '<', '>': '>', '"': '"', "'": ''' }[c]));
|
|
290
|
+
const nf = n => Math.round(n).toLocaleString(L === 'pt' ? 'pt-BR' : 'en-US');
|
|
291
|
+
const pd = s => { const [y, m, d] = s.split('-').map(Number); return new Date(y, m - 1, d); };
|
|
292
|
+
const fd = s => pd(s).toLocaleDateString(L === 'pt' ? 'pt-BR' : 'en-US', { day: 'numeric', month: 'long' });
|
|
293
|
+
const chars = (t, d = 0) => { let i = 0; return `<span class="chars" style="--d:${d}s">${String(t).split(' ').map(w => `<span class="cw">${[...w].map(c => `<i style="--i:${i++}">${esc(c)}</i>`).join('')}</span>`).join(' ')}</span>`; };
|
|
294
|
+
const rv = (html, d, cls = '') => `<div class="rv ${cls}" style="--d:${d}s">${html}</div>`;
|
|
295
|
+
const fitN = (n, base, k = .62) => { const len = nf(n).length; return `font-size:${Math.min(base, 86 / (len * k))}cqw`; };
|
|
296
|
+
const cnt = (n, cls = 'huge') => `<div class="${cls}" style="${fitN(n, cls === 'huge' ? 27 : 16)}" data-count="${n}">0</div>`;
|
|
297
|
+
const tot = D.totals;
|
|
298
|
+
|
|
299
|
+
/* ---------- gráficos ---------- */
|
|
300
|
+
function calendar() {
|
|
301
|
+
const y = D.year, start = new Date(y, 0, 1), max = Math.max(1, ...Object.values(D.days));
|
|
302
|
+
const off = (start.getDay() + 6) % 7; // semana começa na segunda
|
|
303
|
+
const half = 27, cs = 11, g = 2, top = 14;
|
|
304
|
+
let out = '', w = 0;
|
|
305
|
+
for (let d = new Date(start); d.getFullYear() === y; d.setDate(d.getDate() + 1)) {
|
|
306
|
+
const doy = Math.round((d - start) / 864e5), wk = Math.floor((doy + off) / 7), row = (d.getDay() + 6) % 7;
|
|
307
|
+
const part = wk < half ? 0 : 1, col = wk - part * half;
|
|
308
|
+
const iso = `${y}-${String(d.getMonth() + 1).padStart(2, '0')}-${String(d.getDate()).padStart(2, '0')}`;
|
|
309
|
+
const n = D.days[iso] || 0, lv = n ? Math.ceil(Math.min(1, n / (max * .6)) * 4) : 0;
|
|
310
|
+
const op = [0.09, .35, .55, .78, 1][lv];
|
|
311
|
+
out += `<rect x="${col * (cs + g)}" y="${top + part * (7 * (cs + g) + top + 6) + row * (cs + g)}" width="${cs}" height="${cs}" rx="2.5" fill="${lv ? 'var(--ac)' : 'currentColor'}" fill-opacity="${op}" style="--w:${wk}"><title>${iso}: ${n}</title></rect>`;
|
|
312
|
+
w = Math.max(w, col);
|
|
313
|
+
}
|
|
314
|
+
const mn = i => new Date(y, i, 1).toLocaleDateString(L === 'pt' ? 'pt-BR' : 'en-US', { month: 'short' }).replace('.', '');
|
|
315
|
+
const H = 2 * (7 * (cs + g) + top) + 6;
|
|
316
|
+
return `<svg class="cal" viewBox="0 0 ${(w + 1) * (cs + g)} ${H}" role="img" aria-label="${esc(T.yearbyday)}">
|
|
317
|
+
<text x="0" y="9">${mn(0)} – ${mn(5)}</text><text x="0" y="${7 * (cs + g) + top + 6 + 9}">${mn(6)} – ${mn(11)}</text>${out}</svg>`;
|
|
318
|
+
}
|
|
319
|
+
function clock() {
|
|
320
|
+
const max = Math.max(1, ...D.hours), R0 = 46, R1 = 128;
|
|
321
|
+
let s = '';
|
|
322
|
+
D.hours.forEach((n, h) => {
|
|
323
|
+
const a = (h / 24) * Math.PI * 2 - Math.PI / 2, r = R0 + (R1 - R0) * (n / max), c = Math.cos(a), si = Math.sin(a);
|
|
324
|
+
s += `<line x1="${150 + c * R0}" y1="${150 + si * R0}" x2="${150 + c * R1}" y2="${150 + si * R1}" stroke="currentColor" stroke-opacity=".12" stroke-width="7" stroke-linecap="round"/>`;
|
|
325
|
+
if (n) s += `<line class="b" pathLength="1" style="--i:${h}" x1="${150 + c * R0}" y1="${150 + si * R0}" x2="${150 + c * r}" y2="${150 + si * r}" stroke="var(--ac)" stroke-width="7" stroke-linecap="round"/>`;
|
|
326
|
+
});
|
|
327
|
+
[0, 6, 12, 18].forEach(h => { const a = (h / 24) * Math.PI * 2 - Math.PI / 2; s += `<text x="${150 + Math.cos(a) * 146}" y="${150 + Math.sin(a) * 146}">${h}h</text>`; });
|
|
328
|
+
return `<svg class="clock" viewBox="0 0 300 300" role="img" aria-label="${esc(T.clock)}">${s}</svg>`;
|
|
329
|
+
}
|
|
330
|
+
const hbars = (rows, val, label, color) => {
|
|
331
|
+
const max = Math.max(1, ...rows.map(val));
|
|
332
|
+
return `<div class="hb">${rows.map((r, i) => `<div class="r rv" style="--d:${.25 + i * .1}s"><span class="n">${esc(label(r))}</span><span class="v">${nf(val(r))}</span>
|
|
333
|
+
<span class="t"><i style="--w:${Math.max(3, val(r) * 100 / max)}%;--d:${.45 + i * .1}s${color ? ';--c:' + color(r) : ''}"></i></span></div>`).join('')}</div>`;
|
|
334
|
+
};
|
|
335
|
+
|
|
336
|
+
/* ---------- slides ---------- */
|
|
337
|
+
const S = [];
|
|
338
|
+
S.push({ th: 'ink', html: `<div class="k rv">${esc(T.hi(D.name))}</div>
|
|
339
|
+
<div class="huge" style="font-size:33cqw">${chars(D.year, .15)}</div>
|
|
340
|
+
${rv(`<p class="p">${esc(T.intro)}</p>`, .7)}<div class="sp"></div>${rv(`<div class="meta">${esc(T.tapgo)}</div>`, 1.2)}` });
|
|
341
|
+
|
|
342
|
+
const active = tot.active_days || 1;
|
|
343
|
+
S.push({ th: 'lime', html: `${rv(`<div class="h">${esc(T.youmade)}</div>`, 0)}${rv(cnt(tot.commits), .15)}${rv(`<div class="h">${esc(T.commits)}</div>`, .3)}
|
|
344
|
+
${rv(`<p class="p">${T.across(tot.repos, tot.active_days)}</p>`, .6)}${rv(`<p class="p">${T.perday((tot.commits / active).toFixed(1).replace('.', L === 'pt' ? ',' : '.'))}</p>`, .8)}` });
|
|
345
|
+
|
|
346
|
+
const AW_ICON = { commits: 'burst', streak: 'marathon', owl: 'owl', cleaner: 'cleaner', fixer: 'firefighter' };
|
|
347
|
+
if (D.team) {
|
|
348
|
+
const tm = D.team, mx = Math.max(1, ...tm.members.map(m => m.commits));
|
|
349
|
+
S.push({ th: 'orange', html: `${rv(`<div class="h">${esc(T.who)}</div>`, 0)}
|
|
350
|
+
<div class="hb">${tm.members.slice(0, 7).map((m, i) => `<div class="r rv" style="--d:${.2 + i * .09}s"><span class="n">${icon(m.persona, 'sm')}${esc(m.name)}</span><span class="v">${nf(m.commits)}</span>
|
|
351
|
+
<span class="t"><i style="--w:${Math.max(3, m.commits * 100 / mx)}%;--d:${.4 + i * .09}s"></i></span></div>`).join('')}</div>
|
|
352
|
+
${rv(`<div class="meta">${esc(T.people(tm.size))} · ${esc(T.commits)}</div>`, 1)}` });
|
|
353
|
+
}
|
|
354
|
+
|
|
355
|
+
S.push({ th: 'violet', html: `${rv(`<div class="k">${esc(T.lines)}</div>`, 0)}
|
|
356
|
+
${rv(`<div class="big" style="color:var(--ac);${fitN(Math.max(tot.added, tot.removed) * 10, 16)}">+<span data-count="${tot.added}">0</span></div><div class="meta">${esc(T.written)}</div>`, .15)}
|
|
357
|
+
${rv(`<div class="big" style="${fitN(Math.max(tot.added, tot.removed) * 10, 16)}">−<span data-count="${tot.removed}">0</span></div><div class="meta">${esc(T.erased)}</div>`, .35)}
|
|
358
|
+
${rv(`<p class="p" style="margin-top:3cqw">${tot.removed > tot.added * .5 ? esc(T.delgood) : T.netgood(nf(tot.added - tot.removed))}</p>`, .7)}` });
|
|
359
|
+
|
|
360
|
+
S.push({ th: 'ink', html: `${rv(`<div class="h">${esc(T.yearbyday)}</div>`, 0)}${calendar()}
|
|
361
|
+
${rv(`<p class="p">${T.busiest(fd(D.busiest.date), D.busiest.commits)}</p>`, 1.3)}` });
|
|
362
|
+
|
|
363
|
+
const mmax = Math.max(1, ...D.months), mbest = D.months.indexOf(mmax);
|
|
364
|
+
const mname = (i, style) => new Date(D.year, i, 1).toLocaleDateString(L === 'pt' ? 'pt-BR' : 'en-US', { month: style }).replace('.', '');
|
|
365
|
+
S.push({ th: 'paper', html: `${rv(`<div class="h">${esc(T.months)}</div>`, 0)}
|
|
366
|
+
<div class="weeks rv" style="--d:.1s;height:44cqw">${D.months.map((n, i) => `<div><i style="--i:${i};--h:${Math.max(3, n * 100 / mmax)}%${i === mbest ? '' : ';opacity:.35'}"></i><span>${mname(i, 'narrow')}</span></div>`).join('')}</div>
|
|
367
|
+
${rv(`<p class="p">${T.bestm(mname(mbest, 'long'), mmax)}</p>`, 1.1)}` });
|
|
368
|
+
|
|
369
|
+
S.push({ th: 'orange', html: `${rv(cnt(D.streak.length), 0)}${rv(`<div class="h">${esc(T.days)}</div>`, .2)}
|
|
370
|
+
${rv(`<p class="p">${D.streak.length > 1 ? esc(T.streak(fd(D.streak.start), fd(D.streak.end))) : esc(T.streak1)}</p>`, .5)}` });
|
|
371
|
+
|
|
372
|
+
const peak = D.hours.indexOf(Math.max(...D.hours));
|
|
373
|
+
S.push({ th: 'blue', html: `${rv(`<div class="h">${esc(T.clock)}</div>`, 0)}${clock()}${rv(`<p class="p">${T.peak(peak)}</p>`, 1.2)}` });
|
|
374
|
+
|
|
375
|
+
const wmax = Math.max(1, ...D.weekdays), wbest = D.weekdays.indexOf(wmax);
|
|
376
|
+
S.push({ th: 'lime', html: `${rv(`<div class="h">${esc(T.weekdays)}</div>`, 0)}
|
|
377
|
+
<div class="weeks rv" style="--d:.1s">${D.weekdays.map((n, i) => `<div><i style="--i:${i};--h:${Math.max(4, n * 100 / wmax)}%${i === wbest ? '' : ';opacity:.35'}"></i><span>${T.wd[i]}</span></div>`).join('')}</div>
|
|
378
|
+
${rv(`<p class="p">${T.bestwd(T.wdFull[wbest])}</p>`, .9)}` });
|
|
379
|
+
|
|
380
|
+
const pc = T.personas[D.persona] || T.personas.office;
|
|
381
|
+
S.push({ th: 'pink', html: `${rv(`<div class="k">${esc(T.youare)}</div>`, 0)}<div class="pop" style="--d:.2s">${icon(D.persona)}</div>
|
|
382
|
+
<div class="h" style="font-size:12cqw">${chars(pc[0], .45)}</div>${rv(`<p class="p">${esc(pc[1](D.persona_value))}</p>`, 1.1)}` });
|
|
383
|
+
|
|
384
|
+
if (D.night && D.night.message) S.push({ th: 'ink', html: `${rv(`<div class="k">${esc(T.latest)}</div>`, 0)}
|
|
385
|
+
<div class="huge">${chars(D.night.time, .15)}</div>${rv(`<p class="q">${esc(D.night.message)}</p>`, .7)}${rv(`<div class="meta">${esc(T.at(fd(D.night.date), D.night.repo))}</div>`, .9)}` });
|
|
386
|
+
|
|
387
|
+
if (D.langs.length) S.push({ th: 'paper', html: `${rv(`<div class="h">${esc(T.langs)}</div>`, 0)}
|
|
388
|
+
${hbars(D.langs, r => r.lines, r => `${r.name} · ${String(r.pct).replace('.', L === 'pt' ? ',' : '.')}%`, r => r.color)}` });
|
|
389
|
+
|
|
390
|
+
S.push({ th: 'violet', html: `${rv(`<div class="h">${esc(T.repos)}</div>`, 0)}${hbars(D.repos, r => r.commits, r => r.name)}
|
|
391
|
+
${rv(`<div class="meta">${esc(T.commits)}</div>`, 1)}` });
|
|
392
|
+
|
|
393
|
+
if (D.words.length >= 4 && D.words[0][1] >= 3) { const wm = D.words[0][1];
|
|
394
|
+
S.push({ th: 'lime', html: `${rv(`<div class="h">${esc(T.words)}</div>`, 0)}
|
|
395
|
+
<div class="words">${D.words.map(([w, n], i) => `<span class="pop" style="--d:${.2 + i * .09}s;font-size:${5 + 9 * (n / wm)}cqw;opacity:${.45 + .55 * (n / wm)}">${esc(w)}</span>`).join('')}</div>
|
|
396
|
+
${D.fix_pct ? rv(`<p class="p">${T.fixes(D.fix_pct)}</p>`, 1.1) : ''}` }); }
|
|
397
|
+
|
|
398
|
+
if (D.biggest && D.biggest.lines) S.push({ th: 'orange', html: `${rv(`<div class="k">${esc(T.biggest)}</div>`, 0)}${rv(cnt(D.biggest.lines), .1)}
|
|
399
|
+
${rv(`<div class="h">${esc(T.blines)}</div>`, .3)}${D.biggest.message ? rv(`<p class="q">${esc(D.biggest.message)}</p>`, .6) : ''}${rv(`<div class="meta">${esc(T.at(fd(D.biggest.date), D.biggest.repo))}</div>`, .8)}` });
|
|
400
|
+
|
|
401
|
+
const topLang = D.langs[0] ? D.langs[0].name : '—';
|
|
402
|
+
if (D.team && D.team.awards.length) S.push({ th: 'paper', html: `${rv(`<div class="h">${esc(T.awardsT)}</div>`, 0)}
|
|
403
|
+
<div class="aw">${D.team.awards.map((a, i) => rv(`${icon(AW_ICON[a.key], 'awi')}<div><div class="k">${esc(T.aw[a.key][0])}</div><b>${esc(a.name)}</b><span>${esc(T.aw[a.key][1](a.value))}</span></div>`, .15 + i * .12, 'awr')).join('')}</div>` });
|
|
404
|
+
const delta = (now, before) => { if (!before) return null; const p = Math.round((now - before) * 100 / before); return { p, txt: (p > 0 ? '+' : p < 0 ? '−' : '±') + Math.abs(p) + '%' }; };
|
|
405
|
+
const P = D.prev;
|
|
406
|
+
if (P && P.commits >= 10) {
|
|
407
|
+
const rows = [[T.c_commits, tot.commits, P.commits], [T.c_days, tot.active_days, P.active_days], [T.c_streak, D.streak.length, P.streak], [T.c_added, tot.added, P.added]];
|
|
408
|
+
S.push({ th: 'blue', html: `${rv(`<div class="h">${esc(T.vs(P.year))}</div>`, 0)}
|
|
409
|
+
<div class="cmp">${rows.map(([k, now, before], i) => { const d = delta(now, before);
|
|
410
|
+
return rv(`<div class="r"><span class="l">${esc(k)} · ${nf(before)} → ${nf(now)}</span><span class="v">${nf(now)}</span>${d ? `<span class="d ${d.p < 0 ? 'dn' : ''}">${d.txt}</span>` : ''}</div>`, .15 + i * .12); }).join('')}</div>
|
|
411
|
+
${P.top_lang && D.langs[0] ? rv(`<p class="p">${P.top_lang !== topLang ? T.swapped(esc(P.top_lang), esc(topLang)) : T.kept(esc(topLang))}</p>`, .8) : ''}` });
|
|
412
|
+
}
|
|
413
|
+
S.push({ th: 'ink', last: true, cls: 'summary', html: `${rv(`<div class="h">${esc(T.summary(D.year))}</div>`, 0)}
|
|
414
|
+
<div class="grid">${[[nf(tot.commits), T.s_commits], [nf(tot.repos), T.s_repos], [nf(tot.active_days), T.s_days], [nf(D.streak.length), T.s_streak], [nf(tot.added), T.s_added], [topLang, T.s_lang]]
|
|
415
|
+
.map(([v, k], i) => `<div class="pop" style="--d:${.15 + i * .07}s"><b style="--fs:${34 / (String(v).length * .6)}cqw">${esc(v)}</b><span>${esc(k)}</span></div>`).join('')}</div>
|
|
416
|
+
${rv(`<p class="p"><b>${icon(D.persona, 'sm')}${esc(pc[0])}</b></p>`, .7)}<div class="sp"></div>
|
|
417
|
+
${rv(`<div class="acts"><button class="btn" id="mvbtn">${esc(T.makeVideo)}</button><button class="btn g" id="again">${esc(T.again)}</button></div>`, .9)}
|
|
418
|
+
${rv(`<p class="hint">${esc(T.videoHint)}</p>`, 1)}
|
|
419
|
+
${rv(`<div class="meta" style="font-size:2.8cqw">${esc(T.made)}</div>`, 1.1)}` });
|
|
420
|
+
|
|
421
|
+
/* ---------- motor dos stories ---------- */
|
|
422
|
+
const box = $('#slides'), bars = $('#bars');
|
|
423
|
+
box.innerHTML = S.map((s, i) => `<section class="slide th-${s.th} ${s.cls || ''}" data-i="${i}" aria-hidden="true">${s.html}</section>`).join('');
|
|
424
|
+
bars.innerHTML = S.map(() => '<i><b></b></i>').join('');
|
|
425
|
+
$('#yr').textContent = D.year; $('#help').textContent = T.help;
|
|
426
|
+
const slides = [...box.children], segs = [...bars.children];
|
|
427
|
+
const DUR = 6500, RM = matchMedia('(prefers-reduced-motion: reduce)').matches;
|
|
428
|
+
let cur = -1, t0 = 0, elapsed = 0, paused = false, held = false, raf = 0;
|
|
429
|
+
|
|
430
|
+
function countUps(el) {
|
|
431
|
+
el.querySelectorAll('[data-count]').forEach(c => {
|
|
432
|
+
const to = +c.dataset.count, st = performance.now(), d = RM ? 1 : 1600;
|
|
433
|
+
const step = now => { const k = Math.min(1, (now - st) / d), e = 1 - Math.pow(1 - k, 4); c.textContent = nf(to * e); if (k < 1) requestAnimationFrame(step); };
|
|
434
|
+
requestAnimationFrame(step);
|
|
435
|
+
});
|
|
436
|
+
}
|
|
437
|
+
function go(i) {
|
|
438
|
+
i = Math.max(0, Math.min(S.length - 1, i));
|
|
439
|
+
if (i === cur) return;
|
|
440
|
+
slides.forEach((s, k) => { s.classList.remove('on'); s.setAttribute('aria-hidden', 'true'); });
|
|
441
|
+
const s = slides[i]; void s.offsetWidth; s.classList.add('on'); s.setAttribute('aria-hidden', 'false');
|
|
442
|
+
$('#stage').className = 'stage th-' + S[i].th;
|
|
443
|
+
segs.forEach((g, k) => { g.classList.toggle('done', k < i); g.firstChild.style.transform = k < i ? 'scaleX(1)' : 'scaleX(0)'; });
|
|
444
|
+
$('#tap').style.display = S[i].last ? 'none' : '';
|
|
445
|
+
cur = i; elapsed = 0; t0 = performance.now(); countUps(s);
|
|
446
|
+
if (S[i].last) setTimeout(() => prepare().catch(() => {}), 800);
|
|
447
|
+
}
|
|
448
|
+
function loop(now) {
|
|
449
|
+
if (!paused && !held && !S[cur].last && !document.hidden) {
|
|
450
|
+
elapsed += now - t0;
|
|
451
|
+
segs[cur].firstChild.style.transform = `scaleX(${Math.min(1, elapsed / DUR)})`;
|
|
452
|
+
if (elapsed >= DUR) go(cur + 1);
|
|
453
|
+
}
|
|
454
|
+
t0 = now; raf = requestAnimationFrame(loop);
|
|
455
|
+
}
|
|
456
|
+
const setPause = p => { paused = p; $('#pause').textContent = p ? '▶' : '❚❚'; $('#pause').setAttribute('aria-label', p ? 'play' : 'pause'); };
|
|
457
|
+
$('#pause').addEventListener('click', e => { e.stopPropagation(); setPause(!paused); });
|
|
458
|
+
let downAt = 0;
|
|
459
|
+
$('#tap').addEventListener('pointerdown', () => { downAt = performance.now(); held = true; });
|
|
460
|
+
$('#tap').addEventListener('pointerup', e => { held = false; if (performance.now() - downAt < 250) go(cur + +e.target.dataset.dir); });
|
|
461
|
+
$('#tap').addEventListener('pointercancel', () => { held = false; });
|
|
462
|
+
$('#tap').addEventListener('pointerleave', () => { held = false; });
|
|
463
|
+
addEventListener('keydown', e => {
|
|
464
|
+
if (e.key === 'ArrowRight' || e.key === 'PageDown') go(cur + 1);
|
|
465
|
+
else if (e.key === 'ArrowLeft' || e.key === 'PageUp') go(cur - 1);
|
|
466
|
+
else if (e.key === ' ') { e.preventDefault(); setPause(!paused); }
|
|
467
|
+
else if (e.key === 'Home') go(0);
|
|
468
|
+
else if (e.key === 'End') go(S.length - 1);
|
|
469
|
+
});
|
|
470
|
+
let sx = 0;
|
|
471
|
+
$('#stage').addEventListener('touchstart', e => { sx = e.touches[0].clientX; }, { passive: true });
|
|
472
|
+
$('#stage').addEventListener('touchend', e => { const dx = e.changedTouches[0].clientX - sx; if (Math.abs(dx) > 60) go(cur + (dx < 0 ? 1 : -1)); }, { passive: true });
|
|
473
|
+
$('#again').addEventListener('click', () => { cur = -1; go(0); });
|
|
474
|
+
$('#mvbtn').addEventListener('click', () => openMotion());
|
|
475
|
+
|
|
476
|
+
/* ---------- vídeo para os stories (1080×1920): seis cenas que contam o ano ---------- */
|
|
477
|
+
const VW = 1080, VH = 1920, VX = 84, VCW = VW - 2 * VX;
|
|
478
|
+
const COL = { ink: '#0E0E11', paper: '#F4F0E6', lime: '#C6FF3D', blue: '#1E3BFF', pink: '#FF8AD0' };
|
|
479
|
+
const clamp = (x, a = 0, b = 1) => Math.max(a, Math.min(b, x));
|
|
480
|
+
const eo = t => 1 - Math.pow(1 - clamp(t), 4);
|
|
481
|
+
const eb = t => { t = clamp(t); return 1 + 2.70158 * Math.pow(t - 1, 3) + 1.70158 * Math.pow(t - 1, 2); };
|
|
482
|
+
const eio = t => { t = clamp(t); return t < .5 ? 4 * t * t * t : 1 - Math.pow(-2 * t + 2, 3) / 2; };
|
|
483
|
+
const plain = s => String(s).replace(/<[^>]+>/g, '');
|
|
484
|
+
const CSS = getComputedStyle(document.documentElement), SANS = CSS.getPropertyValue('--sans'), MONO = CSS.getPropertyValue('--mono');
|
|
485
|
+
let c = null, iconImg = null, prepared = null;
|
|
486
|
+
|
|
487
|
+
const font = (w, px, f = SANS) => { c.font = `${w} ${px}px ${f}`; };
|
|
488
|
+
const fit = (txt, w, px, maxW, f = SANS) => { let s = px; font(w, s, f); while (c.measureText(txt).width > maxW && s > 16) { s -= 2; font(w, s, f); } return s; };
|
|
489
|
+
const track = px => { try { c.letterSpacing = px + 'px'; } catch (e) {} };
|
|
490
|
+
const rr = (x, y, w, h, r) => { c.beginPath(); c.roundRect(x, y, w, h, r); };
|
|
491
|
+
const enter = (p, dy, fn) => { if (p <= 0) return; c.save(); c.globalAlpha *= clamp(p); c.translate(0, (1 - eo(p)) * dy); fn(); c.restore(); };
|
|
492
|
+
function wrap(txt, x, y, maxW, lh) {
|
|
493
|
+
let line = '';
|
|
494
|
+
for (const w of String(txt).split(' ')) { const t = line ? line + ' ' + w : w; if (c.measureText(t).width > maxW && line) { c.fillText(line, x, y); y += lh; line = w; } else line = t; }
|
|
495
|
+
if (line) c.fillText(line, x, y);
|
|
496
|
+
return y;
|
|
497
|
+
}
|
|
498
|
+
function glow(color, x, y, r, a) { const g = c.createRadialGradient(x, y, 0, x, y, r); g.addColorStop(0, color.replace(')', `,${a})`).replace('rgb', 'rgba')); g.addColorStop(1, color.replace(')', ',0)').replace('rgb', 'rgba')); c.fillStyle = g; c.fillRect(0, 0, VW, VH); }
|
|
499
|
+
|
|
500
|
+
// células do calendário, calculadas uma vez
|
|
501
|
+
const CAL = (() => {
|
|
502
|
+
const y = D.year, start = new Date(y, 0, 1), off = (start.getDay() + 6) % 7, max = Math.max(1, ...Object.values(D.days)), out = [];
|
|
503
|
+
for (let d = new Date(start); d.getFullYear() === y; d.setDate(d.getDate() + 1)) {
|
|
504
|
+
const doy = Math.round((d - start) / 864e5), wk = Math.floor((doy + off) / 7), row = (d.getDay() + 6) % 7;
|
|
505
|
+
const iso = `${y}-${String(d.getMonth() + 1).padStart(2, '0')}-${String(d.getDate()).padStart(2, '0')}`, n = D.days[iso] || 0;
|
|
506
|
+
out.push({ wk, row, part: wk < 27 ? 0 : 1, col: wk < 27 ? wk : wk - 27, lv: n ? Math.ceil(Math.min(1, n / (max * .6)) * 4) : 0 });
|
|
507
|
+
}
|
|
508
|
+
return out;
|
|
509
|
+
})();
|
|
510
|
+
const mshort = i => new Date(D.year, i, 1).toLocaleDateString(L === 'pt' ? 'pt-BR' : 'en-US', { month: 'short' }).replace('.', '').toUpperCase();
|
|
511
|
+
function drawCal(y0, lt) {
|
|
512
|
+
const gap = 6, cs = (VCW - 26 * gap) / 27, half = 7 * (cs + gap) + 40;
|
|
513
|
+
c.fillStyle = COL.paper; c.globalAlpha = .55 * eo(lt / .4); font(600, 22, MONO); track(2);
|
|
514
|
+
c.fillText(`${mshort(0)} – ${mshort(5)}`, VX, y0 - 14); c.fillText(`${mshort(6)} – ${mshort(11)}`, VX, y0 + half - 14); track(0); c.globalAlpha = 1;
|
|
515
|
+
for (const k of CAL) {
|
|
516
|
+
const p = eb((lt - k.wk * .026 - k.row * .012) / .45); if (p <= 0) continue;
|
|
517
|
+
const x = VX + k.col * (cs + gap), y = y0 + k.part * half + k.row * (cs + gap), s = cs * p;
|
|
518
|
+
c.globalAlpha = [.08, .32, .55, .8, 1][k.lv] * clamp(p * 1.5); c.fillStyle = k.lv ? COL.lime : COL.paper;
|
|
519
|
+
rr(x + (cs - s) / 2, y + (cs - s) / 2, s, s, 6 * p); c.fill();
|
|
520
|
+
}
|
|
521
|
+
c.globalAlpha = 1;
|
|
522
|
+
return y0 + 2 * half;
|
|
523
|
+
}
|
|
524
|
+
const peakH = D.hours.indexOf(Math.max(...D.hours));
|
|
525
|
+
const vsChip = () => { const d = P && P.commits >= 10 ? delta(tot.commits, P.commits) : null; return d && { d, txt: `${d.txt} ${T.vsShort(P.year)}` }; };
|
|
526
|
+
|
|
527
|
+
const SCENES = [
|
|
528
|
+
{ d: 2.3, bg: COL.ink, draw(lt) { // o ano
|
|
529
|
+
glow('rgb(198,255,61)', VW - 60, 160, 900, .2 * eo(lt / .8));
|
|
530
|
+
enter(lt / .5, 20, () => { c.fillStyle = COL.paper; font(600, 30, MONO); track(4); c.fillText('GIT RETRO', VX, 160);
|
|
531
|
+
if (D.name) { c.textAlign = 'right'; c.globalAlpha *= .6; c.fillText(String(D.name).toUpperCase().slice(0, 20), VW - VX, 160); c.textAlign = 'left'; } track(0); });
|
|
532
|
+
const yr = String(D.year); fit(yr, 800, 400, VCW + 40); track(-16);
|
|
533
|
+
const widths = [...yr].map(ch => c.measureText(ch).width), total = widths.reduce((a, b) => a + b, 0) - 16 * (yr.length - 1);
|
|
534
|
+
let x = (VW - total) / 2;
|
|
535
|
+
[...yr].forEach((ch, i) => { const p = eo((lt - .15 - i * .09) / .8); if (p > 0) { c.save(); c.globalAlpha = p; c.fillStyle = COL.lime; c.fillText(ch, x, 1060 + (1 - p) * 260); c.restore(); } x += widths[i] - 16; });
|
|
536
|
+
track(0);
|
|
537
|
+
enter((lt - .9) / .6, 50, () => { c.fillStyle = COL.paper; font(500, 58); c.textAlign = 'center'; c.fillText(T.vYear, VW / 2, 1200); c.textAlign = 'left'; });
|
|
538
|
+
} },
|
|
539
|
+
{ d: 2.5, bg: COL.lime, draw(lt) { // commits contando
|
|
540
|
+
c.fillStyle = COL.ink;
|
|
541
|
+
enter(lt / .5, 50, () => { font(800, 76); c.fillText(T.youmade, VX, 720); });
|
|
542
|
+
const v = nf(tot.commits * eo((lt - .2) / 1.5)); fit(nf(tot.commits), 800, 470, VCW + 20); track(-18); c.fillText(v, VX - 10, 1150); track(0);
|
|
543
|
+
enter((lt - .45) / .5, 50, () => { font(800, 116); c.fillText(T.commits, VX, 1290); });
|
|
544
|
+
const ch = vsChip();
|
|
545
|
+
if (ch) enter((lt - 1.3) / .5, 30, () => { font(800, 50); const w = c.measureText(ch.txt).width + 60; c.fillStyle = COL.ink; rr(VX, 1350, w, 84, 42); c.fill(); c.fillStyle = COL.lime; c.fillText(ch.txt, VX + 30, 1409); });
|
|
546
|
+
enter((lt - 1) / .6, 40, () => { c.fillStyle = COL.ink; font(500, 48); wrap(plain(T.across(tot.repos, tot.active_days)), VX, ch ? 1540 : 1420, VCW, 62); });
|
|
547
|
+
} },
|
|
548
|
+
...(D.team ? [{ d: 2.6, bg: '#FF5A1F', draw(lt) { // quem fez (só no modo time)
|
|
549
|
+
const ms = D.team.members.slice(0, 6), mx = Math.max(1, ...ms.map(m => m.commits));
|
|
550
|
+
enter(lt / .5, 40, () => { c.fillStyle = '#fff'; font(800, 84); c.fillText(T.who, VX, 470); });
|
|
551
|
+
ms.forEach((m, i) => {
|
|
552
|
+
const y = 620 + i * 190, p = (lt - .25 - i * .12) / .5;
|
|
553
|
+
enter(p, 50, () => {
|
|
554
|
+
c.fillStyle = '#fff'; fit(m.name, 800, 58, VCW - 200); c.fillText(m.name, VX, y);
|
|
555
|
+
c.textAlign = 'right'; font(600, 40, MONO); c.fillText(nf(m.commits), VW - VX, y); c.textAlign = 'left';
|
|
556
|
+
c.fillStyle = 'rgba(255,255,255,.18)'; rr(VX, y + 30, VCW, 30, 15); c.fill();
|
|
557
|
+
c.fillStyle = COL.ink; rr(VX, y + 30, Math.max(30, VCW * m.commits / mx * eo((lt - .45 - i * .12) / 1)), 30, 15); c.fill();
|
|
558
|
+
});
|
|
559
|
+
});
|
|
560
|
+
enter((lt - 1.2) / .5, 30, () => { c.fillStyle = '#fff'; c.globalAlpha *= .8; font(600, 32, MONO); track(2); c.fillText(T.people(D.team.size).toUpperCase(), VX, 1800); track(0); });
|
|
561
|
+
} }] : []),
|
|
562
|
+
{ d: 2.7, bg: COL.ink, draw(lt) { // calendário se acendendo
|
|
563
|
+
enter(lt / .5, 40, () => { c.fillStyle = COL.paper; font(800, 80); c.fillText(T.yearbyday, VX, 470); });
|
|
564
|
+
const yb = drawCal(620, lt - .2);
|
|
565
|
+
const n = nf(tot.active_days * eo((lt - .9) / 1.2));
|
|
566
|
+
enter((lt - .8) / .5, 50, () => { c.fillStyle = COL.lime; font(800, 230); track(-8); c.fillText(n, VX - 6, yb + 230); track(0);
|
|
567
|
+
c.fillStyle = COL.paper; font(800, 60); c.fillText(T.s_days, VX, yb + 310);
|
|
568
|
+
c.globalAlpha *= .7; font(600, 30, MONO); track(2); c.fillText(T.streakLine(D.streak.length).toUpperCase(), VX, yb + 380); track(0); });
|
|
569
|
+
} },
|
|
570
|
+
{ d: 2.4, bg: COL.blue, draw(lt) { // relógio crescendo
|
|
571
|
+
enter(lt / .5, 40, () => { c.fillStyle = '#fff'; font(800, 80); c.fillText(T.clock, VX, 430); });
|
|
572
|
+
const cx = VW / 2, cy = 960, R0 = 150, R1 = 400, max = Math.max(1, ...D.hours);
|
|
573
|
+
c.lineCap = 'round'; c.lineWidth = 24;
|
|
574
|
+
D.hours.forEach((n, h) => {
|
|
575
|
+
const a = h / 24 * Math.PI * 2 - Math.PI / 2, co = Math.cos(a), si = Math.sin(a), pb = eo((lt - .1 - h * .012) / .5);
|
|
576
|
+
c.strokeStyle = `rgba(255,255,255,${.14 * pb})`; c.beginPath(); c.moveTo(cx + co * R0, cy + si * R0); c.lineTo(cx + co * R1, cy + si * R1); c.stroke();
|
|
577
|
+
const p = eo((lt - .3 - h * .035) / .8); if (!n || p <= 0) return;
|
|
578
|
+
const r = R0 + (R1 - R0) * (n / max) * p; c.strokeStyle = COL.lime; c.beginPath(); c.moveTo(cx + co * R0, cy + si * R0); c.lineTo(cx + co * r, cy + si * r); c.stroke();
|
|
579
|
+
});
|
|
580
|
+
c.fillStyle = 'rgba(255,255,255,.75)'; font(600, 30, MONO); c.textAlign = 'center'; c.textBaseline = 'middle';
|
|
581
|
+
[0, 6, 12, 18].forEach(h => { const a = h / 24 * Math.PI * 2 - Math.PI / 2; c.globalAlpha = eo((lt - .4) / .5); c.fillText(h + 'h', cx + Math.cos(a) * 455, cy + Math.sin(a) * 455); });
|
|
582
|
+
c.globalAlpha = 1; c.textAlign = 'left'; c.textBaseline = 'alphabetic';
|
|
583
|
+
enter((lt - 1.1) / .5, 40, () => { c.fillStyle = '#fff'; font(800, 70); c.fillText(plain(T.peak(peakH)), VX, 1620); });
|
|
584
|
+
} },
|
|
585
|
+
{ d: 2.6, bg: COL.pink, draw(lt) { // personalidade
|
|
586
|
+
c.fillStyle = COL.ink;
|
|
587
|
+
enter(lt / .4, 20, () => { c.globalAlpha *= .7; font(600, 32, MONO); track(5); c.textAlign = 'center'; c.fillText(T.youare.toUpperCase(), VW / 2, 520); c.textAlign = 'left'; track(0); });
|
|
588
|
+
const s = eb((lt - .15) / .7);
|
|
589
|
+
if (s > 0 && iconImg) { const z = 380 * s; c.save(); c.globalAlpha = clamp(s * 2); c.drawImage(iconImg, VW / 2 - z / 2, 860 - z / 2, z, z); c.restore(); }
|
|
590
|
+
const name = pc[0], fs = fit(name, 800, 140, VCW);
|
|
591
|
+
const ws = [...name].map(ch => c.measureText(ch).width), total = ws.reduce((a, b) => a + b, 0);
|
|
592
|
+
let x = (VW - total) / 2;
|
|
593
|
+
[...name].forEach((ch, i) => { const p = eo((lt - .55 - i * .035) / .6); if (p > 0) { c.save(); c.globalAlpha = p; font(800, fs); c.fillText(ch, x, 1240 + (1 - p) * 90); c.restore(); } x += ws[i]; });
|
|
594
|
+
enter((lt - 1.1) / .6, 40, () => { font(500, 46); c.textAlign = 'center'; wrap(plain(pc[1](D.persona_value)), VW / 2, 1360, VCW - 40, 62); c.textAlign = 'left'; });
|
|
595
|
+
} },
|
|
596
|
+
{ d: 3.8, bg: COL.ink, draw(lt) { // o cartão se monta e fica
|
|
597
|
+
const b = i => (lt - .1 - i * .11) / .55;
|
|
598
|
+
glow('rgb(198,255,61)', VW - 80, 120, 760, .22 * eo(lt / .8));
|
|
599
|
+
enter(b(0), 40, () => { c.fillStyle = COL.paper; font(600, 30, MONO); track(3); c.fillText(T.cardTitle(D.year), VX, 132);
|
|
600
|
+
if (D.name) { c.textAlign = 'right'; c.globalAlpha *= .6; c.fillText(String(D.name).toUpperCase().slice(0, 22), VW - VX, 132); c.textAlign = 'left'; } track(0); });
|
|
601
|
+
enter(b(1), 70, () => { const num = nf(tot.commits); c.fillStyle = COL.lime; track(-14); fit(num, 800, 330, VCW); c.fillText(num, VX - 8, 440); track(0); });
|
|
602
|
+
enter(b(2), 50, () => {
|
|
603
|
+
c.fillStyle = COL.paper; font(800, 64); c.fillText(T.cardCommits, VX, 530);
|
|
604
|
+
const ch = vsChip(); if (!ch) return;
|
|
605
|
+
const x1 = VX + c.measureText(T.cardCommits).width + 28; font(800, 40); const w = c.measureText(ch.txt).width + 48, up = ch.d.p >= 0;
|
|
606
|
+
c.fillStyle = COL.lime; c.strokeStyle = COL.lime; c.lineWidth = 3; rr(x1, 478, w, 66, 33); up ? c.fill() : c.stroke();
|
|
607
|
+
c.fillStyle = up ? COL.ink : COL.lime; c.fillText(ch.txt, x1 + 24, 524);
|
|
608
|
+
});
|
|
609
|
+
let y = drawCal(620, lt - .35) + 40;
|
|
610
|
+
const cells = [[nf(tot.active_days), T.s_days], [nf(D.streak.length), T.s_streak], [L === 'pt' ? `${peakH}h` : `${peakH}:00`, T.peakK]], bw = (VCW - 48) / 3;
|
|
611
|
+
cells.forEach(([v, k], i) => enter(b(4 + i * .5), 50, () => {
|
|
612
|
+
const x = VX + i * (bw + 24);
|
|
613
|
+
c.strokeStyle = 'rgba(244,240,230,.2)'; c.lineWidth = 2; rr(x, y, bw, 170, 26); c.stroke();
|
|
614
|
+
c.fillStyle = COL.paper; fit(v, 800, 88, bw - 56); c.fillText(v, x + 28, y + 98);
|
|
615
|
+
c.globalAlpha *= .6; font(600, 22, MONO); track(2); c.fillText(k.toUpperCase(), x + 28, y + 140); track(0);
|
|
616
|
+
}));
|
|
617
|
+
y += 230;
|
|
618
|
+
const lt5 = D.langs.slice(0, 5), lsum = lt5.reduce((a, l) => a + l.lines, 0) || 1;
|
|
619
|
+
enter(b(6), 40, () => {
|
|
620
|
+
c.fillStyle = COL.paper; c.globalAlpha *= .6; font(600, 22, MONO); track(2); c.fillText(T.langsK.toUpperCase(), VX, y); track(0); c.globalAlpha /= .6;
|
|
621
|
+
const grow = eo((lt - .9) / .9); c.save(); rr(VX, y + 26, VCW * grow, 34, 17); c.clip();
|
|
622
|
+
let x = VX; lt5.forEach(l => { const w = VCW * l.lines / lsum; c.fillStyle = l.color; c.fillRect(x, y + 26, w + 1, 34); x += w; }); c.restore();
|
|
623
|
+
x = VX; lt5.slice(0, 3).forEach(l => { c.fillStyle = l.color; c.beginPath(); c.arc(x + 11, y + 110 - 13, 11, 0, 7); c.fill();
|
|
624
|
+
c.fillStyle = COL.paper; font(800, 36); const tx = `${l.name} ${Math.round(l.pct)}%`; c.fillText(tx, x + 32, y + 110); x += c.measureText(tx).width + 80; });
|
|
625
|
+
});
|
|
626
|
+
y += 162;
|
|
627
|
+
const ph = Math.max(170, VH - 150 - y);
|
|
628
|
+
enter(b(7), 80, () => {
|
|
629
|
+
c.fillStyle = COL.pink; rr(VX, y, VCW, ph, 40); c.fill();
|
|
630
|
+
c.fillStyle = COL.ink;
|
|
631
|
+
if (iconImg) { const s = eb((lt - 1.2) / .6) * 104; c.drawImage(iconImg, VX + 52 + 52 - s / 2, y + ph / 2 - s / 2, s, s); }
|
|
632
|
+
fit(pc[0], 800, 80, VCW - 230); c.fillText(pc[0], VX + 186, y + ph / 2 + 28);
|
|
633
|
+
});
|
|
634
|
+
enter(b(8), 20, () => { c.fillStyle = COL.paper; c.globalAlpha *= .45; font(600, 24, MONO); c.fillText('github.com/Ryuks-py/git-retro', VX, VH - 70); });
|
|
635
|
+
} },
|
|
636
|
+
];
|
|
637
|
+
const TR = .5, STARTS = []; { let a = 0; SCENES.forEach(s => { STARTS.push(a); a += s.d - TR; }); }
|
|
638
|
+
const TOTAL = STARTS[STARTS.length - 1] + SCENES[SCENES.length - 1].d;
|
|
639
|
+
function scene(i, lt) { c.fillStyle = SCENES[i].bg; c.fillRect(0, 0, VW, VH); SCENES[i].draw(lt); }
|
|
640
|
+
function frame(ctx, t) {
|
|
641
|
+
c = ctx; c.textAlign = 'left'; c.textBaseline = 'alphabetic'; c.globalAlpha = 1; track(0);
|
|
642
|
+
let i = 0; while (i + 1 < SCENES.length && t >= STARTS[i + 1]) i++;
|
|
643
|
+
const into = t - STARTS[i];
|
|
644
|
+
if (i > 0 && into < TR) {
|
|
645
|
+
scene(i - 1, t - STARTS[i - 1]);
|
|
646
|
+
const p = eio(into / TR); c.save(); c.beginPath(); c.arc(VW / 2, VH * .55, p * Math.hypot(VW, VH) * .62 + 1, 0, 7); c.clip(); scene(i, into); c.restore();
|
|
647
|
+
} else scene(i, into);
|
|
648
|
+
}
|
|
649
|
+
async function prepare() {
|
|
650
|
+
if (prepared) return prepared;
|
|
651
|
+
return (prepared = (async () => {
|
|
652
|
+
try { await Promise.all(['800 100px Retro', '500 40px Retro', '600 30px RetroMono'].map(f => document.fonts.load(f))); } catch (e) {}
|
|
653
|
+
const svg = icon(D.persona).replace('<svg ', '<svg xmlns="http://www.w3.org/2000/svg" width="400" height="400" ').replaceAll('currentColor', COL.ink);
|
|
654
|
+
const img = new Image(); img.src = 'data:image/svg+xml;charset=utf-8,' + encodeURIComponent(svg);
|
|
655
|
+
try { await img.decode(); iconImg = img; } catch (e) {}
|
|
656
|
+
})());
|
|
657
|
+
}
|
|
658
|
+
|
|
659
|
+
/* imagem parada = último quadro do vídeo */
|
|
660
|
+
let cardFile = null;
|
|
661
|
+
async function makeCard() {
|
|
662
|
+
if (cardFile) return cardFile;
|
|
663
|
+
await prepare();
|
|
664
|
+
const cv = document.createElement('canvas'); cv.width = VW; cv.height = VH; frame(cv.getContext('2d'), TOTAL);
|
|
665
|
+
const b = await new Promise(r => cv.toBlob(r, 'image/png'));
|
|
666
|
+
return (cardFile = new File([b], `git-retro-${D.year}.png`, { type: 'image/png' }));
|
|
667
|
+
}
|
|
668
|
+
function saveFile(f) {
|
|
669
|
+
const a = document.createElement('a'); a.href = URL.createObjectURL(f); a.download = f.name; document.body.append(a); a.click(); a.remove();
|
|
670
|
+
setTimeout(() => URL.revokeObjectURL(a.href), 4000);
|
|
671
|
+
}
|
|
672
|
+
async function shareFile(f) {
|
|
673
|
+
// no celular abre a folha de compartilhar do sistema: Instagram (stories, feed, direct), WhatsApp, LinkedIn…
|
|
674
|
+
try { await navigator.share({ files: [f], text: T.shareText(D.year) }); }
|
|
675
|
+
catch (e) { if (e && e.name !== 'AbortError') saveFile(f); }
|
|
676
|
+
}
|
|
677
|
+
const canShareFile = f => { try { return !!(navigator.canShare && navigator.canShare({ files: [f] })); } catch (e) { return false; } };
|
|
678
|
+
|
|
679
|
+
/* ---------- MP4 de verdade: H.264 pelo WebCodecs e um muxer mínimo (moov no início, sem fragmentos) ---------- */
|
|
680
|
+
const FPS = 30;
|
|
681
|
+
function mp4Mux(samples, avcC, w, h) {
|
|
682
|
+
const u32 = n => [(n >>> 24) & 255, (n >>> 16) & 255, (n >>> 8) & 255, n & 255], u16 = n => [(n >> 8) & 255, n & 255];
|
|
683
|
+
const str = s => [...s].map(ch => ch.charCodeAt(0));
|
|
684
|
+
const box = (type, ...parts) => { const body = parts.flat(Infinity), out = new Uint8Array(8 + body.length); out.set(u32(8 + body.length)); out.set(str(type), 4); out.set(body, 8); return [...out]; };
|
|
685
|
+
const full = (type, v, flags, ...parts) => box(type, [v, (flags >> 16) & 255, (flags >> 8) & 255, flags & 255], ...parts);
|
|
686
|
+
const matrix = [0x00010000, 0, 0, 0, 0x00010000, 0, 0, 0, 0x40000000].map(u32);
|
|
687
|
+
const n = samples.length, TS = FPS * 1000, durTS = n * 1000, durMs = Math.round(n * 1000 / FPS);
|
|
688
|
+
const moov = off => box('moov',
|
|
689
|
+
full('mvhd', 0, 0, u32(0), u32(0), u32(1000), u32(durMs), u32(0x00010000), u16(0x0100), Array(10).fill(0), matrix, Array(24).fill(0), u32(2)),
|
|
690
|
+
box('trak',
|
|
691
|
+
full('tkhd', 0, 3, u32(0), u32(0), u32(1), u32(0), u32(durMs), Array(8).fill(0), u16(0), u16(0), u16(0), u16(0), matrix, u32(w << 16), u32(h << 16)),
|
|
692
|
+
box('mdia',
|
|
693
|
+
full('mdhd', 0, 0, u32(0), u32(0), u32(TS), u32(durTS), u16(0x55C4), u16(0)),
|
|
694
|
+
full('hdlr', 0, 0, u32(0), str('vide'), Array(12).fill(0), str('VideoHandler'), 0),
|
|
695
|
+
box('minf',
|
|
696
|
+
full('vmhd', 0, 1, Array(8).fill(0)),
|
|
697
|
+
box('dinf', full('dref', 0, 0, u32(1), full('url ', 0, 1))),
|
|
698
|
+
box('stbl',
|
|
699
|
+
full('stsd', 0, 0, u32(1), box('avc1', Array(6).fill(0), u16(1), Array(16).fill(0), u16(w), u16(h), u32(0x00480000), u32(0x00480000), u32(0), u16(1), Array(32).fill(0), u16(0x18), u16(0xFFFF), box('avcC', [...avcC]))),
|
|
700
|
+
full('stts', 0, 0, u32(1), u32(n), u32(1000)),
|
|
701
|
+
full('stss', 0, 0, u32(samples.filter(s => s.key).length), samples.map((s, i) => s.key ? u32(i + 1) : []).flat()),
|
|
702
|
+
full('stsc', 0, 0, u32(1), u32(1), u32(n), u32(1)),
|
|
703
|
+
full('stsz', 0, 0, u32(0), u32(n), samples.map(s => u32(s.data.length)).flat()),
|
|
704
|
+
full('stco', 0, 0, u32(1), u32(off)))))));
|
|
705
|
+
const ftyp = box('ftyp', str('isom'), u32(512), str('isom'), str('iso2'), str('avc1'), str('mp41'));
|
|
706
|
+
const moovLen = moov(0).length, dataLen = samples.reduce((a, s) => a + s.data.length, 0);
|
|
707
|
+
const head = new Uint8Array([...ftyp, ...moov(ftyp.length + moovLen + 8), ...u32(8 + dataLen), ...str('mdat')]);
|
|
708
|
+
const out = new Uint8Array(head.length + dataLen); out.set(head);
|
|
709
|
+
let o = head.length; for (const s of samples) { out.set(s.data, o); o += s.data.length; }
|
|
710
|
+
return out;
|
|
711
|
+
}
|
|
712
|
+
async function encodeMp4(cv, onProgress) {
|
|
713
|
+
if (!window.VideoEncoder || !window.VideoFrame) return null;
|
|
714
|
+
const cfg = { codec: 'avc1.640028', width: VW, height: VH, bitrate: 9e6, framerate: FPS, avc: { format: 'avc' } };
|
|
715
|
+
for (const codec of ['avc1.640028', 'avc1.4d0028', 'avc1.42e028']) {
|
|
716
|
+
cfg.codec = codec;
|
|
717
|
+
try { if ((await VideoEncoder.isConfigSupported(cfg)).supported) break; } catch (e) {}
|
|
718
|
+
if (codec === 'avc1.42e028') return null;
|
|
719
|
+
}
|
|
720
|
+
const samples = []; let avcC = null, err = null, lastTs = -1, reordered = false;
|
|
721
|
+
const enc = new VideoEncoder({
|
|
722
|
+
output: (chunk, meta) => {
|
|
723
|
+
if (meta && meta.decoderConfig && meta.decoderConfig.description) avcC = new Uint8Array(meta.decoderConfig.description);
|
|
724
|
+
if (chunk.timestamp < lastTs) reordered = true; lastTs = chunk.timestamp;
|
|
725
|
+
const data = new Uint8Array(chunk.byteLength); chunk.copyTo(data); samples.push({ data, key: chunk.type === 'key' });
|
|
726
|
+
},
|
|
727
|
+
error: e => { err = e; },
|
|
728
|
+
});
|
|
729
|
+
enc.configure(cfg);
|
|
730
|
+
const ctx = cv.getContext('2d'), N = Math.ceil((TOTAL + .6) * FPS);
|
|
731
|
+
for (let k = 0; k < N; k++) {
|
|
732
|
+
if (err || !recording) break;
|
|
733
|
+
frame(ctx, Math.min(k / FPS, TOTAL));
|
|
734
|
+
const vf = new VideoFrame(cv, { timestamp: Math.round(k * 1e6 / FPS), duration: Math.round(1e6 / FPS) });
|
|
735
|
+
enc.encode(vf, { keyFrame: k % (FPS * 2) === 0 }); vf.close();
|
|
736
|
+
onProgress((k + 1) / N);
|
|
737
|
+
if (enc.encodeQueueSize > 6 || k % 6 === 0) await new Promise(r => setTimeout(r, 0));
|
|
738
|
+
}
|
|
739
|
+
await enc.flush(); enc.close();
|
|
740
|
+
if (err || !recording || !avcC || reordered || samples.length < N) return null;
|
|
741
|
+
return new File([mp4Mux(samples, avcC, VW, VH)], `git-retro-${D.year}.mp4`, { type: 'video/mp4' });
|
|
742
|
+
}
|
|
743
|
+
|
|
744
|
+
/* ---------- janela do vídeo ---------- */
|
|
745
|
+
let mvLoop = 0, videoFile = null, recording = false;
|
|
746
|
+
function mvButtons(list) {
|
|
747
|
+
const box = $('#mva'); box.innerHTML = '';
|
|
748
|
+
list.forEach(([label, fn, ghost]) => { const b = document.createElement('button'); b.className = 'btn' + (ghost ? ' g' : ''); b.textContent = label; b.onclick = fn; box.append(b); });
|
|
749
|
+
}
|
|
750
|
+
function preview(cv) {
|
|
751
|
+
const ctx = cv.getContext('2d'), st = performance.now();
|
|
752
|
+
cancelAnimationFrame(mvLoop);
|
|
753
|
+
const step = now => { frame(ctx, ((now - st) / 1000) % (TOTAL + 1.2)); mvLoop = requestAnimationFrame(step); };
|
|
754
|
+
mvLoop = requestAnimationFrame(step);
|
|
755
|
+
}
|
|
756
|
+
function finished(note) {
|
|
757
|
+
$('#mvt').textContent = T.ready; $('#mvp').style.transform = 'scaleX(1)'; $('#mvs').textContent = note || T.musicTip;
|
|
758
|
+
const acts = [];
|
|
759
|
+
if (videoFile && canShareFile(videoFile)) acts.push([T.postVideo, () => shareFile(videoFile)]);
|
|
760
|
+
if (videoFile) acts.push([T.downloadVideo, () => saveFile(videoFile), acts.length > 0]);
|
|
761
|
+
acts.push([T.download, async () => { const f = await makeCard(); canShareFile(f) && matchMedia('(pointer:coarse)').matches ? shareFile(f) : saveFile(f); }, true]);
|
|
762
|
+
acts.push([T.close, closeMotion, true]);
|
|
763
|
+
mvButtons(acts);
|
|
764
|
+
}
|
|
765
|
+
async function openMotion() {
|
|
766
|
+
held = true; $('#mv').hidden = false; document.body.style.overflow = 'hidden';
|
|
767
|
+
const cv = $('#mvc');
|
|
768
|
+
if (videoFile) { preview(cv); finished(); return; }
|
|
769
|
+
$('#mvt').textContent = T.recording; $('#mvs').textContent = T.keepOpen; $('#mvp').style.transform = 'scaleX(0)';
|
|
770
|
+
mvButtons([[T.close, closeMotion, true]]);
|
|
771
|
+
await prepare();
|
|
772
|
+
recording = true;
|
|
773
|
+
const mp4 = await encodeMp4(cv, k => { $('#mvp').style.transform = `scaleX(${k})`; }).catch(() => null);
|
|
774
|
+
if (!recording) return;
|
|
775
|
+
if (mp4) { recording = false; videoFile = mp4; preview(cv); finished(); return; }
|
|
776
|
+
// sem WebCodecs: grava em tempo real com o MediaRecorder
|
|
777
|
+
const types = ['video/mp4;codecs=avc1.640028', 'video/mp4;codecs=avc1.42E01F', 'video/mp4', 'video/webm;codecs=vp9', 'video/webm;codecs=vp8', 'video/webm'];
|
|
778
|
+
const mime = window.MediaRecorder && cv.captureStream ? types.find(t => MediaRecorder.isTypeSupported(t)) : null;
|
|
779
|
+
if (!mime) { preview(cv); finished(T.noVideo); return; }
|
|
780
|
+
const ctx = cv.getContext('2d'), stream = cv.captureStream(30);
|
|
781
|
+
const rec = new MediaRecorder(stream, { mimeType: mime, videoBitsPerSecond: 12e6 }), chunks = [];
|
|
782
|
+
rec.ondataavailable = e => { if (e.data && e.data.size) chunks.push(e.data); };
|
|
783
|
+
const stopped = new Promise(r => { rec.onstop = r; });
|
|
784
|
+
recording = true; frame(ctx, 0); rec.start(250);
|
|
785
|
+
const st = performance.now();
|
|
786
|
+
await new Promise(res => {
|
|
787
|
+
const step = now => {
|
|
788
|
+
if (!recording) return res();
|
|
789
|
+
const t = (now - st) / 1000; frame(ctx, Math.min(t, TOTAL));
|
|
790
|
+
$('#mvp').style.transform = `scaleX(${clamp(t / (TOTAL + .4))})`;
|
|
791
|
+
if (t < TOTAL + .4) mvLoop = requestAnimationFrame(step); else res();
|
|
792
|
+
};
|
|
793
|
+
mvLoop = requestAnimationFrame(step);
|
|
794
|
+
});
|
|
795
|
+
const cancelled = !recording; recording = false;
|
|
796
|
+
rec.stop(); await stopped; stream.getTracks().forEach(t => t.stop());
|
|
797
|
+
if (cancelled) return;
|
|
798
|
+
const type = mime.split(';')[0], ext = type === 'video/mp4' ? 'mp4' : 'webm';
|
|
799
|
+
videoFile = new File([new Blob(chunks, { type })], `git-retro-${D.year}.${ext}`, { type });
|
|
800
|
+
preview(cv);
|
|
801
|
+
finished(ext === 'webm' ? T.webmNote : '');
|
|
802
|
+
}
|
|
803
|
+
function closeMotion() {
|
|
804
|
+
recording = false; cancelAnimationFrame(mvLoop); $('#mv').hidden = true; document.body.style.overflow = ''; held = false;
|
|
805
|
+
}
|
|
806
|
+
addEventListener('keydown', e => { if (e.key === 'Escape' && !$('#mv').hidden) closeMotion(); });
|
|
807
|
+
go(0); raf = requestAnimationFrame(loop);
|
|
808
|
+
</script>
|
|
809
|
+
</body>
|
|
810
|
+
</html>
|