dashboard / erock/git-pr / feat: static assets #3 rss

accepted · opened on 2024-07-19T14:53:23Z by erock
Help
checkout latest patchset:
ssh pr.pico.sh print pr-3 | git am -3
checkout any patchset in a patch request:
ssh pr.pico.sh print ps-X | git am -3
add changes to patch request:
git format-patch main --stdout | ssh pr.pico.sh pr add 3
add review to patch request:
git format-patch main --stdout | ssh pr.pico.sh pr add --review 3
accept PR:
ssh pr.pico.sh pr accept 3
close PR:
ssh pr.pico.sh pr close 3

Logs

erock created pr with ps-3 on 2024-07-19T14:53:23Z
erock added ps-4 on 2024-07-19T14:55:48Z
jolheiser reviewed pr with ps-5 on 2024-07-19T15:42:29Z
jolheiser changed status on 2024-07-19T15:42:29Z {"status":"reviewed"}
erock added ps-9 on 2024-07-19T17:43:47Z
jolheiser changed status on 2024-07-19T18:27:53Z {"status":"accepted"}

Patchsets

ps-3 by erock on 2024-07-19T14:53:23Z
Range Diff ↕ rd-4
2: 8919af5 ! 1: 66cafc6 feat: static assets folder
1: 3b99dc0 ! 2: 5e76ed3 fix(cli): access control for removing patchsets
3: 7346122 < -: ------- chore: create patch for smol
4: d8792d5 < -: ------- feat: static folder
ps-4 by erock on 2024-07-19T14:55:48Z
Range Diff ↕ rd-5
1: 66cafc6 = 1: cc56ea1 feat: static assets folder
2: 5e76ed3 < -: ------- fix(cli): access control for removing patchsets
-: ------- > 2: ef749a4 review: typo and future enhancement comment
ps-5 by jolheiser on 2024-07-19T15:42:29Z
Range Diff ↕ rd-9
1: cc56ea1 = 1: 0467f9e feat: static assets folder
2: ef749a4 = 2: da1730f review: typo and future enhancement comment
-: ------- > 3: c038404 refactor: per-file override for static folder
ps-9 by erock on 2024-07-19T17:43:47Z

Patchset ps-4

feat: static assets folder

Eric Bower
2024-07-19T04:27:17Z
Makefile
+5 -0
ssh.go
+1 -1
static/smol.css
+726 -0
web.go
+68 -1

fix(cli): access control for removing patchsets

Eric Bower
2024-07-19T16:20:18Z
cli.go
+30 -6
pr.go
+11 -0
Back to top

feat: static assets folder

Create a static folder that will be served as-is with the ability for
users to bring-their-own static folder.

If we detect `data_dir/static/` we will serve that instead of the
embedded one we provide by default.
Makefile link
+5 -0
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
diff --git a/Makefile b/Makefile
index cb3a367..e521f82 100644
--- a/Makefile
+++ b/Makefile
@@ -26,3 +26,8 @@ bp: bp-setup
 	$(DOCKER_BUILDX_BUILD) -t "ghcr.io/picosh/pico/git-ssh:$(DOCKER_TAG)" --target release-ssh .
 	$(DOCKER_BUILDX_BUILD) -t "ghcr.io/picosh/pico/git-web:$(DOCKER_TAG)" --target release-web .
 .PHONY: bp
+
+smol:
+	curl https://pico.sh/smol.css -o ./static/smol.css
+	cat patches/smol.diff | git apply
+.PHONY: smol
patches/smol.diff link
+53 -0
 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
