tangled
alpha
login
or
join now
tjh.dev
/
test
forked from
tangled.org/core
0
fork
atom
Mirror of @tangled.org/core. Running on a Raspberry Pi Zero 2 (Please be gentle).
0
fork
atom
overview
issues
pulls
pipelines
smaller times, optimize for mobile
oppi.li
1 year ago
4f4bdd25
beacedb6
+49
-198
7 changed files
expand all
collapse all
unified
split
appview
pages
funcmap.go
templates
fragments
diff.html
pullActions.html
pullNewComment.html
pullResubmit.html
repo
pulls
pull.html
input.css
+21
appview/pages/funcmap.go
reviewed
···
6
6
"html"
7
7
"html/template"
8
8
"log"
9
9
+
"math"
9
10
"path/filepath"
10
11
"reflect"
11
12
"strings"
13
13
+
"time"
12
14
13
15
"github.com/dustin/go-humanize"
14
16
)
···
68
66
return s
69
67
},
70
68
"timeFmt": humanize.Time,
69
69
+
"shortTimeFmt": func(t time.Time) string {
70
70
+
return humanize.CustomRelTime(t, time.Now(), "", "", []humanize.RelTimeMagnitude{
71
71
+
{time.Second, "now", time.Second},
72
72
+
{2 * time.Second, "1s %s", 1},
73
73
+
{time.Minute, "%ds %s", time.Second},
74
74
+
{2 * time.Minute, "1min %s", 1},
75
75
+
{time.Hour, "%dmin %s", time.Minute},
76
76
+
{2 * time.Hour, "1hr %s", 1},
77
77
+
{humanize.Day, "%dhrs %s", time.Hour},
78
78
+
{2 * humanize.Day, "1d %s", 1},
79
79
+
{20 * humanize.Day, "%dd %s", humanize.Day},
80
80
+
{8 * humanize.Week, "%dw %s", humanize.Week},
81
81
+
{humanize.Year, "%dmo %s", humanize.Month},
82
82
+
{18 * humanize.Month, "1y %s", 1},
83
83
+
{2 * humanize.Year, "2y %s", 1},
84
84
+
{humanize.LongTime, "%dy %s", humanize.Year},
85
85
+
{math.MaxInt64, "a long while %s", 1},
86
86
+
})
87
87
+
},
71
88
"byteFmt": humanize.Bytes,
72
89
"length": func(slice any) int {
73
90
v := reflect.ValueOf(slice)
+2
-2
appview/pages/templates/fragments/diff.html
reviewed
···
84
84
<div class="bg-gray-100 text-gray-500 select-none">{{ .Header }}</div>
85
85
{{- range .Lines -}}
86
86
{{- if eq .Op.String "+" -}}
87
87
-
<div class="bg-green-100 text-green-700 p-1"><span class="select-none mx-2">{{ .Op.String }}</span><span>{{ .Line }}</span></div>
87
87
+
<div class="bg-green-100 text-green-700 p-1 w-full min-w-fit"><span class="select-none mx-2">{{ .Op.String }}</span><span>{{ .Line }}</span></div>
88
88
{{- end -}}
89
89
90
90
{{- if eq .Op.String "-" -}}
91
91
-
<div class="bg-red-100 text-red-700 p-1"><span class="select-none mx-2">{{ .Op.String }}</span><span>{{ .Line }}</span></div>
91
91
+
<div class="bg-red-100 text-red-700 p-1 w-full min-w-fit"><span class="select-none mx-2">{{ .Op.String }}</span><span>{{ .Line }}</span></div>
92
92
{{- end -}}
93
93
94
94
{{- if eq .Op.String " " -}}
+1
-1
appview/pages/templates/fragments/pullActions.html
reviewed
···
28
28
<button
29
29
hx-post="/{{ .RepoInfo.FullName }}/pulls/{{ .Pull.PullId }}/merge"
30
30
hx-swap="none"
31
31
-
hx-confirm="Are you sure you want to merge this pull request?"
31
31
+
hx-confirm="Are you sure you want to merge pull #{{ .Pull.PullId }} into the `{{ .Pull.TargetBranch }}` branch?"
32
32
class="btn p-2 flex items-center gap-2" {{ $disabled }}>
33
33
{{ i "git-merge" "w-4 h-4" }}
34
34
<span>merge</span>
+1
-1
appview/pages/templates/fragments/pullNewComment.html
reviewed
···
1
1
{{ define "fragments/pullNewComment" }}
2
2
<div
3
3
id="pull-comment-card-{{ .RoundNumber }}"
4
4
-
class="bg-white rounded drop-shadow-sm py-4 px-6 relative w-full flex flex-col gap-2">
4
4
+
class="bg-white rounded drop-shadow-sm p-4 relative w-full flex flex-col gap-2">
5
5
<div class="text-sm text-gray-500">
6
6
{{ didOrHandle .LoggedInUser.Did .LoggedInUser.Handle }}
7
7
</div>
+1
-1
appview/pages/templates/fragments/pullResubmit.html
reviewed
···
24
24
class="w-full p-2 mb-2 rounded border border-gray-200"
25
25
placeholder="Paste your updated patch here."
26
26
rows="15"
27
27
-
></textarea>
27
27
+
>{{.Pull.LatestPatch}}</textarea>
28
28
<button
29
29
type="submit"
30
30
class="btn flex items-center gap-2"
+22
-192
appview/pages/templates/repo/pulls/pull.html
reviewed
···
77
77
{{ $oneIndexedRound := add .RoundNumber 1 }}
78
78
<details {{ if eq $idx $lastIdx }}open{{ end }}>
79
79
<summary id="round-#{{ $oneIndexedRound }}" class="list-none cursor-pointer">
80
80
-
<div class="flex gap-2 items-center">
81
81
-
<div class="rounded bg-white drop-shadow-sm p-3">
80
80
+
<div class="flex flex-wrap gap-2 items-center">
81
81
+
<!-- round number -->
82
82
+
<div class="rounded bg-white drop-shadow-sm px-3 py-2">
82
83
#{{ $oneIndexedRound }}
83
84
</div>
84
84
-
<div class="rounded drop-shadow-sm bg-white p-3 text-gray-500">
85
85
+
<!-- round summary -->
86
86
+
<div class="rounded drop-shadow-sm bg-white p-2 text-gray-500">
85
87
<span>
86
88
{{ $owner := index $.DidHandleMap $.Pull.OwnerDid }}
87
87
-
submitted by <a href="/{{ $owner }}">{{ $owner }}</a>
89
89
+
{{ $re := "re" }}
90
90
+
{{ if eq .RoundNumber 0 }}
91
91
+
{{ $re = "" }}
92
92
+
{{ end }}
93
93
+
<span class="hidden md:inline">{{$re}}submitted</span>
94
94
+
by <a href="/{{ $owner }}">{{ $owner }}</a>
88
95
<span class="select-none before:content-['\00B7']"></span>
89
89
-
<a class="text-gray-500 hover:text-gray-500" href="#round-#{{ $oneIndexedRound }}"><time>{{ .Created | timeFmt }}</time></a>
96
96
+
<a class="text-gray-500 hover:text-gray-500" href="#round-#{{ $oneIndexedRound }}"><time>{{ .Created | shortTimeFmt }}</time></a>
90
97
<span class="select-none before:content-['·']"></span>
91
98
{{ $s := "s" }}
92
99
{{ if eq (len .Comments) 1 }}
93
100
{{ $s = "" }}
94
101
{{ end }}
95
102
{{ len .Comments }} comment{{$s}}
96
96
-
<span class="before:content-['·']"></span>
97
97
-
<a href="/{{ $.RepoInfo.FullName }}/pulls/{{ $.Pull.PullId }}/round/{{.RoundNumber}}">view patch</a>
98
103
</span>
99
104
</div>
105
105
+
<!-- view patch -->
106
106
+
<a class="btn flex items-center gap-2 no-underline hover:no-underline p-2"
107
107
+
hx-boost="true"
108
108
+
href="/{{ $.RepoInfo.FullName }}/pulls/{{ $.Pull.PullId }}/round/{{.RoundNumber}}">
109
109
+
{{ i "file-diff" "w-4 h-4" }} <span class="hidden md:inline">view patch</span>
110
110
+
</a>
100
111
</div>
101
112
</summary>
102
102
-
<div class="pl-12 flex flex-col gap-2 mt-2 relative">
113
113
+
<div class="md:pl-12 flex flex-col gap-2 mt-2 relative">
103
114
{{ range .Comments }}
104
115
<div id="comment-{{.ID}}" class="bg-white rounded drop-shadow-sm py-2 px-4 relative w-fit">
105
116
<div class="absolute left-8 -top-2 w-px h-2 bg-gray-300"></div>
···
118
107
{{ $owner := index $.DidHandleMap .OwnerDid }}
119
108
<a href="/{{$owner}}">{{$owner}}</a>
120
109
<span class="before:content-['·']"></span>
121
121
-
<a href="#comment-{{.ID}}"><time>{{ .Created | timeFmt }}</time></a>
110
110
+
<a class="text-gray-500 hover:text-gray-500" href="#comment-{{.ID}}"><time>{{ .Created | shortTimeFmt }}</time></a>
122
111
</div>
123
112
<div class="prose">
124
124
-
{{ .Body }}
113
113
+
{{ .Body | markdown }}
125
114
</div>
126
115
</div>
127
116
{{ end }}
···
140
129
{{ end }}
141
130
</div>
142
131
</details>
132
132
+
<hr class="md:hidden"/>
143
133
{{ end }}
144
134
{{ end }}
145
135
{{ end }}
···
199
187
</div>
200
188
</div>
201
189
{{ end }}
202
202
-
{{ end }}
203
203
-
204
204
-
{{ define "newComment" }}
205
205
-
{{ $rootObj := index . 0 }}
206
206
-
{{ $submissionId := index . 1 }}
207
207
-
208
208
-
{{ with $rootObj }}
209
209
-
{{ if .LoggedInUser }}
210
210
-
<div class="bg-white rounded drop-shadow-sm py-2 px-4 relative w-full md:w-96">
211
211
-
<div class="absolute left-8 -top-2 w-px h-2 bg-gray-300"></div>
212
212
-
<div class="text-sm text-gray-500">
213
213
-
{{ index .DidHandleMap .LoggedInUser.Did }}
214
214
-
</div>
215
215
-
<form
216
216
-
hx-post="/{{ .RepoInfo.FullName }}/pulls/{{ .Pull.PullId }}/comment"
217
217
-
hx-swap="none">
218
218
-
<input type="hidden" name="submissionId" value="{{ $submissionId }}">
219
219
-
<textarea
220
220
-
name="body"
221
221
-
class="w-full border-0 h-8 focus:outline-none focus:ring-0 px-0 py-1"
222
222
-
placeholder="Add to the discussion..." /></textarea>
223
223
-
<div class="flex justify-end">
224
224
-
<button type="submit" class="btn text-sm mt-2">comment</button>
225
225
-
</div>
226
226
-
<div id="pull-comment"></div>
227
227
-
</form>
228
228
-
</div>
229
229
-
{{ else }}
230
230
-
<div class="bg-white rounded drop-shadow-sm px-6 py-4 text-sm w-fit">
231
231
-
<div class="absolute left-8 -top-2 w-px h-2 bg-gray-300"></div>
232
232
-
<a href="/login" class="underline">login</a> to join the discussion
233
233
-
</div>
234
234
-
{{ end }}
235
235
-
{{ end }}
236
236
-
{{ end }}
237
237
-
238
238
-
{{ define "alreadyMergedCard" }}
239
239
-
<div
240
240
-
id="merge-status-card"
241
241
-
class="rounded relative bg-purple-50 border border-purple-200 p-4">
242
242
-
243
243
-
<div class="flex items-center gap-2 text-purple-500">
244
244
-
{{ i "git-merge" "w-4 h-4" }}
245
245
-
<span class="font-medium"
246
246
-
>pull request successfully merged</span
247
247
-
>
248
248
-
</div>
249
249
-
250
250
-
<div class="mt-2 text-sm text-gray-700">
251
251
-
<p>This pull request has been merged into the base branch.</p>
252
252
-
</div>
253
253
-
</div>
254
254
-
{{ end }}
255
255
-
256
256
-
{{ define "isConflictedCard" }}
257
257
-
<div
258
258
-
id="merge-status-card"
259
259
-
class="rounded relative border bg-red-50 border-red-200 p-4">
260
260
-
261
261
-
<div class="flex items-center gap-2 text-red-500">
262
262
-
<i data-lucide="alert-triangle" class="w-4 h-4"></i>
263
263
-
<span class="font-medium">merge conflicts detected</span>
264
264
-
</div>
265
265
-
266
266
-
<div class="mt-2">
267
267
-
<ul class="text-sm space-y-1">
268
268
-
{{ range .MergeCheck.Conflicts }}
269
269
-
<li class="flex items-center">
270
270
-
<i
271
271
-
data-lucide="file-warning"
272
272
-
class="w-3 h-3 mr-1.5 text-red-500"
273
273
-
></i>
274
274
-
<span class="font-mono"
275
275
-
>{{ slice .Filename 0 (sub (len .Filename) 2) }}</span
276
276
-
>
277
277
-
</li>
278
278
-
{{ end }}
279
279
-
</ul>
280
280
-
</div>
281
281
-
<div class="mt-3 text-sm text-gray-700">
282
282
-
<p>
283
283
-
Please resolve these conflicts locally and update
284
284
-
the patch to continue with the merge.
285
285
-
</p>
286
286
-
</div>
287
287
-
</div>
288
288
-
{{ end }}
289
289
-
290
290
-
291
291
-
{{ define "noConflictsCard" }}
292
292
-
{{ $isPushAllowed := .RepoInfo.Roles.IsPushAllowed }}
293
293
-
{{ $isPullAuthor := and .LoggedInUser (eq .LoggedInUser.Did .Pull.OwnerDid) }}
294
294
-
<div
295
295
-
id="merge-status-card"
296
296
-
class="rounded relative border bg-green-50 border-green-200 p-4">
297
297
-
298
298
-
<div class="flex items-center gap-2 text-green-500">
299
299
-
<i data-lucide="check-circle" class="w-4 h-4"></i>
300
300
-
<span class="font-medium">ready to merge</span>
301
301
-
</div>
302
302
-
303
303
-
<div class="mt-2 text-sm text-gray-700">
304
304
-
No conflicts detected with the base branch. This
305
305
-
pull request can be merged safely.
306
306
-
</div>
307
307
-
308
308
-
<div class="flex items-center gap-2">
309
309
-
{{ if $isPushAllowed }}
310
310
-
<button
311
311
-
class="btn mt-4 flex items-center gap-2"
312
312
-
hx-post="/{{ .RepoInfo.FullName }}/pulls/{{ .Pull.PullId }}/merge"
313
313
-
hx-swap="none"
314
314
-
{{ if or .Pull.State.IsClosed .MergeCheck.IsConflicted }}
315
315
-
disabled
316
316
-
{{ end }}>
317
317
-
<i data-lucide="git-merge" class="w-4 h-4"></i>
318
318
-
<span>merge</span>
319
319
-
</button>
320
320
-
{{ end }}
321
321
-
322
322
-
{{ if and (or $isPullAuthor $isPushAllowed) (not .Pull.State.IsMerged) }}
323
323
-
{{ $action := "close" }}
324
324
-
{{ $icon := "circle-x" }}
325
325
-
{{ $hoverColor := "red" }}
326
326
-
{{ if .Pull.State.IsClosed }}
327
327
-
{{ $action = "reopen" }}
328
328
-
{{ $icon = "circle-dot" }}
329
329
-
{{ $hoverColor = "green" }}
330
330
-
{{ end }}
331
331
-
<button
332
332
-
hx-post="/{{ .RepoInfo.FullName }}/pulls/{{ .Pull.PullId }}/{{ $action }}"
333
333
-
hx-swap="none"
334
334
-
class="btn mt-4 flex items-center gap-2">
335
335
-
<i data-lucide="{{ $icon }}" class="w-4 h-4 text-{{ $hoverColor }}-400"></i>
336
336
-
<span class="text-black">{{ $action }}</span>
337
337
-
</button>
338
338
-
{{ end }}
339
339
-
340
340
-
<div id="pull-merge-error" class="error"></div>
341
341
-
<div id="pull-merge-success" class="success"></div>
342
342
-
</div>
343
343
-
</div>
344
344
-
{{ end }}
345
345
-
346
346
-
{{ define "resubmitCard" }}
347
347
-
<div
348
348
-
id="resubmit-pull-card"
349
349
-
class="rounded relative border bg-amber-50 border-amber-200 p-4">
350
350
-
351
351
-
<div class="flex items-center gap-2 text-amber-500">
352
352
-
<i data-lucide="edit" class="w-4 h-4"></i>
353
353
-
<span class="font-medium">resubmit your patch</span>
354
354
-
</div>
355
355
-
356
356
-
<div class="mt-2 text-sm text-gray-700">
357
357
-
You can update this patch to address any reviews.
358
358
-
This will begin a new round of reviews,
359
359
-
but you'll still be able to view your previous submissions and feedback.
360
360
-
</div>
361
361
-
362
362
-
<div class="mt-4 flex flex-col">
363
363
-
<form hx-post="/{{ .RepoInfo.FullName }}/pulls/{{ .Pull.PullId }}/resubmit" class="w-full" hx-swap="none">
364
364
-
<textarea
365
365
-
name="patch"
366
366
-
class="w-full p-2 mb-2 rounded border border-gray-200"
367
367
-
placeholder="Paste your updated patch here."
368
368
-
></textarea>
369
369
-
<button
370
370
-
type="submit"
371
371
-
class="btn flex items-center gap-2"
372
372
-
{{ if or .Pull.State.IsClosed }}
373
373
-
disabled
374
374
-
{{ end }}>
375
375
-
<i data-lucide="refresh-ccw" class="w-4 h-4"></i>
376
376
-
<span>resubmit</span>
377
377
-
</button>
378
378
-
</form>
379
379
-
380
380
-
<div id="resubmit-error" class="error"></div>
381
381
-
<div id="resubmit-success" class="success"></div>
382
382
-
</div>
383
383
-
</div>
384
190
{{ end }}
+1
-1
input.css
reviewed
···
132
132
@apply relative z-10 inline-flex min-h-[30px] cursor-pointer items-center
133
133
justify-center bg-transparent px-2 pb-[0.2rem] text-base
134
134
text-gray-900 before:absolute before:inset-0 before:-z-10
135
135
-
before:block before:rounded-sm before:border before:border-gray-200
135
135
+
before:block before:rounded before:border before:border-gray-200
136
136
before:bg-white before:drop-shadow-sm
137
137
before:content-[''] hover:before:border-gray-300
138
138
hover:before:bg-gray-50