+7
-7
appview/db/reaction.go
+7
-7
appview/db/reaction.go
···
11
11
12
12
const (
13
13
Like ReactionKind = "👍"
14
-
Unlike = "👎"
15
-
Laugh = "😆"
16
-
Celebration = "🎉"
17
-
Confused = "🫤"
18
-
Heart = "❤️"
19
-
Rocket = "🚀"
20
-
Eyes = "👀"
14
+
Unlike ReactionKind = "👎"
15
+
Laugh ReactionKind = "😆"
16
+
Celebration ReactionKind = "🎉"
17
+
Confused ReactionKind = "🫤"
18
+
Heart ReactionKind = "❤️"
19
+
Rocket ReactionKind = "🚀"
20
+
Eyes ReactionKind = "👀"
21
21
)
22
22
23
23
func (rk ReactionKind) String() string {
-54
appview/issues/issues.go
-54
appview/issues/issues.go
···
96
96
log.Println("failed to resolve issue owner", err)
97
97
}
98
98
99
-
identsToResolve := make([]string, len(comments))
100
-
for i, comment := range comments {
101
-
identsToResolve[i] = comment.OwnerDid
102
-
}
103
-
resolvedIds := rp.idResolver.ResolveIdents(r.Context(), identsToResolve)
104
-
didHandleMap := make(map[string]string)
105
-
for _, identity := range resolvedIds {
106
-
if !identity.Handle.IsInvalidHandle() {
107
-
didHandleMap[identity.DID.String()] = fmt.Sprintf("@%s", identity.Handle.String())
108
-
} else {
109
-
didHandleMap[identity.DID.String()] = identity.DID.String()
110
-
}
111
-
}
112
-
113
99
rp.pages.RepoSingleIssue(w, pages.RepoSingleIssueParams{
114
100
LoggedInUser: user,
115
101
RepoInfo: f.RepoInfo(user),
···
117
103
Comments: comments,
118
104
119
105
IssueOwnerHandle: issueOwnerIdent.Handle.String(),
120
-
DidHandleMap: didHandleMap,
121
106
122
107
OrderedReactionKinds: db.OrderedReactionKinds,
123
108
Reactions: reactionCountMap,
···
371
356
return
372
357
}
373
358
374
-
identity, err := rp.idResolver.ResolveIdent(r.Context(), comment.OwnerDid)
375
-
if err != nil {
376
-
log.Println("failed to resolve did")
377
-
return
378
-
}
379
-
380
-
didHandleMap := make(map[string]string)
381
-
if !identity.Handle.IsInvalidHandle() {
382
-
didHandleMap[identity.DID.String()] = fmt.Sprintf("@%s", identity.Handle.String())
383
-
} else {
384
-
didHandleMap[identity.DID.String()] = identity.DID.String()
385
-
}
386
-
387
359
rp.pages.SingleIssueCommentFragment(w, pages.SingleIssueCommentParams{
388
360
LoggedInUser: user,
389
361
RepoInfo: f.RepoInfo(user),
390
-
DidHandleMap: didHandleMap,
391
362
Issue: issue,
392
363
Comment: comment,
393
364
})
···
503
474
}
504
475
505
476
// optimistic update for htmx
506
-
didHandleMap := map[string]string{
507
-
user.Did: user.Handle,
508
-
}
509
477
comment.Body = newBody
510
478
comment.Edited = &edited
511
479
···
513
481
rp.pages.SingleIssueCommentFragment(w, pages.SingleIssueCommentParams{
514
482
LoggedInUser: user,
515
483
RepoInfo: f.RepoInfo(user),
516
-
DidHandleMap: didHandleMap,
517
484
Issue: issue,
518
485
Comment: comment,
519
486
})
···
598
565
}
599
566
600
567
// optimistic update for htmx
601
-
didHandleMap := map[string]string{
602
-
user.Did: user.Handle,
603
-
}
604
568
comment.Body = ""
605
569
comment.Deleted = &deleted
606
570
···
608
572
rp.pages.SingleIssueCommentFragment(w, pages.SingleIssueCommentParams{
609
573
LoggedInUser: user,
610
574
RepoInfo: f.RepoInfo(user),
611
-
DidHandleMap: didHandleMap,
612
575
Issue: issue,
613
576
Comment: comment,
614
577
})
615
-
return
616
578
}
617
579
618
580
func (rp *Issues) RepoIssues(w http.ResponseWriter, r *http.Request) {
···
648
610
return
649
611
}
650
612
651
-
identsToResolve := make([]string, len(issues))
652
-
for i, issue := range issues {
653
-
identsToResolve[i] = issue.OwnerDid
654
-
}
655
-
resolvedIds := rp.idResolver.ResolveIdents(r.Context(), identsToResolve)
656
-
didHandleMap := make(map[string]string)
657
-
for _, identity := range resolvedIds {
658
-
if !identity.Handle.IsInvalidHandle() {
659
-
didHandleMap[identity.DID.String()] = fmt.Sprintf("@%s", identity.Handle.String())
660
-
} else {
661
-
didHandleMap[identity.DID.String()] = identity.DID.String()
662
-
}
663
-
}
664
-
665
613
rp.pages.RepoIssues(w, pages.RepoIssuesParams{
666
614
LoggedInUser: rp.oauth.GetUser(r),
667
615
RepoInfo: f.RepoInfo(user),
668
616
Issues: issues,
669
-
DidHandleMap: didHandleMap,
670
617
FilteringByOpen: isOpen,
671
618
Page: page,
672
619
})
673
-
return
674
620
}
675
621
676
622
func (rp *Issues) NewIssue(w http.ResponseWriter, r *http.Request) {
-16
appview/knots/knots.go
-16
appview/knots/knots.go
···
334
334
repoByMember[r.Did] = append(repoByMember[r.Did], r)
335
335
}
336
336
337
-
var didsToResolve []string
338
-
for _, m := range members {
339
-
didsToResolve = append(didsToResolve, m)
340
-
}
341
-
didsToResolve = append(didsToResolve, reg.ByDid)
342
-
resolvedIds := k.IdResolver.ResolveIdents(r.Context(), didsToResolve)
343
-
didHandleMap := make(map[string]string)
344
-
for _, identity := range resolvedIds {
345
-
if !identity.Handle.IsInvalidHandle() {
346
-
didHandleMap[identity.DID.String()] = fmt.Sprintf("@%s", identity.Handle.String())
347
-
} else {
348
-
didHandleMap[identity.DID.String()] = identity.DID.String()
349
-
}
350
-
}
351
-
352
337
k.Pages.Knot(w, pages.KnotParams{
353
338
LoggedInUser: user,
354
-
DidHandleMap: didHandleMap,
355
339
Registration: reg,
356
340
Members: members,
357
341
Repos: repoByMember,
+16
-2
appview/pages/funcmap.go
+16
-2
appview/pages/funcmap.go
···
1
1
package pages
2
2
3
3
import (
4
+
"context"
4
5
"crypto/hmac"
5
6
"crypto/sha256"
6
7
"encoding/hex"
···
27
28
return template.FuncMap{
28
29
"split": func(s string) []string {
29
30
return strings.Split(s, "\n")
31
+
},
32
+
"resolve": func(s string) string {
33
+
identity, err := p.resolver.ResolveIdent(context.Background(), s)
34
+
35
+
if err != nil {
36
+
return s
37
+
}
38
+
39
+
if identity.Handle.IsInvalidHandle() {
40
+
return "handle.invalid"
41
+
}
42
+
43
+
return "@" + identity.Handle.String()
30
44
},
31
45
"truncateAt30": func(s string) string {
32
46
if len(s) <= 30 {
···
74
88
"negf64": func(a float64) float64 {
75
89
return -a
76
90
},
77
-
"cond": func(cond interface{}, a, b string) string {
91
+
"cond": func(cond any, a, b string) string {
78
92
if cond == nil {
79
93
return b
80
94
}
···
167
181
return html.UnescapeString(s)
168
182
},
169
183
"nl2br": func(text string) template.HTML {
170
-
return template.HTML(strings.Replace(template.HTMLEscapeString(text), "\n", "<br>", -1))
184
+
return template.HTML(strings.ReplaceAll(template.HTMLEscapeString(text), "\n", "<br>"))
171
185
},
172
186
"unwrapText": func(text string) string {
173
187
paragraphs := strings.Split(text, "\n\n")
+4
-16
appview/pages/pages.go
+4
-16
appview/pages/pages.go
···
24
24
"tangled.sh/tangled.sh/core/appview/pages/markup"
25
25
"tangled.sh/tangled.sh/core/appview/pages/repoinfo"
26
26
"tangled.sh/tangled.sh/core/appview/pagination"
27
+
"tangled.sh/tangled.sh/core/idresolver"
27
28
"tangled.sh/tangled.sh/core/patchutil"
28
29
"tangled.sh/tangled.sh/core/types"
29
30
···
45
46
t map[string]*template.Template
46
47
47
48
avatar config.AvatarConfig
49
+
resolver *idresolver.Resolver
48
50
dev bool
49
51
embedFS embed.FS
50
52
templateDir string // Path to templates on disk for dev mode
51
53
rctx *markup.RenderContext
52
54
}
53
55
54
-
func NewPages(config *config.Config) *Pages {
56
+
func NewPages(config *config.Config, res *idresolver.Resolver) *Pages {
55
57
// initialized with safe defaults, can be overriden per use
56
58
rctx := &markup.RenderContext{
57
59
IsDev: config.Core.Dev,
···
66
68
avatar: config.Avatar,
67
69
embedFS: Files,
68
70
rctx: rctx,
71
+
resolver: res,
69
72
templateDir: "appview/pages",
70
73
}
71
74
···
290
293
type TimelineParams struct {
291
294
LoggedInUser *oauth.User
292
295
Timeline []db.TimelineEvent
293
-
DidHandleMap map[string]string
294
296
}
295
297
296
298
func (p *Pages) Timeline(w io.Writer, params TimelineParams) error {
···
318
320
319
321
type KnotParams struct {
320
322
LoggedInUser *oauth.User
321
-
DidHandleMap map[string]string
322
323
Registration *db.Registration
323
324
Members []string
324
325
Repos map[string][]db.Repo
···
375
376
Spindle db.Spindle
376
377
Members []string
377
378
Repos map[string][]db.Repo
378
-
DidHandleMap map[string]string
379
379
}
380
380
381
381
func (p *Pages) SpindleDashboard(w io.Writer, params SpindleDashboardParams) error {
···
408
408
ProfileTimeline *db.ProfileTimeline
409
409
Card ProfileCard
410
410
Punchcard db.Punchcard
411
-
412
-
DidHandleMap map[string]string
413
411
}
414
412
415
413
type ProfileCard struct {
···
430
428
LoggedInUser *oauth.User
431
429
Repos []db.Repo
432
430
Card ProfileCard
433
-
434
-
DidHandleMap map[string]string
435
431
}
436
432
437
433
func (p *Pages) ReposPage(w io.Writer, params ReposPageParams) error {
···
460
456
LoggedInUser *oauth.User
461
457
Profile *db.Profile
462
458
AllRepos []PinnedRepo
463
-
DidHandleMap map[string]string
464
459
}
465
460
466
461
type PinnedRepo struct {
···
779
774
RepoInfo repoinfo.RepoInfo
780
775
Active string
781
776
Issues []db.Issue
782
-
DidHandleMap map[string]string
783
777
Page pagination.Page
784
778
FilteringByOpen bool
785
779
}
···
796
790
Issue db.Issue
797
791
Comments []db.Comment
798
792
IssueOwnerHandle string
799
-
DidHandleMap map[string]string
800
793
801
794
OrderedReactionKinds []db.ReactionKind
802
795
Reactions map[db.ReactionKind]int
···
850
843
851
844
type SingleIssueCommentParams struct {
852
845
LoggedInUser *oauth.User
853
-
DidHandleMap map[string]string
854
846
RepoInfo repoinfo.RepoInfo
855
847
Issue *db.Issue
856
848
Comment *db.Comment
···
882
874
RepoInfo repoinfo.RepoInfo
883
875
Pulls []*db.Pull
884
876
Active string
885
-
DidHandleMap map[string]string
886
877
FilteringBy db.PullState
887
878
Stacks map[string]db.Stack
888
879
Pipelines map[string]db.Pipeline
···
915
906
LoggedInUser *oauth.User
916
907
RepoInfo repoinfo.RepoInfo
917
908
Active string
918
-
DidHandleMap map[string]string
919
909
Pull *db.Pull
920
910
Stack db.Stack
921
911
AbandonedPulls []*db.Pull
···
935
925
936
926
type RepoPullPatchParams struct {
937
927
LoggedInUser *oauth.User
938
-
DidHandleMap map[string]string
939
928
RepoInfo repoinfo.RepoInfo
940
929
Pull *db.Pull
941
930
Stack db.Stack
···
953
942
954
943
type RepoPullInterdiffParams struct {
955
944
LoggedInUser *oauth.User
956
-
DidHandleMap map[string]string
957
945
RepoInfo repoinfo.RepoInfo
958
946
Pull *db.Pull
959
947
Round int
+3
-4
appview/pages/templates/knots/dashboard.html
+3
-4
appview/pages/templates/knots/dashboard.html
···
38
38
<div>
39
39
<div class="flex justify-between items-center">
40
40
<div class="flex items-center gap-2">
41
-
{{ i "user" "size-4" }}
42
-
{{ $user := index $.DidHandleMap . }}
43
-
<a href="/{{ $user }}">{{ $user }} <span class="ml-2 font-mono text-gray-500">{{.}}</span></a>
41
+
{{ template "user/fragments/picHandleLink" . }}
42
+
<span class="ml-2 font-mono text-gray-500">{{.}}</span>
44
43
</div>
45
44
</div>
46
45
<div class="ml-2 pl-2 pt-2 border-l border-gray-200 dark:border-gray-700">
···
48
47
{{ range $repos }}
49
48
<div class="flex gap-2 items-center">
50
49
{{ i "book-marked" "size-4" }}
51
-
<a href="/{{ .Did }}/{{ .Name }}">
50
+
<a href="/{{ resolve .Did }}/{{ .Name }}">
52
51
{{ .Name }}
53
52
</a>
54
53
</div>
+1
-2
appview/pages/templates/repo/issues/fragments/issueComment.html
+1
-2
appview/pages/templates/repo/issues/fragments/issueComment.html
···
2
2
{{ with .Comment }}
3
3
<div id="comment-container-{{.CommentId}}">
4
4
<div class="flex items-center gap-2 mb-2 text-gray-500 dark:text-gray-400 text-sm flex-wrap">
5
-
{{ $owner := index $.DidHandleMap .OwnerDid }}
6
-
{{ template "user/fragments/picHandleLink" $owner }}
5
+
{{ template "user/fragments/picHandleLink" .OwnerDid }}
7
6
8
7
<!-- show user "hats" -->
9
8
{{ $isIssueAuthor := eq .OwnerDid $.Issue.OwnerDid }}
+1
-1
appview/pages/templates/repo/issues/issue.html
+1
-1
appview/pages/templates/repo/issues/issue.html
···
70
70
{{ if gt $index 0 }}
71
71
<div class="absolute left-8 -top-2 w-px h-2 bg-gray-300 dark:bg-gray-600"></div>
72
72
{{ end }}
73
-
{{ template "repo/issues/fragments/issueComment" (dict "RepoInfo" $.RepoInfo "LoggedInUser" $.LoggedInUser "DidHandleMap" $.DidHandleMap "Issue" $.Issue "Comment" .)}}
73
+
{{ template "repo/issues/fragments/issueComment" (dict "RepoInfo" $.RepoInfo "LoggedInUser" $.LoggedInUser "Issue" $.Issue "Comment" .)}}
74
74
</div>
75
75
{{ end }}
76
76
</section>
+1
-2
appview/pages/templates/repo/issues/issues.html
+1
-2
appview/pages/templates/repo/issues/issues.html
+2
-2
appview/pages/templates/repo/pipelines/fragments/pipelineSymbol.html
+2
-2
appview/pages/templates/repo/pipelines/fragments/pipelineSymbol.html
···
23
23
</div>
24
24
{{ else if $allFail }}
25
25
<div class="flex gap-1 items-center">
26
-
{{ i "x" "size-4 text-red-600" }}
26
+
{{ i "x" "size-4 text-red-500" }}
27
27
<span>0/{{ $total }}</span>
28
28
</div>
29
29
{{ else if $allTimeout }}
30
30
<div class="flex gap-1 items-center">
31
-
{{ i "clock-alert" "size-4 text-orange-400" }}
31
+
{{ i "clock-alert" "size-4 text-orange-500" }}
32
32
<span>0/{{ $total }}</span>
33
33
</div>
34
34
{{ else }}
+1
-1
appview/pages/templates/repo/pipelines/fragments/workflowSymbol.html
+1
-1
appview/pages/templates/repo/pipelines/fragments/workflowSymbol.html
···
19
19
{{ $color = "text-gray-600 dark:text-gray-500" }}
20
20
{{ else if eq $kind "timeout" }}
21
21
{{ $icon = "clock-alert" }}
22
-
{{ $color = "text-orange-400 dark:text-orange-300" }}
22
+
{{ $color = "text-orange-400 dark:text-orange-500" }}
23
23
{{ else }}
24
24
{{ $icon = "x" }}
25
25
{{ $color = "text-red-600 dark:text-red-500" }}
+2
-2
appview/pages/templates/repo/pulls/fragments/pullHeader.html
+2
-2
appview/pages/templates/repo/pulls/fragments/pullHeader.html
···
17
17
{{ $icon = "git-merge" }}
18
18
{{ end }}
19
19
20
+
{{ $owner := resolve .Pull.OwnerDid }}
20
21
<section class="mt-2">
21
22
<div class="flex items-center gap-2">
22
23
<div
···
28
29
</div>
29
30
<span class="text-gray-500 dark:text-gray-400 text-sm flex flex-wrap items-center gap-1">
30
31
opened by
31
-
{{ $owner := index $.DidHandleMap .Pull.OwnerDid }}
32
-
{{ template "user/fragments/picHandleLink" $owner }}
32
+
{{ template "user/fragments/picHandleLink" .Pull.OwnerDid }}
33
33
<span class="select-none before:content-['\00B7']"></span>
34
34
{{ template "repo/fragments/time" .Pull.Created }}
35
35
+3
-4
appview/pages/templates/repo/pulls/pull.html
+3
-4
appview/pages/templates/repo/pulls/pull.html
···
47
47
<!-- round summary -->
48
48
<div class="rounded drop-shadow-sm bg-white dark:bg-gray-800 p-2 text-gray-500 dark:text-gray-400">
49
49
<span class="gap-1 flex items-center">
50
-
{{ $owner := index $.DidHandleMap $.Pull.OwnerDid }}
50
+
{{ $owner := resolve $.Pull.OwnerDid }}
51
51
{{ $re := "re" }}
52
52
{{ if eq .RoundNumber 0 }}
53
53
{{ $re = "" }}
54
54
{{ end }}
55
55
<span class="hidden md:inline">{{$re}}submitted</span>
56
-
by {{ template "user/fragments/picHandleLink" $owner }}
56
+
by {{ template "user/fragments/picHandleLink" $.Pull.OwnerDid }}
57
57
<span class="select-none before:content-['\00B7']"></span>
58
58
<a class="text-gray-500 dark:text-gray-400 hover:text-gray-500" href="#round-#{{ .RoundNumber }}">{{ template "repo/fragments/shortTime" .Created }}</a>
59
59
<span class="select-none before:content-['·']"></span>
···
151
151
<div class="absolute left-8 -top-2 w-px h-2 bg-gray-300 dark:bg-gray-600"></div>
152
152
{{ end }}
153
153
<div class="text-sm text-gray-500 dark:text-gray-400 flex items-center gap-1">
154
-
{{ $owner := index $.DidHandleMap $c.OwnerDid }}
155
-
{{ template "user/fragments/picHandleLink" $owner }}
154
+
{{ template "user/fragments/picHandleLink" $c.OwnerDid }}
156
155
<span class="before:content-['·']"></span>
157
156
<a class="text-gray-500 dark:text-gray-400 hover:text-gray-500 dark:hover:text-gray-300" href="#comment-{{.ID}}">{{ template "repo/fragments/time" $c.Created }}</a>
158
157
</div>
+1
-2
appview/pages/templates/repo/pulls/pulls.html
+1
-2
appview/pages/templates/repo/pulls/pulls.html
···
55
55
</a>
56
56
</div>
57
57
<div class="text-sm text-gray-500 dark:text-gray-400 flex flex-wrap items-center gap-1">
58
-
{{ $owner := index $.DidHandleMap .OwnerDid }}
59
58
{{ $bgColor := "bg-gray-800 dark:bg-gray-700" }}
60
59
{{ $icon := "ban" }}
61
60
···
76
75
</span>
77
76
78
77
<span class="ml-1">
79
-
{{ template "user/fragments/picHandleLink" $owner }}
78
+
{{ template "user/fragments/picHandleLink" .OwnerDid }}
80
79
</span>
81
80
82
81
<span class="before:content-['·']">
+2
-4
appview/pages/templates/spindles/dashboard.html
+2
-4
appview/pages/templates/spindles/dashboard.html
···
42
42
<div>
43
43
<div class="flex justify-between items-center">
44
44
<div class="flex items-center gap-2">
45
-
{{ i "user" "size-4" }}
46
-
{{ $user := index $.DidHandleMap . }}
47
-
<a href="/{{ $user }}">{{ $user }}</a>
45
+
{{ template "user/fragments/picHandleLink" . }}
48
46
</div>
49
47
{{ if ne $.LoggedInUser.Did . }}
50
48
{{ block "removeMemberButton" (list $ . ) }} {{ end }}
···
109
107
hx-post="/spindles/{{ $root.Spindle.Instance }}/remove"
110
108
hx-swap="none"
111
109
hx-vals='{"member": "{{$member}}" }'
112
-
hx-confirm="Are you sure you want to remove {{ index $root.DidHandleMap $member }} from this instance?"
110
+
hx-confirm="Are you sure you want to remove {{ resolve $member }} from this instance?"
113
111
>
114
112
{{ i "user-minus" "w-4 h-4" }}
115
113
remove
+9
-8
appview/pages/templates/timeline.html
+9
-8
appview/pages/templates/timeline.html
···
76
76
{{ $root := index . 0 }}
77
77
{{ $repo := index . 1 }}
78
78
{{ $source := index . 2 }}
79
-
{{ $userHandle := index $root.DidHandleMap $repo.Did }}
79
+
{{ $userHandle := resolve $repo.Did }}
80
80
<div class="pl-6 py-2 bg-white dark:bg-gray-800 text-gray-600 dark:text-gray-300 flex flex-wrap items-center gap-2 text-sm">
81
-
{{ template "user/fragments/picHandleLink" $userHandle }}
81
+
{{ template "user/fragments/picHandleLink" $repo.Did }}
82
82
{{ with $source }}
83
+
{{ $sourceDid := resolve .Did }}
83
84
forked
84
-
<a href="/{{ index $root.DidHandleMap .Did }}/{{ .Name }}"class="no-underline hover:underline">
85
-
{{ index $root.DidHandleMap .Did }}/{{ .Name }}
85
+
<a href="/{{ $sourceDid }}/{{ .Name }}"class="no-underline hover:underline">
86
+
{{ $sourceDid }}/{{ .Name }}
86
87
</a>
87
88
to
88
89
<a href="/{{ $userHandle }}/{{ $repo.Name }}" class="no-underline hover:underline">{{ $repo.Name }}</a>
···
103
104
{{ $root := index . 0 }}
104
105
{{ $star := index . 1 }}
105
106
{{ with $star }}
106
-
{{ $starrerHandle := index $root.DidHandleMap .StarredByDid }}
107
-
{{ $repoOwnerHandle := index $root.DidHandleMap .Repo.Did }}
107
+
{{ $starrerHandle := resolve .StarredByDid }}
108
+
{{ $repoOwnerHandle := resolve .Repo.Did }}
108
109
<div class="pl-6 py-2 bg-white dark:bg-gray-800 text-gray-600 dark:text-gray-300 flex flex-wrap items-center gap-2 text-sm">
109
110
{{ template "user/fragments/picHandleLink" $starrerHandle }}
110
111
starred
···
126
127
{{ $profile := index . 2 }}
127
128
{{ $stat := index . 3 }}
128
129
129
-
{{ $userHandle := index $root.DidHandleMap $follow.UserDid }}
130
-
{{ $subjectHandle := index $root.DidHandleMap $follow.SubjectDid }}
130
+
{{ $userHandle := resolve $follow.UserDid }}
131
+
{{ $subjectHandle := resolve $follow.SubjectDid }}
131
132
<div class="pl-6 py-2 bg-white dark:bg-gray-800 text-gray-600 dark:text-gray-300 flex flex-wrap items-center gap-2 text-sm">
132
133
{{ template "user/fragments/picHandleLink" $userHandle }}
133
134
followed
+1
-1
appview/pages/templates/user/fragments/editPins.html
+1
-1
appview/pages/templates/user/fragments/editPins.html
···
27
27
<input type="checkbox" id="repo-{{$idx}}" name="pinnedRepo{{$idx}}" value="{{.RepoAt}}" {{if .IsPinned}}checked{{end}}>
28
28
<label for="repo-{{$idx}}" class="my-0 py-0 normal-case font-normal w-full">
29
29
<div class="flex justify-between items-center w-full">
30
-
<span class="flex-shrink-0 overflow-hidden text-ellipsis ">{{ index $.DidHandleMap .Did }}/{{.Name}}</span>
30
+
<span class="flex-shrink-0 overflow-hidden text-ellipsis ">{{ resolve .Did }}/{{.Name}}</span>
31
31
<div class="flex gap-1 items-center">
32
32
{{ i "star" "size-4 fill-current" }}
33
33
<span>{{ .RepoStats.StarCount }}</span>
+3
-2
appview/pages/templates/user/fragments/picHandleLink.html
+3
-2
appview/pages/templates/user/fragments/picHandleLink.html
···
1
1
{{ define "user/fragments/picHandleLink" }}
2
-
<a href="/{{ . }}" class="flex items-center">
3
-
{{ template "user/fragments/picHandle" . }}
2
+
{{ $resolved := resolve . }}
3
+
<a href="/{{ $resolved }}" class="flex items-center">
4
+
{{ template "user/fragments/picHandle" $resolved }}
4
5
</a>
5
6
{{ end }}
+4
-6
appview/pages/templates/user/fragments/repoCard.html
+4
-6
appview/pages/templates/user/fragments/repoCard.html
···
11
11
{{ else }}
12
12
{{ i "book-marked" "w-4 h-4 mr-1.5 shrink-0" }}
13
13
{{ end }}
14
+
15
+
{{ $repoOwner := resolve .Did }}
14
16
{{- if $fullName -}}
15
-
<a href="/{{ index $root.DidHandleMap .Did }}/{{ .Name }}"
16
-
>{{ index $root.DidHandleMap .Did }}/{{ .Name }}</a
17
-
>
17
+
<a href="/{{ $repoOwner }}/{{ .Name }}">{{ $repoOwner }}/{{ .Name }}</a>
18
18
{{- else -}}
19
-
<a href="/{{ index $root.DidHandleMap .Did }}/{{ .Name }}"
20
-
>{{ .Name }}</a
21
-
>
19
+
<a href="/{{ $repoOwner }}/{{ .Name }}">{{ .Name }}</a>
22
20
{{- end -}}
23
21
</div>
24
22
{{ with .Description }}
+13
-20
appview/pages/templates/user/profile.html
+13
-20
appview/pages/templates/user/profile.html
···
50
50
</div>
51
51
{{ else }}
52
52
<div class="flex flex-col gap-1">
53
-
{{ block "repoEvents" (list .RepoEvents $.DidHandleMap) }} {{ end }}
54
-
{{ block "issueEvents" (list .IssueEvents $.DidHandleMap) }} {{ end }}
55
-
{{ block "pullEvents" (list .PullEvents $.DidHandleMap) }} {{ end }}
53
+
{{ block "repoEvents" .RepoEvents }} {{ end }}
54
+
{{ block "issueEvents" .IssueEvents }} {{ end }}
55
+
{{ block "pullEvents" .PullEvents }} {{ end }}
56
56
</div>
57
57
{{ end }}
58
58
</div>
···
66
66
{{ end }}
67
67
68
68
{{ define "repoEvents" }}
69
-
{{ $items := index . 0 }}
70
-
{{ $handleMap := index . 1 }}
71
-
72
-
{{ if gt (len $items) 0 }}
69
+
{{ if gt (len .) 0 }}
73
70
<details>
74
71
<summary class="list-none cursor-pointer hover:text-gray-500 hover:dark:text-gray-400">
75
72
<div class="flex flex-wrap items-center gap-2">
76
73
{{ i "book-plus" "w-4 h-4" }}
77
-
created {{ len $items }} {{if eq (len $items) 1 }}repository{{else}}repositories{{end}}
74
+
created {{ len . }} {{if eq (len .) 1 }}repository{{else}}repositories{{end}}
78
75
</div>
79
76
</summary>
80
77
<div class="py-2 text-sm flex flex-col gap-3 mb-2">
81
-
{{ range $items }}
78
+
{{ range . }}
82
79
<div class="flex flex-wrap items-center gap-2">
83
80
<span class="text-gray-500 dark:text-gray-400">
84
81
{{ if .Source }}
···
87
84
{{ i "book-plus" "w-4 h-4" }}
88
85
{{ end }}
89
86
</span>
90
-
<a href="/{{ index $handleMap .Repo.Did }}/{{ .Repo.Name }}" class="no-underline hover:underline">
87
+
<a href="/{{ resolve .Repo.Did }}/{{ .Repo.Name }}" class="no-underline hover:underline">
91
88
{{- .Repo.Name -}}
92
89
</a>
93
90
</div>
···
98
95
{{ end }}
99
96
100
97
{{ define "issueEvents" }}
101
-
{{ $i := index . 0 }}
102
-
{{ $items := $i.Items }}
103
-
{{ $stats := $i.Stats }}
104
-
{{ $handleMap := index . 1 }}
98
+
{{ $items := .Items }}
99
+
{{ $stats := .Stats }}
105
100
106
101
{{ if gt (len $items) 0 }}
107
102
<details>
···
129
124
</summary>
130
125
<div class="py-2 text-sm flex flex-col gap-3 mb-2">
131
126
{{ range $items }}
132
-
{{ $repoOwner := index $handleMap .Metadata.Repo.Did }}
127
+
{{ $repoOwner := resolve .Metadata.Repo.Did }}
133
128
{{ $repoName := .Metadata.Repo.Name }}
134
129
{{ $repoUrl := printf "%s/%s" $repoOwner $repoName }}
135
130
···
163
158
{{ end }}
164
159
165
160
{{ define "pullEvents" }}
166
-
{{ $i := index . 0 }}
167
-
{{ $items := $i.Items }}
168
-
{{ $stats := $i.Stats }}
169
-
{{ $handleMap := index . 1 }}
161
+
{{ $items := .Items }}
162
+
{{ $stats := .Stats }}
170
163
{{ if gt (len $items) 0 }}
171
164
<details>
172
165
<summary class="list-none cursor-pointer hover:text-gray-500 hover:dark:text-gray-400">
···
200
193
</summary>
201
194
<div class="py-2 text-sm flex flex-col gap-3 mb-2">
202
195
{{ range $items }}
203
-
{{ $repoOwner := index $handleMap .Repo.Did }}
196
+
{{ $repoOwner := resolve .Repo.Did }}
204
197
{{ $repoName := .Repo.Name }}
205
198
{{ $repoUrl := printf "%s/%s" $repoOwner $repoName }}
206
199
-61
appview/pulls/pulls.go
-61
appview/pulls/pulls.go
···
151
151
}
152
152
}
153
153
154
-
resolvedIds := s.idResolver.ResolveIdents(r.Context(), identsToResolve)
155
-
didHandleMap := make(map[string]string)
156
-
for _, identity := range resolvedIds {
157
-
if !identity.Handle.IsInvalidHandle() {
158
-
didHandleMap[identity.DID.String()] = fmt.Sprintf("@%s", identity.Handle.String())
159
-
} else {
160
-
didHandleMap[identity.DID.String()] = identity.DID.String()
161
-
}
162
-
}
163
-
164
154
mergeCheckResponse := s.mergeCheck(f, pull, stack)
165
155
resubmitResult := pages.Unknown
166
156
if user != nil && user.Did == pull.OwnerDid {
···
212
202
s.pages.RepoSinglePull(w, pages.RepoSinglePullParams{
213
203
LoggedInUser: user,
214
204
RepoInfo: repoInfo,
215
-
DidHandleMap: didHandleMap,
216
205
Pull: pull,
217
206
Stack: stack,
218
207
AbandonedPulls: abandonedPulls,
···
377
366
return
378
367
}
379
368
380
-
identsToResolve := []string{pull.OwnerDid}
381
-
resolvedIds := s.idResolver.ResolveIdents(r.Context(), identsToResolve)
382
-
didHandleMap := make(map[string]string)
383
-
for _, identity := range resolvedIds {
384
-
if !identity.Handle.IsInvalidHandle() {
385
-
didHandleMap[identity.DID.String()] = fmt.Sprintf("@%s", identity.Handle.String())
386
-
} else {
387
-
didHandleMap[identity.DID.String()] = identity.DID.String()
388
-
}
389
-
}
390
-
391
369
patch := pull.Submissions[roundIdInt].Patch
392
370
diff := patchutil.AsNiceDiff(patch, pull.TargetBranch)
393
371
394
372
s.pages.RepoPullPatchPage(w, pages.RepoPullPatchParams{
395
373
LoggedInUser: user,
396
-
DidHandleMap: didHandleMap,
397
374
RepoInfo: f.RepoInfo(user),
398
375
Pull: pull,
399
376
Stack: stack,
···
440
417
return
441
418
}
442
419
443
-
identsToResolve := []string{pull.OwnerDid}
444
-
resolvedIds := s.idResolver.ResolveIdents(r.Context(), identsToResolve)
445
-
didHandleMap := make(map[string]string)
446
-
for _, identity := range resolvedIds {
447
-
if !identity.Handle.IsInvalidHandle() {
448
-
didHandleMap[identity.DID.String()] = fmt.Sprintf("@%s", identity.Handle.String())
449
-
} else {
450
-
didHandleMap[identity.DID.String()] = identity.DID.String()
451
-
}
452
-
}
453
-
454
420
currentPatch, err := patchutil.AsDiff(pull.Submissions[roundIdInt].Patch)
455
421
if err != nil {
456
422
log.Println("failed to interdiff; current patch malformed")
···
472
438
RepoInfo: f.RepoInfo(user),
473
439
Pull: pull,
474
440
Round: roundIdInt,
475
-
DidHandleMap: didHandleMap,
476
441
Interdiff: interdiff,
477
442
DiffOpts: diffOpts,
478
443
})
···
492
457
http.Error(w, "bad round id", http.StatusBadRequest)
493
458
log.Println("failed to parse round id", err)
494
459
return
495
-
}
496
-
497
-
identsToResolve := []string{pull.OwnerDid}
498
-
resolvedIds := s.idResolver.ResolveIdents(r.Context(), identsToResolve)
499
-
didHandleMap := make(map[string]string)
500
-
for _, identity := range resolvedIds {
501
-
if !identity.Handle.IsInvalidHandle() {
502
-
didHandleMap[identity.DID.String()] = fmt.Sprintf("@%s", identity.Handle.String())
503
-
} else {
504
-
didHandleMap[identity.DID.String()] = identity.DID.String()
505
-
}
506
460
}
507
461
508
462
w.Header().Set("Content-Type", "text/plain; charset=utf-8")
···
595
549
m[p.Sha] = p
596
550
}
597
551
598
-
identsToResolve := make([]string, len(pulls))
599
-
for i, pull := range pulls {
600
-
identsToResolve[i] = pull.OwnerDid
601
-
}
602
-
resolvedIds := s.idResolver.ResolveIdents(r.Context(), identsToResolve)
603
-
didHandleMap := make(map[string]string)
604
-
for _, identity := range resolvedIds {
605
-
if !identity.Handle.IsInvalidHandle() {
606
-
didHandleMap[identity.DID.String()] = fmt.Sprintf("@%s", identity.Handle.String())
607
-
} else {
608
-
didHandleMap[identity.DID.String()] = identity.DID.String()
609
-
}
610
-
}
611
-
612
552
s.pages.RepoPulls(w, pages.RepoPullsParams{
613
553
LoggedInUser: s.oauth.GetUser(r),
614
554
RepoInfo: f.RepoInfo(user),
615
555
Pulls: pulls,
616
-
DidHandleMap: didHandleMap,
617
556
FilteringBy: state,
618
557
Stacks: stacks,
619
558
Pipelines: m,
-13
appview/spindles/spindles.go
-13
appview/spindles/spindles.go
···
113
113
return
114
114
}
115
115
116
-
identsToResolve := make([]string, len(members))
117
-
copy(identsToResolve, members)
118
-
resolvedIds := s.IdResolver.ResolveIdents(r.Context(), identsToResolve)
119
-
didHandleMap := make(map[string]string)
120
-
for _, identity := range resolvedIds {
121
-
if !identity.Handle.IsInvalidHandle() {
122
-
didHandleMap[identity.DID.String()] = fmt.Sprintf("@%s", identity.Handle.String())
123
-
} else {
124
-
didHandleMap[identity.DID.String()] = identity.DID.String()
125
-
}
126
-
}
127
-
128
116
// organize repos by did
129
117
repoMap := make(map[string][]db.Repo)
130
118
for _, r := range repos {
···
136
124
Spindle: spindle,
137
125
Members: members,
138
126
Repos: repoMap,
139
-
DidHandleMap: didHandleMap,
140
127
})
141
128
}
142
129
-27
appview/state/profile.go
-27
appview/state/profile.go
···
108
108
}
109
109
}
110
110
111
-
resolvedIds := s.idResolver.ResolveIdents(r.Context(), didsToResolve)
112
-
didHandleMap := make(map[string]string)
113
-
for _, identity := range resolvedIds {
114
-
if !identity.Handle.IsInvalidHandle() {
115
-
didHandleMap[identity.DID.String()] = fmt.Sprintf("@%s", identity.Handle.String())
116
-
} else {
117
-
didHandleMap[identity.DID.String()] = identity.DID.String()
118
-
}
119
-
}
120
-
121
111
followers, following, err := db.GetFollowerFollowingCount(s.db, ident.DID.String())
122
112
if err != nil {
123
113
log.Printf("getting follow stats repos for %s: %s", ident.DID.String(), err)
···
145
135
LoggedInUser: loggedInUser,
146
136
Repos: pinnedRepos,
147
137
CollaboratingRepos: pinnedCollaboratingRepos,
148
-
DidHandleMap: didHandleMap,
149
138
Card: pages.ProfileCard{
150
139
UserDid: ident.DID.String(),
151
140
UserHandle: ident.Handle.String(),
···
194
183
s.pages.ReposPage(w, pages.ReposPageParams{
195
184
LoggedInUser: loggedInUser,
196
185
Repos: repos,
197
-
DidHandleMap: map[string]string{ident.DID.String(): ident.Handle.String()},
198
186
Card: pages.ProfileCard{
199
187
UserDid: ident.DID.String(),
200
188
UserHandle: ident.Handle.String(),
···
518
506
})
519
507
}
520
508
521
-
var didsToResolve []string
522
-
for _, r := range allRepos {
523
-
didsToResolve = append(didsToResolve, r.Did)
524
-
}
525
-
resolvedIds := s.idResolver.ResolveIdents(r.Context(), didsToResolve)
526
-
didHandleMap := make(map[string]string)
527
-
for _, identity := range resolvedIds {
528
-
if !identity.Handle.IsInvalidHandle() {
529
-
didHandleMap[identity.DID.String()] = fmt.Sprintf("@%s", identity.Handle.String())
530
-
} else {
531
-
didHandleMap[identity.DID.String()] = identity.DID.String()
532
-
}
533
-
}
534
-
535
509
s.pages.EditPinsFragment(w, pages.EditPinsParams{
536
510
LoggedInUser: user,
537
511
Profile: profile,
538
512
AllRepos: allRepos,
539
-
DidHandleMap: didHandleMap,
540
513
})
541
514
}
+2
-31
appview/state/state.go
+2
-31
appview/state/state.go
···
61
61
return nil, fmt.Errorf("failed to create enforcer: %w", err)
62
62
}
63
63
64
-
pgs := pages.NewPages(config)
65
-
66
64
res, err := idresolver.RedisResolver(config.Redis.ToURL())
67
65
if err != nil {
68
66
log.Printf("failed to create redis resolver: %v", err)
69
67
res = idresolver.DefaultResolver()
70
68
}
69
+
70
+
pgs := pages.NewPages(config, res)
71
71
72
72
cache := cache.New(config.Redis.Addr)
73
73
sess := session.New(cache)
···
180
180
s.pages.Notice(w, "timeline", "Uh oh! Failed to load timeline.")
181
181
}
182
182
183
-
var didsToResolve []string
184
-
for _, ev := range timeline {
185
-
if ev.Repo != nil {
186
-
didsToResolve = append(didsToResolve, ev.Repo.Did)
187
-
if ev.Source != nil {
188
-
didsToResolve = append(didsToResolve, ev.Source.Did)
189
-
}
190
-
}
191
-
if ev.Follow != nil {
192
-
didsToResolve = append(didsToResolve, ev.Follow.UserDid, ev.Follow.SubjectDid)
193
-
}
194
-
if ev.Star != nil {
195
-
didsToResolve = append(didsToResolve, ev.Star.StarredByDid, ev.Star.Repo.Did)
196
-
}
197
-
}
198
-
199
-
resolvedIds := s.idResolver.ResolveIdents(r.Context(), didsToResolve)
200
-
didHandleMap := make(map[string]string)
201
-
for _, identity := range resolvedIds {
202
-
if !identity.Handle.IsInvalidHandle() {
203
-
didHandleMap[identity.DID.String()] = fmt.Sprintf("@%s", identity.Handle.String())
204
-
} else {
205
-
didHandleMap[identity.DID.String()] = identity.DID.String()
206
-
}
207
-
}
208
-
209
183
s.pages.Timeline(w, pages.TimelineParams{
210
184
LoggedInUser: user,
211
185
Timeline: timeline,
212
-
DidHandleMap: didHandleMap,
213
186
})
214
-
215
-
return
216
187
}
217
188
218
189
func (s *State) Keys(w http.ResponseWriter, r *http.Request) {