forked from tangled.org/core
this repo has no description

appview/pages: show tiny avatar in more places

Also fixes OrderedReactionKinds breaking patch/interdiff pages.

Signed-off-by: Anirudh Oppiliappan <anirudh@tangled.sh>

anirudh.fi 83937565 9b2bf899

verified
Changed files
+53 -44
appview
+20 -18
appview/pages/pages.go
··· 691 DidHandleMap map[string]string 692 693 OrderedReactionKinds []db.ReactionKind 694 - Reactions map[db.ReactionKind]int 695 - UserReacted map[db.ReactionKind]bool 696 697 State string 698 } 699 700 type ThreadReactionFragmentParams struct { 701 ThreadAt syntax.ATURI 702 - Kind db.ReactionKind 703 - Count int 704 IsReacted bool 705 } 706 ··· 825 } 826 827 type RepoPullPatchParams struct { 828 - LoggedInUser *oauth.User 829 - DidHandleMap map[string]string 830 - RepoInfo repoinfo.RepoInfo 831 - Pull *db.Pull 832 - Stack db.Stack 833 - Diff *types.NiceDiff 834 - Round int 835 - Submission *db.PullSubmission 836 } 837 838 // this name is a mouthful ··· 841 } 842 843 type RepoPullInterdiffParams struct { 844 - LoggedInUser *oauth.User 845 - DidHandleMap map[string]string 846 - RepoInfo repoinfo.RepoInfo 847 - Pull *db.Pull 848 - Round int 849 - Interdiff *patchutil.InterdiffResult 850 } 851 852 // this name is a mouthful
··· 691 DidHandleMap map[string]string 692 693 OrderedReactionKinds []db.ReactionKind 694 + Reactions map[db.ReactionKind]int 695 + UserReacted map[db.ReactionKind]bool 696 697 State string 698 } 699 700 type ThreadReactionFragmentParams struct { 701 ThreadAt syntax.ATURI 702 + Kind db.ReactionKind 703 + Count int 704 IsReacted bool 705 } 706 ··· 825 } 826 827 type RepoPullPatchParams struct { 828 + LoggedInUser *oauth.User 829 + DidHandleMap map[string]string 830 + RepoInfo repoinfo.RepoInfo 831 + Pull *db.Pull 832 + Stack db.Stack 833 + Diff *types.NiceDiff 834 + Round int 835 + Submission *db.PullSubmission 836 + OrderedReactionKinds []db.ReactionKind 837 } 838 839 // this name is a mouthful ··· 842 } 843 844 type RepoPullInterdiffParams struct { 845 + LoggedInUser *oauth.User 846 + DidHandleMap map[string]string 847 + RepoInfo repoinfo.RepoInfo 848 + Pull *db.Pull 849 + Round int 850 + Interdiff *patchutil.InterdiffResult 851 + OrderedReactionKinds []db.ReactionKind 852 } 853 854 // this name is a mouthful
+1 -1
appview/pages/templates/layouts/topbar.html
··· 39 class="cursor-pointer list-none flex items-center" 40 > 41 {{ $user := didOrHandle .Did .Handle }} 42 - {{ template "user/fragments/picHandle" $user }} 43 </summary> 44 <div 45 class="absolute flex flex-col right-0 mt-4 p-4 rounded w-48 bg-white dark:bg-gray-800 dark:text-white border border-gray-200 dark:border-gray-700"
··· 39 class="cursor-pointer list-none flex items-center" 40 > 41 {{ $user := didOrHandle .Did .Handle }} 42 + {{ template "user/fragments/picHandleLink" $user }} 43 </summary> 44 <div 45 class="absolute flex flex-col right-0 mt-4 p-4 rounded w-48 bg-white dark:bg-gray-800 dark:text-white border border-gray-200 dark:border-gray-700"
+1 -1
appview/pages/templates/repo/commit.html
··· 59 <div class="flex items-center gap-2 my-2"> 60 {{ i "user" "w-4 h-4" }} 61 {{ $committerDidOrHandle := index $.EmailToDidOrHandle $commit.Committer.Email }} 62 - <a href="/{{ $committerDidOrHandle }}">{{ $committerDidOrHandle }}</a> 63 </div> 64 <div class="my-1 pt-2 text-xs border-t"> 65 <div class="text-gray-600 dark:text-gray-300">SSH Key Fingerprint:</div>
··· 59 <div class="flex items-center gap-2 my-2"> 60 {{ i "user" "w-4 h-4" }} 61 {{ $committerDidOrHandle := index $.EmailToDidOrHandle $commit.Committer.Email }} 62 + <a href="/{{ $committerDidOrHandle }}">{{ template "user/fragments/picHandleLink" $committerDidOrHandle }}</a> 63 </div> 64 <div class="my-1 pt-2 text-xs border-t"> 65 <div class="text-gray-600 dark:text-gray-300">SSH Key Fingerprint:</div>
+1 -1
appview/pages/templates/repo/index.html
··· 266 {{ end }}" 267 class="text-gray-500 dark:text-gray-400 no-underline hover:underline" 268 >{{ if $didOrHandle }} 269 - {{ $didOrHandle }} 270 {{ else }} 271 {{ .Author.Name }} 272 {{ end }}</a
··· 266 {{ end }}" 267 class="text-gray-500 dark:text-gray-400 no-underline hover:underline" 268 >{{ if $didOrHandle }} 269 + {{ template "user/fragments/picHandleLink" $didOrHandle }} 270 {{ else }} 271 {{ .Author.Name }} 272 {{ end }}</a
+6 -6
appview/pages/templates/repo/issues/fragments/issueComment.html
··· 1 {{ define "repo/issues/fragments/issueComment" }} 2 {{ with .Comment }} 3 <div id="comment-container-{{.CommentId}}"> 4 - <div class="flex items-center gap-2 mb-2 text-gray-500 dark:text-gray-400 text-sm"> 5 {{ $owner := index $.DidHandleMap .OwnerDid }} 6 - <a href="/{{ $owner }}" class="no-underline hover:underline">{{ $owner }}</a> 7 8 <span class="before:content-['·']"></span> 9 <a ··· 18 {{ .Created | timeFmt }} 19 {{ end }} 20 </a> 21 - 22 <!-- show user "hats" --> 23 {{ $isIssueAuthor := eq .OwnerDid $.Issue.OwnerDid }} 24 {{ if $isIssueAuthor }} ··· 29 30 {{ $isCommentOwner := and $.LoggedInUser (eq $.LoggedInUser.Did .OwnerDid) }} 31 {{ if and $isCommentOwner (not .Deleted) }} 32 - <button 33 - class="btn px-2 py-1 text-sm" 34 hx-get="/{{ $.RepoInfo.FullName }}/issues/{{ .Issue }}/comment/{{ .CommentId }}/edit" 35 hx-swap="outerHTML" 36 hx-target="#comment-container-{{.CommentId}}" 37 > 38 {{ i "pencil" "w-4 h-4" }} 39 </button> 40 - <button 41 class="btn px-2 py-1 text-sm text-red-500 flex gap-2 items-center group" 42 hx-delete="/{{ $.RepoInfo.FullName }}/issues/{{ .Issue }}/comment/{{ .CommentId }}/" 43 hx-confirm="Are you sure you want to delete your comment?"
··· 1 {{ define "repo/issues/fragments/issueComment" }} 2 {{ with .Comment }} 3 <div id="comment-container-{{.CommentId}}"> 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 }} 7 8 <span class="before:content-['·']"></span> 9 <a ··· 18 {{ .Created | timeFmt }} 19 {{ end }} 20 </a> 21 + 22 <!-- show user "hats" --> 23 {{ $isIssueAuthor := eq .OwnerDid $.Issue.OwnerDid }} 24 {{ if $isIssueAuthor }} ··· 29 30 {{ $isCommentOwner := and $.LoggedInUser (eq $.LoggedInUser.Did .OwnerDid) }} 31 {{ if and $isCommentOwner (not .Deleted) }} 32 + <button 33 + class="btn px-2 py-1 text-sm" 34 hx-get="/{{ $.RepoInfo.FullName }}/issues/{{ .Issue }}/comment/{{ .CommentId }}/edit" 35 hx-swap="outerHTML" 36 hx-target="#comment-container-{{.CommentId}}" 37 > 38 {{ i "pencil" "w-4 h-4" }} 39 </button> 40 + <button 41 class="btn px-2 py-1 text-sm text-red-500 flex gap-2 items-center group" 42 hx-delete="/{{ $.RepoInfo.FullName }}/issues/{{ .Issue }}/comment/{{ .CommentId }}/" 43 hx-confirm="Are you sure you want to delete your comment?"
+1 -1
appview/pages/templates/repo/issues/issue.html
··· 90 > 91 <div class="bg-white dark:bg-gray-800 rounded drop-shadow-sm py-4 px-4 relative w-full md:w-3/5"> 92 <div class="text-sm pb-2 text-gray-500 dark:text-gray-400"> 93 - {{ didOrHandle .LoggedInUser.Did .LoggedInUser.Handle }} 94 </div> 95 <textarea 96 id="comment-textarea"
··· 90 > 91 <div class="bg-white dark:bg-gray-800 rounded drop-shadow-sm py-4 px-4 relative w-full md:w-3/5"> 92 <div class="text-sm pb-2 text-gray-500 dark:text-gray-400"> 93 + {{ template "user/fragments/picHandleLink" (didOrHandle .LoggedInUser.Did .LoggedInUser.Handle) }} 94 </div> 95 <textarea 96 id="comment-textarea"
+2 -2
appview/pages/templates/repo/log.html
··· 31 <td class=" py-3 align-top"> 32 {{ $didOrHandle := index $.EmailToDidOrHandle $commit.Author.Email }} 33 {{ if $didOrHandle }} 34 - <a href="/{{ $didOrHandle }}" class="text-gray-700 dark:text-gray-300 no-underline hover:underline">{{ $didOrHandle }}</a> 35 {{ else }} 36 <a href="mailto:{{ $commit.Author.Email }}" class="text-gray-700 dark:text-gray-300 no-underline hover:underline">{{ $commit.Author.Name }}</a> 37 {{ end }} ··· 159 {{ $didOrHandle := index $.EmailToDidOrHandle $commit.Author.Email }} 160 <a href="{{ if $didOrHandle }}/{{ $didOrHandle }}{{ else }}mailto:{{ $commit.Author.Email }}{{ end }}" 161 class="text-gray-500 dark:text-gray-400 no-underline hover:underline"> 162 - {{ if $didOrHandle }}{{ $didOrHandle }}{{ else }}{{ $commit.Author.Name }}{{ end }} 163 </a> 164 </span> 165 <div class="inline-block px-1 select-none after:content-['·']"></div>
··· 31 <td class=" py-3 align-top"> 32 {{ $didOrHandle := index $.EmailToDidOrHandle $commit.Author.Email }} 33 {{ if $didOrHandle }} 34 + {{ template "user/fragments/picHandleLink" $didOrHandle }} 35 {{ else }} 36 <a href="mailto:{{ $commit.Author.Email }}" class="text-gray-700 dark:text-gray-300 no-underline hover:underline">{{ $commit.Author.Name }}</a> 37 {{ end }} ··· 159 {{ $didOrHandle := index $.EmailToDidOrHandle $commit.Author.Email }} 160 <a href="{{ if $didOrHandle }}/{{ $didOrHandle }}{{ else }}mailto:{{ $commit.Author.Email }}{{ end }}" 161 class="text-gray-500 dark:text-gray-400 no-underline hover:underline"> 162 + {{ if $didOrHandle }}{{ template "user/fragments/picHandleLink" $didOrHandle }}{{ else }}{{ $commit.Author.Name }}{{ end }} 163 </a> 164 </span> 165 <div class="inline-block px-1 select-none after:content-['·']"></div>
+4 -2
appview/pages/templates/repo/pulls/fragments/pullHeader.html
··· 62 </article> 63 {{ end }} 64 65 <div class="flex items-center gap-2 mt-2"> 66 - {{ template "repo/fragments/reactionsPopUp" .OrderedReactionKinds }} 67 - {{ range $kind := .OrderedReactionKinds }} 68 {{ 69 template "repo/fragments/reaction" 70 (dict ··· 75 }} 76 {{ end }} 77 </div> 78 </section> 79 80
··· 62 </article> 63 {{ end }} 64 65 + {{ with .OrderedReactionKinds }} 66 <div class="flex items-center gap-2 mt-2"> 67 + {{ template "repo/fragments/reactionsPopUp" . }} 68 + {{ range $kind := . }} 69 {{ 70 template "repo/fragments/reaction" 71 (dict ··· 76 }} 77 {{ end }} 78 </div> 79 + {{ end }} 80 </section> 81 82
+3 -4
appview/pages/templates/repo/pulls/fragments/pullNewComment.html
··· 1 {{ define "repo/pulls/fragments/pullNewComment" }} 2 - <div 3 - id="pull-comment-card-{{ .RoundNumber }}" 4 class="bg-white dark:bg-gray-800 rounded drop-shadow-sm p-4 relative w-full flex flex-col gap-2"> 5 <div class="text-sm text-gray-500 dark:text-gray-400"> 6 - {{ didOrHandle .LoggedInUser.Did .LoggedInUser.Handle }} 7 </div> 8 <form 9 hx-post="/{{ .RepoInfo.FullName }}/pulls/{{ .Pull.PullId }}/round/{{ .RoundNumber }}/comment" ··· 38 </form> 39 </div> 40 {{ end }} 41 -
··· 1 {{ define "repo/pulls/fragments/pullNewComment" }} 2 + <div 3 + id="pull-comment-card-{{ .RoundNumber }}" 4 class="bg-white dark:bg-gray-800 rounded drop-shadow-sm p-4 relative w-full flex flex-col gap-2"> 5 <div class="text-sm text-gray-500 dark:text-gray-400"> 6 + {{ template "user/fragments/picHandleLink" (didOrHandle .LoggedInUser.Did .LoggedInUser.Handle) }} 7 </div> 8 <form 9 hx-post="/{{ .RepoInfo.FullName }}/pulls/{{ .Pull.PullId }}/round/{{ .RoundNumber }}/comment" ··· 38 </form> 39 </div> 40 {{ end }}
+7 -7
appview/pages/templates/repo/pulls/pull.html
··· 5 {{ define "extrameta" }} 6 {{ $title := printf "%s &middot; pull #%d &middot; %s" .Pull.Title .Pull.PullId .RepoInfo.FullName }} 7 {{ $url := printf "https://tangled.sh/%s/pulls/%d" .RepoInfo.FullName .Pull.PullId }} 8 - 9 {{ template "repo/fragments/og" (dict "RepoInfo" .RepoInfo "Title" $title "Url" $url) }} 10 {{ end }} 11 ··· 46 </div> 47 <!-- round summary --> 48 <div class="rounded drop-shadow-sm bg-white dark:bg-gray-800 p-2 text-gray-500 dark:text-gray-400"> 49 - <span> 50 {{ $owner := index $.DidHandleMap $.Pull.OwnerDid }} 51 {{ $re := "re" }} 52 {{ if eq .RoundNumber 0 }} 53 {{ $re = "" }} 54 {{ end }} 55 <span class="hidden md:inline">{{$re}}submitted</span> 56 - by <a href="/{{ $owner }}">{{ $owner }}</a> 57 <span class="select-none before:content-['\00B7']"></span> 58 <a class="text-gray-500 dark:text-gray-400 hover:text-gray-500" href="#round-#{{ .RoundNumber }}"><time>{{ .Created | shortTimeFmt }}</time></a> 59 <span class="select-none before:content-['·']"></span> ··· 68 <a class="btn flex items-center gap-2 no-underline hover:no-underline p-2 group" 69 hx-boost="true" 70 href="/{{ $.RepoInfo.FullName }}/pulls/{{ $.Pull.PullId }}/round/{{.RoundNumber}}"> 71 - {{ i "file-diff" "w-4 h-4" }} 72 <span class="hidden md:inline">diff</span> 73 {{ i "loader-circle" "w-4 h-4 animate-spin hidden group-[.htmx-request]:inline" }} 74 </a> ··· 150 {{ if gt $cidx 0 }} 151 <div class="absolute left-8 -top-2 w-px h-2 bg-gray-300 dark:bg-gray-600"></div> 152 {{ end }} 153 - <div class="text-sm text-gray-500 dark:text-gray-400"> 154 - {{ $owner := index $.DidHandleMap $c.OwnerDid }} 155 - <a href="/{{$owner}}">{{$owner}}</a> 156 <span class="before:content-['·']"></span> 157 <a class="text-gray-500 dark:text-gray-400 hover:text-gray-500 dark:hover:text-gray-300" href="#comment-{{.ID}}"><time>{{ $c.Created | shortTimeFmt }}</time></a> 158 </div>
··· 5 {{ define "extrameta" }} 6 {{ $title := printf "%s &middot; pull #%d &middot; %s" .Pull.Title .Pull.PullId .RepoInfo.FullName }} 7 {{ $url := printf "https://tangled.sh/%s/pulls/%d" .RepoInfo.FullName .Pull.PullId }} 8 + 9 {{ template "repo/fragments/og" (dict "RepoInfo" .RepoInfo "Title" $title "Url" $url) }} 10 {{ end }} 11 ··· 46 </div> 47 <!-- round summary --> 48 <div class="rounded drop-shadow-sm bg-white dark:bg-gray-800 p-2 text-gray-500 dark:text-gray-400"> 49 + <span class="gap-1 flex items-center"> 50 {{ $owner := index $.DidHandleMap $.Pull.OwnerDid }} 51 {{ $re := "re" }} 52 {{ if eq .RoundNumber 0 }} 53 {{ $re = "" }} 54 {{ end }} 55 <span class="hidden md:inline">{{$re}}submitted</span> 56 + by {{ template "user/fragments/picHandleLink" $owner }} 57 <span class="select-none before:content-['\00B7']"></span> 58 <a class="text-gray-500 dark:text-gray-400 hover:text-gray-500" href="#round-#{{ .RoundNumber }}"><time>{{ .Created | shortTimeFmt }}</time></a> 59 <span class="select-none before:content-['·']"></span> ··· 68 <a class="btn flex items-center gap-2 no-underline hover:no-underline p-2 group" 69 hx-boost="true" 70 href="/{{ $.RepoInfo.FullName }}/pulls/{{ $.Pull.PullId }}/round/{{.RoundNumber}}"> 71 + {{ i "file-diff" "w-4 h-4" }} 72 <span class="hidden md:inline">diff</span> 73 {{ i "loader-circle" "w-4 h-4 animate-spin hidden group-[.htmx-request]:inline" }} 74 </a> ··· 150 {{ if gt $cidx 0 }} 151 <div class="absolute left-8 -top-2 w-px h-2 bg-gray-300 dark:bg-gray-600"></div> 152 {{ end }} 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 }} 156 <span class="before:content-['·']"></span> 157 <a class="text-gray-500 dark:text-gray-400 hover:text-gray-500 dark:hover:text-gray-300" href="#comment-{{.ID}}"><time>{{ $c.Created | shortTimeFmt }}</time></a> 158 </div>
+7 -1
appview/pages/templates/repo/tree.html
··· 11 {{ template "repo/fragments/meta" . }} 12 {{ $title := printf "%s at %s &middot; %s" $path .Ref .RepoInfo.FullName }} 13 {{ $url := printf "https://tangled.sh/%s/tree/%s%s" .RepoInfo.FullName .Ref $path }} 14 - 15 {{ template "repo/fragments/og" (dict "RepoInfo" .RepoInfo "Title" $title "Url" $url) }} 16 {{ end }} 17 ··· 63 </div> 64 </a> 65 {{ if .LastCommit}} 66 <time class="text-xs text-gray-500 dark:text-gray-400">{{ timeFmt .LastCommit.When }}</time> 67 {{ end }} 68 </div> 69 </div> ··· 80 </div> 81 </a> 82 {{ if .LastCommit}} 83 <time class="text-xs text-gray-500 dark:text-gray-400">{{ timeFmt .LastCommit.When }}</time> 84 {{ end }} 85 </div> 86 </div>
··· 11 {{ template "repo/fragments/meta" . }} 12 {{ $title := printf "%s at %s &middot; %s" $path .Ref .RepoInfo.FullName }} 13 {{ $url := printf "https://tangled.sh/%s/tree/%s%s" .RepoInfo.FullName .Ref $path }} 14 + 15 {{ template "repo/fragments/og" (dict "RepoInfo" .RepoInfo "Title" $title "Url" $url) }} 16 {{ end }} 17 ··· 63 </div> 64 </a> 65 {{ if .LastCommit}} 66 + <div class="flex items-end gap-2"> 67 + <span class="text text-gray-500 dark:text-gray-400 mr-6">{{ .LastCommit.Message }}</span> 68 <time class="text-xs text-gray-500 dark:text-gray-400">{{ timeFmt .LastCommit.When }}</time> 69 + </div> 70 {{ end }} 71 </div> 72 </div> ··· 83 </div> 84 </a> 85 {{ if .LastCommit}} 86 + <div class="flex items-end gap-2"> 87 + <span class="text text-gray-500 dark:text-gray-400 mr-6">{{ .LastCommit.Message }}</span> 88 <time class="text-xs text-gray-500 dark:text-gray-400">{{ timeFmt .LastCommit.When }}</time> 89 + </div> 90 {{ end }} 91 </div> 92 </div>