Commit c02493d

Eric Bower  ·  2024-01-14 17:48:02 -0500 EST
parent 41f93ba
changes
6 files changed,  +624, -28
+7, -2
......@@ -1,6 +1,10 @@
11 REV=$(shell git rev-parse --short HEAD)
22 PROJECT="git-pgit-$(REV)"
33
4+smol:
5+ curl https://pico.sh/smol.css -o ./static/smol.css
6+.PHONY: smol
7+
48 clean:
59 rm -rf ./public
610 .PHONY: clean
......@@ -28,6 +32,7 @@ static: build clean
2832 .PHONY:
2933
3034 deploy:
31- rsync -rv ./public/* erock@pgs.sh:/$(PROJECT)
32- ssh erock@pgs.sh link git-pgit $(PROJECT) --write
35+ rsync -rv ./public/* hey@pgs.sh:/git-pgit-local
36+ # $(PROJECT)
37+ # ssh hey@pgs.sh link git-pgit $(PROJECT) --write
3338 .PHONY: deploy
+1, -2
......@@ -10,8 +10,7 @@
1010
1111 {{template "meta" .}}
1212
13- <link rel="stylesheet" href="https://cdn.jsdelivr.net/gh/devicons/devicon@latest/devicon.min.css">
14- <link rel="stylesheet" href="https://pico.sh/smol.css" />
13+ <link rel="stylesheet" href="/smol.css" />
1514 <link rel="stylesheet" href="/main.css" />
1615 </head>
1716 <body>
+5, -3
......@@ -16,14 +16,16 @@
1616 </div>
1717
1818 {{range .Tree.Items}}
19- <div class="flex justify-between items-center gap p-sm border-b tree-row">
19+ <div class="flex justify-between items-center gap-2 p tree-row border-b">
2020 <div class="flex-1 tree-path flex items-center gap">
2121 {{if .IsDir}}
22- <svg xmlns="http://www.w3.org/2000/svg" height="16" width="16" viewBox="0 0 512 512">
22+ <svg xmlns="http://www.w3.org/2000/svg" fill="currentColor" height="16" width="16" viewBox="0 0 512 512">
2323 <path d="M0 96C0 60.7 28.7 32 64 32H196.1c19.1 0 37.4 7.6 50.9 21.1L289.9 96H448c35.3 0 64 28.7 64 64V416c0 35.3-28.7 64-64 64H64c-35.3 0-64-28.7-64-64V96zM64 80c-8.8 0-16 7.2-16 16V416c0 8.8 7.2 16 16 16H448c8.8 0 16-7.2 16-16V160c0-8.8-7.2-16-16-16H286.6c-10.6 0-20.8-4.2-28.3-11.7L213.1 87c-4.5-4.5-10.6-7-17-7H64z"/>
2424 </svg>
2525 {{else}}
26- <i class="{{.Icon}}"></i>
26+ <svg xmlns="http://www.w3.org/2000/svg" fill="currentColor" height="16" width="16" viewBox="0 0 384 512">
27+ <path d="M320 464c8.8 0 16-7.2 16-16V160H256c-17.7 0-32-14.3-32-32V48H64c-8.8 0-16 7.2-16 16V448c0 8.8 7.2 16 16 16H320zM0 64C0 28.7 28.7 0 64 0H229.5c17 0 33.3 6.7 45.3 18.7l90.5 90.5c12 12 18.7 28.3 18.7 45.3V448c0 35.3-28.7 64-64 64H64c-35.3 0-64-28.7-64-64V64z"/>
28+ </svg>
2729 {{end}}
2830
2931 <a href="{{.URL}}">{{.Name}}</a>
+32, -21
......@@ -24,11 +24,8 @@ import (
2424 "go.uber.org/zap"
2525 )
2626
27-//go:embed static/main.css
28-var mainCss []byte
29-
30-//go:embed static/syntax.css
31-var syntaxCss []byte
27+//go:embed static/*
28+var sfs embed.FS
3229
3330 //go:embed html/*.tmpl
3431 var efs embed.FS
......@@ -120,7 +117,7 @@ type TreeItem struct {
120117 Size string
121118 NumLines int
122119 Name string
123- Icon string
120+ Icon string
124121 Path string
125122 URL template.URL
126123 CommitID string
......@@ -335,10 +332,25 @@ func (c *Config) writeHtml(writeData *WriteData) {
335332 bail(err)
336333 }
337334
338-func (c *Config) copyStatic(dst string, data []byte) {
339- c.Logger.Infof("writing (%s)", dst)
340- err := os.WriteFile(dst, data, 0755)
335+func (c *Config) copyStatic() error {
336+ dir := "static"
337+ entries, err := sfs.ReadDir(dir)
341338 bail(err)
339+
340+ for _, e := range entries {
341+ infp := filepath.Join(dir, e.Name())
342+ if e.IsDir() {
343+ continue
344+ }
345+
346+ w, err := os.ReadFile(infp)
347+ bail(err)
348+ fp := filepath.Join(c.Outdir, e.Name())
349+ c.Logger.Infof("writing (%s)", fp)
350+ os.WriteFile(fp, w, 0755)
351+ }
352+
353+ return nil
342354 }
343355
344356 func (c *Config) writeRootSummary(data *PageData, readme template.HTML) {
......@@ -740,15 +752,18 @@ func FilenameToDevIcon(filename string) string {
740752 ext := filepath.Ext(filename)
741753 extMappr := map[string]string{
742754 ".html": "html5",
743- ".go": "go",
744- ".py": "python",
745- ".css": "css3",
746- ".js": "javascript",
747- ".md": "markdown",
755+ ".go": "go",
756+ ".py": "python",
757+ ".css": "css3",
758+ ".js": "javascript",
759+ ".md": "markdown",
760+ ".ts": "typescript",
761+ ".tsx": "react",
762+ ".jsx": "react",
748763 }
749764
750- nameMappr := map[string]string {
751- "Makefile": "cmake",
765+ nameMappr := map[string]string{
766+ "Makefile": "cmake",
752767 "Dockerfile": "docker",
753768 }
754769
......@@ -890,9 +905,7 @@ func (c *Config) writeRevision(repo *git.Repository, pageData *PageData, refs []
890905 if pageSize == 0 {
891906 pageSize = 5000
892907 }
893- fmt.Println("grabbing commits")
894908 commits, err := repo.CommitsByPage(pageData.RevData.ID(), 0, pageSize)
895- fmt.Println("got commits")
896909 bail(err)
897910
898911 logs := []*CommitData{}
......@@ -1058,9 +1071,7 @@ func main() {
10581071 }
10591072
10601073 config.writeRepo()
1061-
1062- config.copyStatic(filepath.Join(config.Outdir, "main.css"), mainCss)
1063- config.copyStatic(filepath.Join(config.Outdir, "syntax.css"), syntaxCss)
1074+ config.copyStatic()
10641075
10651076 url := filepath.Join("/", "index.html")
10661077 config.Logger.Info(url)
+4, -0
......@@ -1,3 +1,7 @@
1+.border-b {
2+ border-bottom: 1px solid var(--grey);
3+}
4+
15 body {
26 max-width: 900px;
37 }
+575, -0
......@@ -0,0 +1,575 @@
1+*,
2+::before,
3+::after {
4+ box-sizing: border-box;
5+}
6+
7+::-moz-focus-inner {
8+ border-style: none;
9+ padding: 0;
10+}
11+:-moz-focusring {
12+ outline: 1px dotted ButtonText;
13+}
14+:-moz-ui-invalid {
15+ box-shadow: none;
16+}
17+
18+@media (prefers-color-scheme: light) {
19+ :root {
20+ --main-hue: 250;
21+ --white: #6a737d;
22+ --code: #fff8d3;
23+ --code-border: #f0d547;
24+ --pre: #f6f8fa;
25+ --bg-color: #fff;
26+ --text-color: #24292f;
27+ --link-color: #005cc5;
28+ --visited: #6f42c1;
29+ --blockquote: #005cc5;
30+ --blockquote-bg: #fff;
31+ --hover: #d73a49;
32+ --grey: #ccc;
33+ --grey-light: #6a708e;
34+ --shadow: #252525;
35+ }
36+}
37+
38+@media (prefers-color-scheme: dark) {
39+ :root {
40+ --main-hue: 250;
41+ --white: #f2f2f2;
42+ --code: #414558;
43+ --code-border: #252525;
44+ --pre: #252525;
45+ --bg-color: #282a36;
46+ --text-color: #f2f2f2;
47+ --link-color: #8be9fd;
48+ --visited: #bd93f9;
49+ --blockquote: #bd93f9;
50+ --blockquote-bg: #414558;
51+ --hover: #ff80bf;
52+ --grey: #414558;
53+ --grey-light: #6a708e;
54+ --shadow: #252525;
55+ }
56+}
57+
58+html {
59+ background-color: var(--bg-color);
60+ color: var(--text-color);
61+ font-size: 18px;
62+ line-height: 1.5;
63+ font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen,
64+ Ubuntu, Cantarell, "Fira Sans", "Droid Sans", "Helvetica Neue", Arial,
65+ sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol";
66+ -webkit-text-size-adjust: 100%;
67+ -moz-tab-size: 4;
68+ tab-size: 4;
69+}
70+
71+body {
72+ margin: 0 auto;
73+}
74+
75+img {
76+ max-width: 100%;
77+ height: auto;
78+}
79+
80+b,
81+strong {
82+ font-weight: bold;
83+}
84+
85+code,
86+kbd,
87+samp,
88+pre {
89+ font-family: ui-monospace, SFMono-Regular, Consolas, "Liberation Mono", Menlo,
90+ monospace;
91+}
92+
93+code,
94+kbd,
95+samp {
96+ background-color: var(--code);
97+ border: 1px solid var(--code-border);
98+}
99+
100+pre > code {
101+ background-color: inherit;
102+ padding: 0;
103+ border: none;
104+}
105+
106+code {
107+ border-radius: 0.3rem;
108+ padding: 0.15rem 0.2rem 0.05rem;
109+}
110+
111+pre {
112+ border-radius: 5px;
113+ padding: 1rem;
114+ margin: 1rem 0;
115+ overflow-x: auto;
116+ background-color: var(--pre) !important;
117+}
118+
119+small {
120+ font-size: 0.8rem;
121+}
122+
123+summary {
124+ display: list-item;
125+}
126+
127+h1,
128+h2,
129+h3 {
130+ margin: 0;
131+ padding: 0.6rem 0 0 0;
132+ border: 0;
133+ font-style: normal;
134+ font-weight: inherit;
135+ font-size: inherit;
136+}
137+
138+h1 > code {
139+ font-size: inherit;
140+}
141+
142+h2 > code {
143+ font-size: inherit;
144+}
145+
146+h3 > code {
147+ font-size: inherit;
148+}
149+
150+path {
151+ fill: var(--text-color);
152+ stroke: var(--text-color);
153+}
154+
155+hr {
156+ color: inherit;
157+ border: 0;
158+ margin: 0;
159+ height: 1px;
160+ background: var(--grey);
161+ margin: 1rem auto;
162+ text-align: center;
163+}
164+
165+a {
166+ text-decoration: underline;
167+ color: var(--link-color);
168+}
169+
170+a:hover,
171+a:visited:hover {
172+ color: var(--hover);
173+}
174+
175+a:visited {
176+ color: var(--visited);
177+}
178+
179+a.link-grey {
180+ text-decoration: underline;
181+ color: var(--white);
182+}
183+
184+a.link-grey:visited {
185+ color: var(--white);
186+}
187+
188+section {
189+ margin-bottom: 1.4rem;
190+}
191+
192+section:last-child {
193+ margin-bottom: 0;
194+}
195+
196+header {
197+ margin: 1rem auto;
198+}
199+
200+p {
201+ margin: 0.8rem 0;
202+}
203+
204+article {
205+ overflow-wrap: break-word;
206+}
207+
208+blockquote {
209+ border-left: 5px solid var(--blockquote);
210+ background-color: var(--blockquote-bg);
211+ padding: 0.8rem;
212+ margin: 1rem 0;
213+}
214+
215+blockquote > p {
216+ margin: 0;
217+}
218+
219+ul,
220+ol {
221+ padding: 0 0 0 2rem;
222+ list-style-position: outside;
223+}
224+
225+ul[style*="list-style-type: none;"] {
226+ padding: 0;
227+}
228+
229+li {
230+ margin: 0.5rem 0;
231+}
232+
233+li > pre {
234+ padding: 0;
235+}
236+
237+footer {
238+ text-align: center;
239+ margin-bottom: 4rem;
240+}
241+
242+dt {
243+ font-weight: bold;
244+}
245+
246+dd {
247+ margin-left: 0;
248+}
249+
250+dd:not(:last-child) {
251+ margin-bottom: 0.5rem;
252+}
253+
254+figure {
255+ margin: 0;
256+}
257+
258+.container {
259+ max-width: 900px;
260+ width: 100%;
261+}
262+
263+.container-center {
264+ width: 100%;
265+ height: 100%;
266+ display: flex;
267+ justify-content: center;
268+}
269+
270+.text-3xl {
271+ font-size: 3rem;
272+}
273+
274+.text-2xl {
275+ font-size: 1.85rem;
276+ line-height: 1.15;
277+}
278+
279+.text-xl {
280+ font-size: 1.55rem;
281+ line-height: 1.15;
282+}
283+
284+.text-lg {
285+ font-size: 1.35rem;
286+ line-height: 1.15;
287+}
288+
289+.text-md {
290+ font-size: 1.15rem;
291+ line-height: 1.15;
292+}
293+
294+.text-sm {
295+ font-size: 0.875rem;
296+}
297+
298+.text-center {
299+ text-align: center;
300+}
301+
302+.text-underline {
303+ border-bottom: 3px solid var(--text-color);
304+ padding-bottom: 3px;
305+}
306+
307+.font-bold {
308+ font-weight: bold;
309+}
310+
311+.font-italic {
312+ font-style: italic;
313+}
314+
315+.inline {
316+ display: inline;
317+}
318+
319+.inline-block {
320+ display: inline-block;
321+}
322+
323+.max-w-half {
324+ max-width: 50%;
325+}
326+
327+.flex {
328+ display: flex;
329+}
330+
331+.flex-col {
332+ flex-direction: column;
333+}
334+
335+.items-center {
336+ align-items: center;
337+}
338+
339+.m-0 {
340+ margin: 0;
341+}
342+
343+.mt {
344+ margin-top: 0.5rem;
345+}
346+
347+.mt-2 {
348+ margin-top: 1rem;
349+}
350+
351+.mt-4 {
352+ margin-top: 2rem;
353+}
354+
355+.mt-8 {
356+ margin-top: 4rem;
357+}
358+
359+.mb {
360+ margin-bottom: 0.5rem;
361+}
362+
363+.mb-2 {
364+ margin-bottom: 1rem;
365+}
366+
367+.mb-4 {
368+ margin-bottom: 2rem;
369+}
370+
371+.mb-8 {
372+ margin-bottom: 4rem;
373+}
374+
375+.mb-16 {
376+ margin-bottom: 8rem;
377+}
378+
379+.mr {
380+ margin-right: 0.5rem;
381+}
382+
383+.ml-sm {
384+ margin-left: 0.25rem;
385+}
386+
387+.ml {
388+ margin-left: 0.5rem;
389+}
390+
391+.my {
392+ margin-top: 0.5rem;
393+ margin-bottom: 0.5rem;
394+}
395+
396+.my-2 {
397+ margin-top: 1rem;
398+ margin-bottom: 1rem;
399+}
400+
401+.my-4 {
402+ margin-top: 2rem;
403+ margin-bottom: 2rem;
404+}
405+
406+.my-8 {
407+ margin-top: 4rem;
408+ margin-bottom: 4rem;
409+}
410+
411+.mx {
412+ margin-left: 0.5rem;
413+ margin-right: 0.5rem;
414+}
415+
416+.mx-2 {
417+ margin-left: 1rem;
418+ margin-right: 1rem;
419+}
420+
421+.p-0 {
422+ padding: 0;
423+}
424+
425+.py {
426+ padding-top: 0.5rem;
427+ padding-bottom: 0.5rem;
428+}
429+
430+.py-2 {
431+ padding-top: 1rem;
432+ padding-bottom: 1rem;
433+}
434+
435+.py-4 {
436+ padding-top: 2rem;
437+ padding-bottom: 2rem;
438+}
439+
440+.py-8 {
441+ padding-top: 4rem;
442+ padding-bottom: 4rem;
443+}
444+
445+.justify-between {
446+ justify-content: space-between;
447+}
448+
449+.justify-center {
450+ justify-content: center;
451+}
452+
453+.gap {
454+ gap: 0.5rem;
455+}
456+
457+.gap-2 {
458+ gap: 1rem;
459+}
460+
461+.group {
462+ display: flex;
463+ flex-direction: column;
464+ gap: 0.5rem;
465+}
466+
467+.group-h {
468+ display: flex;
469+ gap: 0.5rem;
470+ align-items: center;
471+}
472+
473+.flex-1 {
474+ flex: 1;
475+}
476+
477+.items-end {
478+ align-items: end;
479+}
480+
481+.items-start {
482+ align-items: start;
483+}
484+
485+.justify-end {
486+ justify-content: end;
487+}
488+
489+.font-grey-light {
490+ color: var(--grey-light);
491+}
492+
493+.hidden {
494+ display: none;
495+}
496+
497+.align-right {
498+ text-align: right;
499+}
500+
501+/* ==== HELPERS ==== */
502+
503+.logo-header {
504+ line-height: 1;
505+ display: inline-block;
506+ background-image: linear-gradient(to right, #FF5555, #FF79C6, #F8F859);
507+ color: transparent;
508+ background-clip: text;
509+ border: 3px solid #FF79C6;
510+ padding: 8px 10px 10px 10px;
511+ border-radius: 10px;
512+ box-shadow: 0px 5px 0px 0px var(--shadow);
513+}
514+
515+.btn-icon {
516+ border: 3px solid hsl(var(--main-hue), 92%, 66%);
517+ background-color: hsl(var(--main-hue), 92%, 66%);
518+ padding: 0.25rem 0.3rem;
519+ border-radius: 0.25rem;
520+ box-shadow: 0px 5px 0px 0px var(--shadow);
521+ color: var(--white);
522+ cursor: pointer;
523+}
524+
525+.btn-link {
526+ border: 3px solid hsl(var(--main-hue), 92%, 66%);
527+ background-color: hsl(var(--main-hue), 92%, 66%);
528+ padding: 0.5rem 1rem;
529+ border-radius: 0.25rem;
530+ box-shadow: 0px 5px 0px 0px var(--shadow);
531+ color: var(--white);
532+ text-decoration: none;
533+ font-weight: bold;
534+}
535+
536+.btn-link:visited:hover,
537+.btn-link:hover {
538+ border: 3px solid hsl(260, 92%, 66%);
539+ background-color: hsl(260, 92%, 66%);
540+ color: var(--white);
541+ transform: scale(.98, .98);
542+}
543+
544+.btn-link:visited {
545+ color: var(--white);
546+}
547+
548+.box {
549+ border: 2px solid var(--grey-light);
550+ border-radius: .5rem;
551+ padding: 1rem;
552+ text-decoration: none;
553+ box-shadow: 0px 5px 0px 0px var(--shadow);
554+ color: var(--white);
555+}
556+
557+.box:hover {
558+ border: 2px solid var(--white);
559+}
560+
561+.box:visited,
562+.box:visited:hover,
563+.box:hover {
564+ color: var(--white);
565+}
566+
567+@media only screen and (max-width: 600px) {
568+ body {
569+ padding: 0 1rem;
570+ }
571+
572+ header {
573+ margin: 0;
574+ }
575+}