Mirror of @tangled.org/core. Running on a Raspberry Pi Zero 2 (Please be gentle).
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

appview: remove all occurrences of DidHandleMap

Signed-off-by: oppiliappan <me@oppi.li>

authored by

oppiliappan and committed by
Tangled
99e405a1 581ad086

+76 -288
+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
··· 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), ··· 103 117 Comments: comments, 104 118 105 119 IssueOwnerHandle: issueOwnerIdent.Handle.String(), 106 - DidHandleMap: didHandleMap, 107 120 108 121 OrderedReactionKinds: db.OrderedReactionKinds, 109 122 Reactions: reactionCountMap, ··· 356 371 return 357 372 } 358 373 359 - identity, err := rp.idResolver.ResolveIdent(r.Context(), comment.OwnerDid) 360 - if err != nil { 361 - log.Println("failed to resolve did") 362 - return 363 - } 364 - 365 - didHandleMap := make(map[string]string) 366 - if !identity.Handle.IsInvalidHandle() { 367 - didHandleMap[identity.DID.String()] = fmt.Sprintf("@%s", identity.Handle.String()) 368 - } else { 369 - didHandleMap[identity.DID.String()] = identity.DID.String() 370 - } 371 - 372 374 rp.pages.SingleIssueCommentFragment(w, pages.SingleIssueCommentParams{ 373 375 LoggedInUser: user, 374 376 RepoInfo: f.RepoInfo(user), 375 - DidHandleMap: didHandleMap, 376 377 Issue: issue, 377 378 Comment: comment, 378 379 }) ··· 474 503 } 475 504 476 505 // optimistic update for htmx 477 - didHandleMap := map[string]string{ 478 - user.Did: user.Handle, 479 - } 480 506 comment.Body = newBody 481 507 comment.Edited = &edited 482 508 ··· 481 513 rp.pages.SingleIssueCommentFragment(w, pages.SingleIssueCommentParams{ 482 514 LoggedInUser: user, 483 515 RepoInfo: f.RepoInfo(user), 484 - DidHandleMap: didHandleMap, 485 516 Issue: issue, 486 517 Comment: comment, 487 518 }) ··· 565 598 } 566 599 567 600 // optimistic update for htmx 568 - didHandleMap := map[string]string{ 569 - user.Did: user.Handle, 570 - } 571 601 comment.Body = "" 572 602 comment.Deleted = &deleted 573 603 ··· 572 608 rp.pages.SingleIssueCommentFragment(w, pages.SingleIssueCommentParams{ 573 609 LoggedInUser: user, 574 610 RepoInfo: f.RepoInfo(user), 575 - DidHandleMap: didHandleMap, 576 611 Issue: issue, 577 612 Comment: comment, 578 613 }) 579 - return 580 614 } 581 615 582 616 func (rp *Issues) RepoIssues(w http.ResponseWriter, r *http.Request) { ··· 610 648 return 611 649 } 612 650 613 - identsToResolve := make([]string, len(issues)) 614 - for i, issue := range issues { 615 - identsToResolve[i] = issue.OwnerDid 616 - } 617 - resolvedIds := rp.idResolver.ResolveIdents(r.Context(), identsToResolve) 618 - didHandleMap := make(map[string]string) 619 - for _, identity := range resolvedIds { 620 - if !identity.Handle.IsInvalidHandle() { 621 - didHandleMap[identity.DID.String()] = fmt.Sprintf("@%s", identity.Handle.String()) 622 - } else { 623 - didHandleMap[identity.DID.String()] = identity.DID.String() 624 - } 625 - } 626 - 627 651 rp.pages.RepoIssues(w, pages.RepoIssuesParams{ 628 652 LoggedInUser: rp.oauth.GetUser(r), 629 653 RepoInfo: f.RepoInfo(user), 630 654 Issues: issues, 631 - DidHandleMap: didHandleMap, 632 655 FilteringByOpen: isOpen, 633 656 Page: page, 634 657 }) 635 - return 636 658 } 637 659 638 660 func (rp *Issues) NewIssue(w http.ResponseWriter, r *http.Request) {
-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
··· 1 1 package pages 2 2 3 3 import ( 4 + "context" 4 5 "crypto/hmac" 5 6 "crypto/sha256" 6 7 "encoding/hex" ··· 28 27 return template.FuncMap{ 29 28 "split": func(s string) []string { 30 29 return strings.Split(s, "\n") 30 + }, 31 + "resolve": func(s string) string { 32 + identity, err := p.resolver.ResolveIdent(context.Background(), s) 33 + 34 + if err != nil { 35 + return s 36 + } 37 + 38 + if identity.Handle.IsInvalidHandle() { 39 + return "handle.invalid" 40 + } 41 + 42 + return "@" + identity.Handle.String() 31 43 }, 32 44 "truncateAt30": func(s string) string { 33 45 if len(s) <= 30 { ··· 88 74 "negf64": func(a float64) float64 { 89 75 return -a 90 76 }, 91 - "cond": func(cond interface{}, a, b string) string { 77 + "cond": func(cond any, a, b string) string { 92 78 if cond == nil { 93 79 return b 94 80 } ··· 181 167 return html.UnescapeString(s) 182 168 }, 183 169 "nl2br": func(text string) template.HTML { 184 - return template.HTML(strings.Replace(template.HTMLEscapeString(text), "\n", "<br>", -1)) 170 + return template.HTML(strings.ReplaceAll(template.HTMLEscapeString(text), "\n", "<br>")) 185 171 }, 186 172 "unwrapText": func(text string) string { 187 173 paragraphs := strings.Split(text, "\n\n")
+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 ··· 46 45 t map[string]*template.Template 47 46 48 47 avatar config.AvatarConfig 48 + resolver *idresolver.Resolver 49 49 dev bool 50 50 embedFS embed.FS 51 51 templateDir string // Path to templates on disk for dev mode 52 52 rctx *markup.RenderContext 53 53 } 54 54 55 - func NewPages(config *config.Config) *Pages { 55 + func NewPages(config *config.Config, res *idresolver.Resolver) *Pages { 56 56 // initialized with safe defaults, can be overriden per use 57 57 rctx := &markup.RenderContext{ 58 58 IsDev: config.Core.Dev, ··· 68 66 avatar: config.Avatar, 69 67 embedFS: Files, 70 68 rctx: rctx, 69 + resolver: res, 71 70 templateDir: "appview/pages", 72 71 } 73 72 ··· 293 290 type TimelineParams struct { 294 291 LoggedInUser *oauth.User 295 292 Timeline []db.TimelineEvent 296 - DidHandleMap map[string]string 297 293 } 298 294 299 295 func (p *Pages) Timeline(w io.Writer, params TimelineParams) error { ··· 320 318 321 319 type KnotParams struct { 322 320 LoggedInUser *oauth.User 323 - DidHandleMap map[string]string 324 321 Registration *db.Registration 325 322 Members []string 326 323 Repos map[string][]db.Repo ··· 376 375 Spindle db.Spindle 377 376 Members []string 378 377 Repos map[string][]db.Repo 379 - DidHandleMap map[string]string 380 378 } 381 379 382 380 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 { ··· 428 430 LoggedInUser *oauth.User 429 431 Repos []db.Repo 430 432 Card ProfileCard 431 - 432 - DidHandleMap map[string]string 433 433 } 434 434 435 435 func (p *Pages) ReposPage(w io.Writer, params ReposPageParams) error { ··· 456 460 LoggedInUser *oauth.User 457 461 Profile *db.Profile 458 462 AllRepos []PinnedRepo 459 - DidHandleMap map[string]string 460 463 } 461 464 462 465 type PinnedRepo struct { ··· 774 779 RepoInfo repoinfo.RepoInfo 775 780 Active string 776 781 Issues []db.Issue 777 - DidHandleMap map[string]string 778 782 Page pagination.Page 779 783 FilteringByOpen bool 780 784 } ··· 790 796 Issue db.Issue 791 797 Comments []db.Comment 792 798 IssueOwnerHandle string 793 - DidHandleMap map[string]string 794 799 795 800 OrderedReactionKinds []db.ReactionKind 796 801 Reactions map[db.ReactionKind]int ··· 843 850 844 851 type SingleIssueCommentParams struct { 845 852 LoggedInUser *oauth.User 846 - DidHandleMap map[string]string 847 853 RepoInfo repoinfo.RepoInfo 848 854 Issue *db.Issue 849 855 Comment *db.Comment ··· 874 882 RepoInfo repoinfo.RepoInfo 875 883 Pulls []*db.Pull 876 884 Active string 877 - DidHandleMap map[string]string 878 885 FilteringBy db.PullState 879 886 Stacks map[string]db.Stack 880 887 Pipelines map[string]db.Pipeline ··· 906 915 LoggedInUser *oauth.User 907 916 RepoInfo repoinfo.RepoInfo 908 917 Active string 909 - DidHandleMap map[string]string 910 918 Pull *db.Pull 911 919 Stack db.Stack 912 920 AbandonedPulls []*db.Pull ··· 925 935 926 936 type RepoPullPatchParams struct { 927 937 LoggedInUser *oauth.User 928 - DidHandleMap map[string]string 929 938 RepoInfo repoinfo.RepoInfo 930 939 Pull *db.Pull 931 940 Stack db.Stack ··· 942 953 943 954 type RepoPullInterdiffParams struct { 944 955 LoggedInUser *oauth.User 945 - DidHandleMap map[string]string 946 956 RepoInfo repoinfo.RepoInfo 947 957 Pull *db.Pull 948 958 Round int
+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"> ··· 47 48 {{ range $repos }} 48 49 <div class="flex gap-2 items-center"> 49 50 {{ i "book-marked" "size-4" }} 50 - <a href="/{{ .Did }}/{{ .Name }}"> 51 + <a href="/{{ resolve .Did }}/{{ .Name }}"> 51 52 {{ .Name }} 52 53 </a> 53 54 </div>
+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
··· 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
··· 65 65 </span> 66 66 67 67 <span class="ml-1"> 68 - {{ $owner := index $.DidHandleMap .OwnerDid }} 69 - {{ template "user/fragments/picHandleLink" $owner }} 68 + {{ template "user/fragments/picHandleLink" .OwnerDid }} 70 69 </span> 71 70 72 71 <span class="before:content-['·']">
+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
··· 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
··· 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 ··· 29 28 </div> 30 29 <span class="text-gray-500 dark:text-gray-400 text-sm flex flex-wrap items-center gap-1"> 31 30 opened by 32 - {{ $owner := index $.DidHandleMap .Pull.OwnerDid }} 33 - {{ template "user/fragments/picHandleLink" $owner }} 31 + {{ template "user/fragments/picHandleLink" .Pull.OwnerDid }} 34 32 <span class="select-none before:content-['\00B7']"></span> 35 33 {{ template "repo/fragments/time" .Pull.Created }} 36 34
+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
··· 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 ··· 75 76 </span> 76 77 77 78 <span class="ml-1"> 78 - {{ template "user/fragments/picHandleLink" $owner }} 79 + {{ template "user/fragments/picHandleLink" .OwnerDid }} 79 80 </span> 80 81 81 82 <span class="before:content-['·']">
+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 }} ··· 107 109 hx-post="/spindles/{{ $root.Spindle.Instance }}/remove" 108 110 hx-swap="none" 109 111 hx-vals='{"member": "{{$member}}" }' 110 - hx-confirm="Are you sure you want to remove {{ index $root.DidHandleMap $member }} from this instance?" 112 + hx-confirm="Are you sure you want to remove {{ resolve $member }} from this instance?" 111 113 > 112 114 {{ i "user-minus" "w-4 h-4" }} 113 115 remove
+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> ··· 104 103 {{ $root := index . 0 }} 105 104 {{ $star := index . 1 }} 106 105 {{ with $star }} 107 - {{ $starrerHandle := index $root.DidHandleMap .StarredByDid }} 108 - {{ $repoOwnerHandle := index $root.DidHandleMap .Repo.Did }} 106 + {{ $starrerHandle := resolve .StarredByDid }} 107 + {{ $repoOwnerHandle := resolve .Repo.Did }} 109 108 <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"> 110 109 {{ template "user/fragments/picHandleLink" $starrerHandle }} 111 110 starred ··· 127 126 {{ $profile := index . 2 }} 128 127 {{ $stat := index . 3 }} 129 128 130 - {{ $userHandle := index $root.DidHandleMap $follow.UserDid }} 131 - {{ $subjectHandle := index $root.DidHandleMap $follow.SubjectDid }} 129 + {{ $userHandle := resolve $follow.UserDid }} 130 + {{ $subjectHandle := resolve $follow.SubjectDid }} 132 131 <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"> 133 132 {{ template "user/fragments/picHandleLink" $userHandle }} 134 133 followed
+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
··· 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
··· 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
··· 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 }} ··· 84 87 {{ i "book-plus" "w-4 h-4" }} 85 88 {{ end }} 86 89 </span> 87 - <a href="/{{ index $handleMap .Repo.Did }}/{{ .Repo.Name }}" class="no-underline hover:underline"> 90 + <a href="/{{ resolve .Repo.Did }}/{{ .Repo.Name }}" class="no-underline hover:underline"> 88 91 {{- .Repo.Name -}} 89 92 </a> 90 93 </div> ··· 95 98 {{ end }} 96 99 97 100 {{ define "issueEvents" }} 98 - {{ $i := index . 0 }} 99 - {{ $items := $i.Items }} 100 - {{ $stats := $i.Stats }} 101 - {{ $handleMap := index . 1 }} 101 + {{ $items := .Items }} 102 + {{ $stats := .Stats }} 102 103 103 104 {{ if gt (len $items) 0 }} 104 105 <details> ··· 124 129 </summary> 125 130 <div class="py-2 text-sm flex flex-col gap-3 mb-2"> 126 131 {{ range $items }} 127 - {{ $repoOwner := index $handleMap .Metadata.Repo.Did }} 132 + {{ $repoOwner := resolve .Metadata.Repo.Did }} 128 133 {{ $repoName := .Metadata.Repo.Name }} 129 134 {{ $repoUrl := printf "%s/%s" $repoOwner $repoName }} 130 135 ··· 158 163 {{ end }} 159 164 160 165 {{ define "pullEvents" }} 161 - {{ $i := index . 0 }} 162 - {{ $items := $i.Items }} 163 - {{ $stats := $i.Stats }} 164 - {{ $handleMap := index . 1 }} 166 + {{ $items := .Items }} 167 + {{ $stats := .Stats }} 165 168 {{ if gt (len $items) 0 }} 166 169 <details> 167 170 <summary class="list-none cursor-pointer hover:text-gray-500 hover:dark:text-gray-400"> ··· 193 200 </summary> 194 201 <div class="py-2 text-sm flex flex-col gap-3 mb-2"> 195 202 {{ range $items }} 196 - {{ $repoOwner := index $handleMap .Repo.Did }} 203 + {{ $repoOwner := resolve .Repo.Did }} 197 204 {{ $repoName := .Repo.Name }} 198 205 {{ $repoUrl := printf "%s/%s" $repoOwner $repoName }} 199 206
-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 { ··· 202 212 s.pages.RepoSinglePull(w, pages.RepoSinglePullParams{ 203 213 LoggedInUser: user, 204 214 RepoInfo: repoInfo, 205 - DidHandleMap: didHandleMap, 206 215 Pull: pull, 207 216 Stack: stack, 208 217 AbandonedPulls: abandonedPulls, ··· 366 377 return 367 378 } 368 379 369 - identsToResolve := []string{pull.OwnerDid} 370 - resolvedIds := s.idResolver.ResolveIdents(r.Context(), identsToResolve) 371 - didHandleMap := make(map[string]string) 372 - for _, identity := range resolvedIds { 373 - if !identity.Handle.IsInvalidHandle() { 374 - didHandleMap[identity.DID.String()] = fmt.Sprintf("@%s", identity.Handle.String()) 375 - } else { 376 - didHandleMap[identity.DID.String()] = identity.DID.String() 377 - } 378 - } 379 - 380 380 patch := pull.Submissions[roundIdInt].Patch 381 381 diff := patchutil.AsNiceDiff(patch, pull.TargetBranch) 382 382 383 383 s.pages.RepoPullPatchPage(w, pages.RepoPullPatchParams{ 384 384 LoggedInUser: user, 385 - DidHandleMap: didHandleMap, 386 385 RepoInfo: f.RepoInfo(user), 387 386 Pull: pull, 388 387 Stack: stack, ··· 417 440 return 418 441 } 419 442 420 - identsToResolve := []string{pull.OwnerDid} 421 - resolvedIds := s.idResolver.ResolveIdents(r.Context(), identsToResolve) 422 - didHandleMap := make(map[string]string) 423 - for _, identity := range resolvedIds { 424 - if !identity.Handle.IsInvalidHandle() { 425 - didHandleMap[identity.DID.String()] = fmt.Sprintf("@%s", identity.Handle.String()) 426 - } else { 427 - didHandleMap[identity.DID.String()] = identity.DID.String() 428 - } 429 - } 430 - 431 443 currentPatch, err := patchutil.AsDiff(pull.Submissions[roundIdInt].Patch) 432 444 if err != nil { 433 445 log.Println("failed to interdiff; current patch malformed") ··· 438 472 RepoInfo: f.RepoInfo(user), 439 473 Pull: pull, 440 474 Round: roundIdInt, 441 - DidHandleMap: didHandleMap, 442 475 Interdiff: interdiff, 443 476 DiffOpts: diffOpts, 444 477 }) ··· 457 492 http.Error(w, "bad round id", http.StatusBadRequest) 458 493 log.Println("failed to parse round id", err) 459 494 return 460 - } 461 - 462 - identsToResolve := []string{pull.OwnerDid} 463 - resolvedIds := s.idResolver.ResolveIdents(r.Context(), identsToResolve) 464 - didHandleMap := make(map[string]string) 465 - for _, identity := range resolvedIds { 466 - if !identity.Handle.IsInvalidHandle() { 467 - didHandleMap[identity.DID.String()] = fmt.Sprintf("@%s", identity.Handle.String()) 468 - } else { 469 - didHandleMap[identity.DID.String()] = identity.DID.String() 470 - } 471 495 } 472 496 473 497 w.Header().Set("Content-Type", "text/plain; charset=utf-8") ··· 549 595 m[p.Sha] = p 550 596 } 551 597 552 - identsToResolve := make([]string, len(pulls)) 553 - for i, pull := range pulls { 554 - identsToResolve[i] = pull.OwnerDid 555 - } 556 - resolvedIds := s.idResolver.ResolveIdents(r.Context(), identsToResolve) 557 - didHandleMap := make(map[string]string) 558 - for _, identity := range resolvedIds { 559 - if !identity.Handle.IsInvalidHandle() { 560 - didHandleMap[identity.DID.String()] = fmt.Sprintf("@%s", identity.Handle.String()) 561 - } else { 562 - didHandleMap[identity.DID.String()] = identity.DID.String() 563 - } 564 - } 565 - 566 598 s.pages.RepoPulls(w, pages.RepoPullsParams{ 567 599 LoggedInUser: s.oauth.GetUser(r), 568 600 RepoInfo: f.RepoInfo(user), 569 601 Pulls: pulls, 570 - DidHandleMap: didHandleMap, 571 602 FilteringBy: state, 572 603 Stacks: stacks, 573 604 Pipelines: m,
-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 { ··· 124 136 Spindle: spindle, 125 137 Members: members, 126 138 Repos: repoMap, 127 - DidHandleMap: didHandleMap, 128 139 }) 129 140 } 130 141
-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) ··· 135 145 LoggedInUser: loggedInUser, 136 146 Repos: pinnedRepos, 137 147 CollaboratingRepos: pinnedCollaboratingRepos, 138 - DidHandleMap: didHandleMap, 139 148 Card: pages.ProfileCard{ 140 149 UserDid: ident.DID.String(), 141 150 UserHandle: ident.Handle.String(), ··· 183 194 s.pages.ReposPage(w, pages.ReposPageParams{ 184 195 LoggedInUser: loggedInUser, 185 196 Repos: repos, 186 - DidHandleMap: map[string]string{ident.DID.String(): ident.Handle.String()}, 187 197 Card: pages.ProfileCard{ 188 198 UserDid: ident.DID.String(), 189 199 UserHandle: ident.Handle.String(), ··· 506 518 }) 507 519 } 508 520 509 - var didsToResolve []string 510 - for _, r := range allRepos { 511 - didsToResolve = append(didsToResolve, r.Did) 512 - } 513 - resolvedIds := s.idResolver.ResolveIdents(r.Context(), didsToResolve) 514 - didHandleMap := make(map[string]string) 515 - for _, identity := range resolvedIds { 516 - if !identity.Handle.IsInvalidHandle() { 517 - didHandleMap[identity.DID.String()] = fmt.Sprintf("@%s", identity.Handle.String()) 518 - } else { 519 - didHandleMap[identity.DID.String()] = identity.DID.String() 520 - } 521 - } 522 - 523 521 s.pages.EditPinsFragment(w, pages.EditPinsParams{ 524 522 LoggedInUser: user, 525 523 Profile: profile, 526 524 AllRepos: allRepos, 527 - DidHandleMap: didHandleMap, 528 525 }) 529 526 }
+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) {