diff --git a/patches/smol.diff b/patches/smol.diff
new file mode 100644
index 0000000..ae2df55
--- /dev/null
+++ b/patches/smol.diff
@@ -0,0 +1,53 @@
+diff --git a/static/smol.css b/static/smol.css
+index e9b59ec..9e9d925 100644
+--- a/static/smol.css
++++ b/static/smol.css
+@@ -15,48 +15,6 @@
+   box-shadow: none;
+ }
+ 
+-@media (prefers-color-scheme: light) {
+-  :root {
+-    --main-hue: 250;
+-    --white: #2e3f53;
+-    --white-light: #cfe0f4;
+-    --white-dark: #6c6a6a;
+-    --code: #52576f;
+-    --pre: #e1e7ee;
+-    --bg-color: #f4f4f4;
+-    --text-color: #24292f;
+-    --link-color: #005cc5;
+-    --visited: #6f42c1;
+-    --blockquote: #005cc5;
+-    --blockquote-bg: #cfe0f4;
+-    --hover: #c11e7a;
+-    --grey: #ccc;
+-    --grey-light: #6a708e;
+-    --shadow: #e8e8e8;
+-  }
+-}
+-
+-@media (prefers-color-scheme: dark) {
+-  :root {
+-    --main-hue: 250;
+-    --white: #f2f2f2;
+-    --white-light: #f2f2f2;
+-    --white-dark: #e8e8e8;
+-    --code: #414558;
+-    --pre: #252525;
+-    --bg-color: #282a36;
+-    --text-color: #f2f2f2;
+-    --link-color: #8be9fd;
+-    --visited: #bd93f9;
+-    --blockquote: #bd93f9;
+-    --blockquote-bg: #353548;
+-    --hover: #ff80bf;
+-    --grey: #414558;
+-    --grey-light: #6a708e;
+-    --shadow: #252525;
+-  }
+-}
+-
+ html {
+   background-color: var(--bg-color);
+   color: var(--text-color);
ssh.go link
+1 -1
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
diff --git a/ssh.go b/ssh.go
index 1fb34d0..3e5e407 100644
--- a/ssh.go
+++ b/ssh.go
@@ -35,7 +35,7 @@ func GitSshServer(cfg *GitCfg) {
 	dbpath := filepath.Join(cfg.DataDir, "pr.db")
 	dbh, err := Open(dbpath, cfg.Logger)
 	if err != nil {
-		panic(fmt.Sprintf("cannot find database file, check folder and perms: %s", dbpath))
+		panic(fmt.Sprintf("cannot find database file, check folder and perms: %s: %s", dbpath, err))
 	}
 
 	be := &Backend{
static/smol.css link
+726 -0
  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
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
diff --git a/static/smol.css b/static/smol.css
new file mode 100644
index 0000000..9e9d925
--- /dev/null
+++ b/static/smol.css
@@ -0,0 +1,726 @@
+*,
+::before,
+::after {
+  box-sizing: border-box;
+}
+
+::-moz-focus-inner {
+  border-style: none;
+  padding: 0;
+}
+:-moz-focusring {
+  outline: 1px dotted ButtonText;
+}
+:-moz-ui-invalid {
+  box-shadow: none;
+}
+
+html {
+  background-color: var(--bg-color);
+  color: var(--text-color);
+  font-size: 18px;
+  line-height: 1.5;
+  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen,
+    Ubuntu, Cantarell, "Fira Sans", "Droid Sans", "Helvetica Neue", Arial,
+    sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol";
+  -webkit-text-size-adjust: 100%;
+  -moz-tab-size: 4;
+  -o-tab-size: 4;
+  tab-size: 4;
+}
+
+body {
+  margin: 0 auto;
+}
+
+img {
+  max-width: 100%;
+  height: auto;
+}
+
+b,
+strong {
+  font-weight: bold;
+}
+
+code,
+kbd,
+samp,
+pre {
+  font-family: ui-monospace, SFMono-Regular, Consolas, "Liberation Mono", Menlo,
+    monospace;
+}
+
+code,
+kbd,
+samp {
+  border: 2px solid var(--code);
+}
+
+pre > code {
+  background-color: inherit;
+  padding: 0;
+  border: none;
+}
+
+code {
+  font-size: 90%;
+  border-radius: 0.3rem;
+  padding: 0.1rem 0.3rem;
+}
+
+pre {
+  font-size: 14px;
+  border-radius: 5px;
+  padding: 1rem;
+  margin: 1rem 0;
+  overflow-x: auto;
+  background-color: var(--pre) !important;
+}
+
+small {
+  font-size: 0.8rem;
+}
+
+summary {
+  display: list-item;
+  cursor: pointer;
+}
+
+h1,
+h2,
+h3,
+h4 {
+  margin: 0;
+  padding: 0.5rem 0 0 0;
+  border: 0;
+  font-style: normal;
+  font-weight: inherit;
+  font-size: inherit;
+}
+
+path {
+  fill: var(--text-color);
+  stroke: var(--text-color);
+}
+
+hr {
+  color: inherit;
+  border: 0;
+  margin: 0;
+  height: 2px;
+  background: var(--grey);
+  margin: 1rem auto;
+  text-align: center;
+}
+
+a {
+  text-decoration: none;
+  color: var(--link-color);
+}
+
+a:hover,
+a:visited:hover {
+  text-decoration: underline;
+  color: var(--hover);
+}
+
+a:visited {
+  color: var(--visited);
+}
+
+a.link-grey {
+  text-decoration: underline;
+  color: var(--white);
+}
+
+a.link-grey:visited {
+  color: var(--white);
+}
+
+section {
+  margin-bottom: 1.4rem;
+}
+
+section:last-child {
+  margin-bottom: 0;
+}
+
+header {
+  margin: 1rem auto;
+}
+
+p {
+  margin: 0.5rem 0;
+}
+
+article {
+  overflow-wrap: break-word;
+}
+
+blockquote {
+  border-left: 5px solid var(--blockquote);
+  background-color: var(--blockquote-bg);
+  padding: 0.5rem 0.75rem;
+  margin: 0.5rem 0;
+}
+
+blockquote > p {
+  margin: 0;
+}
+
+blockquote code {
+  border: 1px solid var(--blockquote);
+}
+
+ul,
+ol {
+  padding: 0 0 0 1rem;
+  list-style-position: outside;
+}
+
+ul[style*="list-style-type: none;"] {
+  padding: 0;
+}
+
+li {
+  margin: 0.5rem 0;
+}
+
+li > pre {
+  padding: 0;
+}
+
+footer {
+  text-align: center;
+  margin-bottom: 4rem;
+}
+
+dt {
+  font-weight: bold;
+}
+
+dd {
+  margin-left: 0;
+}
+
+dd:not(:last-child) {
+  margin-bottom: 0.5rem;
+}
+
+figure {
+  margin: 0;
+}
+
+.container {
+  max-width: 50em;
+  width: 100%;
+}
+
+.container-sm {
+  max-width: 40em;
+  width: 100%;
+}
+
+.container-center {
+  width: 100%;
+  height: 100%;
+  display: flex;
+  justify-content: center;
+}
+
+.mono {
+  font-family: ui-monospace, SFMono-Regular, Consolas, "Liberation Mono", Menlo,
+    monospace;
+}
+
+.link-alt-adj,
+.link-alt-adj:visited,
+.link-alt-adj:visited:hover,
+.link-alt-adj:hover {
+  color: var(--link-color);
+  text-decoration: none;
+}
+
+.link-alt-adj:visited:hover,
+.link-alt-adj:hover {
+  text-decoration: underline;
+}
+
+.link-alt-hover,
+.link-alt-hover:visited,
+.link-alt-hover:visited:hover,
+.link-alt-hover:hover {
+  color: var(--hover);
+  text-decoration: none;
+}
+
+.link-alt-hover:visited:hover,
+.link-alt-hover:hover {
+  text-decoration: underline;
+}
+
+.link-alt,
+.link-alt:visited,
+.link-alt:visited:hover,
+.link-alt:hover {
+  color: var(--white);
+  text-decoration: none;
+}
+
+.link-alt:visited:hover,
+.link-alt:hover {
+  text-decoration: underline;
+}
+
+.text-3xl {
+  font-size: 2.5rem;
+}
+
+.text-2xl {
+  font-size: 1.9rem;
+  line-height: 1.15;
+}
+
+.text-xl {
+  font-size: 1.55rem;
+  line-height: 1.15;
+}
+
+.text-lg {
+  font-size: 1.35rem;
+  line-height: 1.15;
+}
+
+.text-md {
+  font-size: 1.15rem;
+  line-height: 1.15;
+}
+
+.text-sm {
+  font-size: 0.875rem;
+}
+
+.text-xs {
+  font-size: 0.775rem;
+}
+
+.cursor-pointer {
+  cursor: pointer;
+}
+
+.w-full {
+  width: 100%;
+}
+
+.h-full {
+  height: 100%;
+}
+
+.border {
+  border: 2px solid var(--grey-light);
+}
+
+.text-left {
+  text-align: left;
+}
+
+.text-center {
+  text-align: center;
+}
+
+.text-underline {
+  border-bottom: 3px solid var(--text-color);
+  padding-bottom: 3px;
+}
+
+.text-hdr {
+  color: var(--hover);
+}
+
+.text-underline-hdr {
+  border-bottom: 3px solid var(--hover);
+  padding-bottom: 3px;
+}
+
+.font-bold {
+  font-weight: bold;
+}
+
+.font-italic {
+  font-style: italic;
+}
+
+.inline {
+  display: inline;
+}
+
+.inline-block {
+  display: inline-block;
+}
+
+.max-w-half {
+  max-width: 50%;
+}
+
+.h-screen {
+  height: 100vh;
+}
+
+.w-screen {
+  width: 100vw;
+}
+
+.flex {
+  display: flex;
+}
+
+.flex-col {
+  flex-direction: column;
+}
+
+.items-center {
+  align-items: center;
+}
+
+.m-0 {
+  margin: 0;
+}
+
+.mt {
+  margin-top: 0.5rem;
+}
+
+.mt-2 {
+  margin-top: 1rem;
+}
+
+.mt-4 {
+  margin-top: 2rem;
+}
+
+.mt-8 {
+  margin-top: 4rem;
+}
+
+.mb {
+  margin-bottom: 0.5rem;
+}
+
+.mb-2 {
+  margin-bottom: 1rem;
+}
+
+.mb-4 {
+  margin-bottom: 2rem;
+}
+
+.mb-8 {
+  margin-bottom: 4rem;
+}
+
+.mb-16 {
+  margin-bottom: 8rem;
+}
+
+.mr {
+  margin-right: 0.5rem;
+}
+
+.ml-sm {
+  margin-left: 0.25rem;
+}
+
+.ml {
+  margin-left: 0.5rem;
+}
+
+.pt-0 {
+  padding-top: 0;
+}
+
+.my {
+  margin-top: 0.5rem;
+  margin-bottom: 0.5rem;
+}
+
+.my-2 {
+  margin-top: 1rem;
+  margin-bottom: 1rem;
+}
+
+.my-4 {
+  margin-top: 2rem;
+  margin-bottom: 2rem;
+}
+
+.my-8 {
+  margin-top: 4rem;
+  margin-bottom: 4rem;
+}
+
+.mx {
+  margin-left: 0.5rem;
+  margin-right: 0.5rem;
+}
+
+.mx-2 {
+  margin-left: 1rem;
+  margin-right: 1rem;
+}
+
+.m-1 {
+  margin: 0.5rem;
+}
+
+.p-1 {
+  padding: 0.5rem;
+}
+
+.p-0 {
+  padding: 0;
+}
+
+.px-2 {
+  padding-left: 1rem;
+  padding-right: 1rem;
+}
+
+.px-4 {
+  padding-left: 2rem;
+  padding-right: 2rem;
+}
+
+.py {
+  padding-top: 0.5rem;
+  padding-bottom: 0.5rem;
+}
+
+.py-2 {
+  padding-top: 1rem;
+  padding-bottom: 1rem;
+}
+
+.py-4 {
+  padding-top: 2rem;
+  padding-bottom: 2rem;
+}
+
+.py-8 {
+  padding-top: 4rem;
+  padding-bottom: 4rem;
+}
+
+.justify-between {
+  justify-content: space-between;
+}
+
+.justify-center {
+  justify-content: center;
+}
+
+.gap {
+  gap: 0.5rem;
+}
+
+.gap-2 {
+  gap: 1rem;
+}
+
+.group {
+  display: flex;
+  flex-direction: column;
+  gap: 0.5rem;
+}
+
+.group-2 {
+  display: flex;
+  flex-direction: column;
+  gap: 1rem;
+}
+
+.group-h {
+  display: flex;
+  gap: 0.5rem;
+  align-items: center;
+}
+
+.flex-1 {
+  flex: 1;
+}
+
+.items-end {
+  align-items: end;
+}
+
+.items-start {
+  align-items: start;
+}
+
+.justify-end {
+  justify-content: end;
+}
+
+.font-grey-light {
+  color: var(--grey-light);
+}
+
+.hidden {
+  display: none;
+}
+
+.align-right {
+  text-align: right;
+}
+
+/* ==== MARKDOWN ==== */
+
+.md h1,
+.md h2,
+.md h3,
+.md h4 {
+  padding: 0;
+  margin: 1.5rem 0 0.9rem 0;
+  font-weight: bold;
+}
+
+.md h1 a,
+.md h2 a,
+.md h3 a,
+.md h4 a {
+  color: var(--grey-light);
+  text-decoration: none;
+}
+
+.md h1 {
+  font-size: 1.6rem;
+  line-height: 1.15;
+  border-bottom: 2px solid var(--grey);
+  padding-bottom: 0.7rem;
+}
+
+.md h2 {
+  font-size: 1.3rem;
+  line-height: 1.15;
+  color: var(--white-dark);
+}
+
+.md h3 {
+  font-size: 1.2rem;
+  color: var(--white-dark);
+}
+
+.md h4 {
+  font-size: 1rem;
+  color: var(--white-dark);
+}
+
+/* ==== HELPERS ==== */
+
+.logo-header {
+  line-height: 1;
+  display: inline-block;
+  background-color: #FF79C6;
+  background-image: linear-gradient(to right, #FF5555, #FF79C6, #F8F859);
+  color: transparent;
+  background-clip: text;
+  border: 3px solid #FF79C6;
+  padding: 8px 10px 10px 10px;
+  border-radius: 10px;
+  box-shadow: 0px 5px 0px 0px var(--shadow);
+  background-size: 100%;
+  -webkit-background-clip: text;
+  -moz-background-clip: text;
+  -webkit-text-fill-color: transparent;
+  -moz-text-fill-color: transparent;
+}
+
+.btn {
+  border: 2px solid var(--link-color);
+  color: var(--link-color);
+  padding: 0.4rem 1rem;
+  font-weight: bold;
+  display: inline-block;
+}
+
+.btn-link,
+.btn-link:visited {
+  border: 2px solid var(--link-color);
+  color: var(--link-color);
+  padding: 0.4rem 1rem;
+  text-decoration: none;
+  font-weight: bold;
+  display: inline-block;
+}
+
+.btn-link:visited:hover,
+.btn-link:hover {
+  border: 2px solid var(--hover);
+}
+
+.btn-link-alt,
+.btn-link-alt:visited {
+  border: 2px solid var(--white);
+  color: var(--white);
+}
+
+.box {
+  border: 2px solid var(--grey-light);
+  padding: 0.5rem 0.75rem;
+}
+
+.box-sm {
+  border: 2px solid var(--grey-light);
+  padding: 0.15rem 0.35rem;
+}
+
+.box-alert {
+  border: 2px solid var(--hover);
+  padding: 0.5rem 0.75rem;
+}
+
+.box-sm-alert {
+  border: 2px solid var(--hover);
+  padding: 0.15rem 0.35rem;
+}
+
+.list-none {
+  list-style-type: none;
+}
+
+.list-disc {
+  list-style-type: disc;
+}
+
+.list-decimal {
+  list-style-type: decimal;
+}
+
+.pill {
+  border: 1px solid var(--link-color);
+  color: var(--link-color);
+}
+
+.pill-alert {
+  border: 1px solid var(--hover);
+  color: var(--hover);
+}
+
+.pill-info {
+  border: 1px solid var(--visited);
+  color: var(--visited);
+}
+
+@media only screen and (max-width: 40em) {
+  body {
+    padding: 0 1rem;
+  }
+
+  header {
+    margin: 0;
+  }
+
+  .flex-collapse {
+    flex-direction: column;
+  }
+}
static/vars.css link
+18 -0
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
diff --git a/static/vars.css b/static/vars.css
new file mode 100644
index 0000000..6300534
--- /dev/null
+++ b/static/vars.css
@@ -0,0 +1,18 @@
+:root {
+  --main-hue: 250;
+  --white: #f2f2f2;
+  --white-light: #f2f2f2;
+  --white-dark: #e8e8e8;
+  --code: #414558;
+  --pre: #252525;
+  --bg-color: #282a36;
+  --text-color: #f2f2f2;
+  --link-color: #8be9fd;
+  --visited: #bd93f9;
+  --blockquote: #bd93f9;
+  --blockquote-bg: #353548;
+  --hover: #ff80bf;
+  --grey: #414558;
+  --grey-light: #6a708e;
+  --shadow: #252525;
+}
tmpl/base.html link
+3 -2
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
diff --git a/tmpl/base.html b/tmpl/base.html
index a656cd5..b5f5fb3 100644
--- a/tmpl/base.html
+++ b/tmpl/base.html
@@ -9,8 +9,9 @@
     <meta name="keywords" content="git, collaboration, patch, requests" />
     {{template "meta" .}}
 
-    <link rel="stylesheet" href="https://pico.sh/smol.css" />
-    <link rel="stylesheet" href="https://pico.sh/syntax.css" />
+    <link rel="stylesheet" href="/static/smol.css" />
+    <link rel="stylesheet" href="/static/vars.css" />
+    <link rel="stylesheet" href="/syntax.css" />
   </head>
   <body class="container">{{template "body" .}}</body>
 </html>
web.go link
+68 -1
  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
diff --git a/web.go b/web.go
index 4e782c8..99bfec6 100644
--- a/web.go
+++ b/web.go
@@ -6,8 +6,12 @@ import (
 	"embed"
 	"fmt"
 	"html/template"
+	"io"
+	"io/fs"
 	"log/slog"
+	"mime"
 	"net/http"
+	"os"
 	"path/filepath"
 	"slices"
 	"strconv"
@@ -23,6 +27,9 @@ import (
 //go:embed tmpl/*
 var tmplFS embed.FS
 
+//go:embed static/*
+var staticFS embed.FS
+
 type WebCtx struct {
 	Pr        *PrCmd
 	Backend   *Backend
@@ -618,13 +625,68 @@ func chromaStyleHandler(w http.ResponseWriter, r *http.Request) {
 	}
 }
 
+func serveFile(staticfs fs.FS) func(w http.ResponseWriter, r *http.Request) {
+	return func(w http.ResponseWriter, r *http.Request) {
+		web, err := getWebCtx(r)
+		if err != nil {
+			w.WriteHeader(http.StatusUnprocessableEntity)
+			return
+		}
+		logger := web.Logger
+
+		file := r.PathValue("file")
+		logger.Info("serving file", "file", file, "fs", staticfs)
+		reader, err := staticfs.Open(file)
+		if err != nil {
+			logger.Error(err.Error())
+			http.Error(w, "file not found", 404)
+			return
+		}
+		contents, err := io.ReadAll(reader)
+		if err != nil {
+			logger.Error(err.Error())
+			http.Error(w, "file not found", 404)
+			return
+		}
+		contentType := mime.TypeByExtension(filepath.Ext(file))
+		if contentType == "" {
+			contentType = http.DetectContentType(contents)
+		}
+		w.Header().Add("Content-Type", contentType)
+
+		_, err = w.Write(contents)
+		if err != nil {
+			logger.Error(err.Error())
+			http.Error(w, "server error", 500)
+			return
+		}
+	}
+}
+
+func getFileSystem(logger *slog.Logger, ffs embed.FS, datadir string, dirName string) (fs.FS, error) {
+	dir := filepath.Join(datadir, dirName)
+	_, err := os.Stat(dir)
+	if err == nil {
+		logger.Info("found folder in data_dir", "dir", dir)
+		return os.DirFS(dir), nil
+	}
+
+	logger.Info("using embeded folder", "dir", dir)
+	fsys, err := fs.Sub(ffs, dirName)
+	if err != nil {
+		return nil, err
+	}
+
+	return fsys, nil
+}
+
 func StartWebServer(cfg *GitCfg) {
 	addr := fmt.Sprintf("%s:%s", cfg.Host, cfg.WebPort)
 
 	dbpath := filepath.Join(cfg.DataDir, "pr.db")
 	dbh, err := Open(dbpath, cfg.Logger)
 	if err != nil {
-		panic(fmt.Sprintf("cannot find database file, check folder and perms: %s", dbpath))
+		panic(fmt.Sprintf("cannot find database file, check folder and perms: %s: %s", dbpath, err))
 	}
 
 	be := &Backend{
@@ -659,6 +721,11 @@ func StartWebServer(cfg *GitCfg) {
 	http.HandleFunc("GET /", ctxMdw(ctx, repoListHandler))
 	http.HandleFunc("GET /syntax.css", ctxMdw(ctx, chromaStyleHandler))
 	http.HandleFunc("GET /rss", ctxMdw(ctx, rssHandler))
+	filesys, err := getFileSystem(cfg.Logger, staticFS, cfg.DataDir, "static")
+	if err != nil {
+		panic(err)
+	}
+	http.HandleFunc("GET /static/{file}", ctxMdw(ctx, serveFile(filesys)))
 
 	cfg.Logger.Info("starting web server", "addr", addr)
 	err = http.ListenAndServe(addr, nil)

fix(cli): access control for removing patchsets

I also fixed some other access control issues for changing PR status.
cli.go link
+30 -6
 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
diff --git a/cli.go b/cli.go
index fcd2543..16c696d 100644
--- a/cli.go
+++ b/cli.go
@@ -213,7 +213,30 @@ Here's how it works:
 							if err != nil {
 								return err
 							}
-							return pr.DeletePatchsetByID(patchsetID)
+
+							patchset, err := pr.GetPatchsetByID(patchsetID)
+							if err != nil {
+								return err
+							}
+
+							user, err := pr.GetUserByID(patchset.UserID)
+							if err != nil {
+								return err
+							}
+
+							pk := sesh.PublicKey()
+							isAdmin := be.IsAdmin(pk)
+							isContrib := pubkey == user.Pubkey
+							if !isAdmin && !isContrib {
+								return fmt.Errorf("you are not authorized to delete a patchset")
+							}
+
+							err = pr.DeletePatchsetByID(patchsetID)
+							if err != nil {
+								return err
+							}
+							wish.Printf(sesh, "successfully removed patchset: %d\n", patchsetID)
+							return nil
 						},
 					},
 				},
@@ -597,17 +620,18 @@ Here's how it works:
 								return err
 							}
 
-							user, err := pr.UpsertUser(pubkey, userName)
+							patchReq, err := pr.GetPatchRequestByID(prID)
 							if err != nil {
 								return err
 							}
 
-							patchReq, err := pr.GetPatchRequestByID(prID)
+							user, err := pr.GetUserByID(patchReq.UserID)
 							if err != nil {
 								return err
 							}
+
 							pk := sesh.PublicKey()
-							isContrib := be.Pubkey(pk) == user.Pubkey
+							isContrib := pubkey == user.Pubkey
 							isAdmin := be.IsAdmin(pk)
 							if !isAdmin && !isContrib {
 								return fmt.Errorf("you are not authorized to change PR status")
@@ -645,13 +669,13 @@ Here's how it works:
 								return err
 							}
 
-							user, err := pr.UpsertUser(pubkey, userName)
+							user, err := pr.GetUserByID(patchReq.UserID)
 							if err != nil {
 								return err
 							}
 
 							pk := sesh.PublicKey()
-							isContrib := be.Pubkey(pk) == user.Pubkey
+							isContrib := pubkey == user.Pubkey
 							isAdmin := be.IsAdmin(pk)
 							if !isAdmin && !isContrib {
 								return fmt.Errorf("you are not authorized to change PR status")
pr.go link
+11 -0
 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
diff --git a/pr.go b/pr.go
index 0078ecf..1a35e13 100644
--- a/pr.go
+++ b/pr.go
@@ -34,6 +34,7 @@ type GitPatchRequest interface {
 	GetPatchRequests() ([]*PatchRequest, error)
 	GetPatchRequestsByRepoID(repoID string) ([]*PatchRequest, error)
 	GetPatchsetsByPrID(prID int64) ([]*Patchset, error)
+	GetPatchsetByID(patchsetID int64) (*Patchset, error)
 	GetLatestPatchsetByPrID(prID int64) (*Patchset, error)
 	GetPatchesByPatchsetID(prID int64) ([]*Patch, error)
 	UpdatePatchRequestStatus(prID, userID int64, status string) error
@@ -234,6 +235,16 @@ func (pr PrCmd) GetPatchsetsByPrID(prID int64) ([]*Patchset, error) {
 	return patchsets, nil
 }
 
+func (pr PrCmd) GetPatchsetByID(patchsetID int64) (*Patchset, error) {
+	var patchset Patchset
+	err := pr.Backend.DB.Get(
+		&patchset,
+		"SELECT * FROM patchsets WHERE id=?",
+		patchsetID,
+	)
+	return &patchset, err
+}
+
 func (pr PrCmd) GetLatestPatchsetByPrID(prID int64) (*Patchset, error) {
 	patchsets, err := pr.GetPatchsetsByPrID(prID)
 	if err != nil {