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

appview: repo: show ssh fingerprint info on hover

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

anirudh.fi 656a4c86 9fb5e15b

verified
Changed files
+46 -32
appview
commitverify
pages
repo
-2
appview/commitverify/verify.go
··· 1 package commitverify 2 3 import ( 4 - "fmt" 5 "log" 6 7 "github.com/go-git/go-git/v5/plumbing/object" ··· 74 if err != nil { 75 log.Println("error computing ssh fingerprint:", err) 76 } 77 - fmt.Println(fp) 78 79 vc := verifiedCommit{fingerprint: fp, hash: c.This} 80 vcs[vc] = struct{}{}
··· 1 package commitverify 2 3 import ( 4 "log" 5 6 "github.com/go-git/go-git/v5/plumbing/object" ··· 73 if err != nil { 74 log.Println("error computing ssh fingerprint:", err) 75 } 76 77 vc := verifiedCommit{fingerprint: fp, hash: c.This} 78 vcs[vc] = struct{}{}
+6 -3
appview/pages/pages.go
··· 15 "path/filepath" 16 "strings" 17 18 "tangled.sh/tangled.sh/core/appview/config" 19 "tangled.sh/tangled.sh/core/appview/db" 20 "tangled.sh/tangled.sh/core/appview/oauth" ··· 414 HTMLReadme template.HTML 415 Raw bool 416 EmailToDidOrHandle map[string]string 417 - VerifiedCommits map[string]bool 418 Languages *types.RepoLanguageResponse 419 types.RepoIndexResponse 420 } ··· 453 types.RepoLogResponse 454 Active string 455 EmailToDidOrHandle map[string]string 456 - VerifiedCommits map[string]bool 457 } 458 459 func (p *Pages) RepoLog(w io.Writer, params RepoLogParams) error { ··· 466 RepoInfo repoinfo.RepoInfo 467 Active string 468 EmailToDidOrHandle map[string]string 469 - Verified bool 470 471 types.RepoCommitResponse 472 }
··· 15 "path/filepath" 16 "strings" 17 18 + "tangled.sh/tangled.sh/core/appview/commitverify" 19 "tangled.sh/tangled.sh/core/appview/config" 20 "tangled.sh/tangled.sh/core/appview/db" 21 "tangled.sh/tangled.sh/core/appview/oauth" ··· 415 HTMLReadme template.HTML 416 Raw bool 417 EmailToDidOrHandle map[string]string 418 + VerifiedCommits commitverify.VerifiedCommits 419 Languages *types.RepoLanguageResponse 420 types.RepoIndexResponse 421 } ··· 454 types.RepoLogResponse 455 Active string 456 EmailToDidOrHandle map[string]string 457 + VerifiedCommits commitverify.VerifiedCommits 458 } 459 460 func (p *Pages) RepoLog(w io.Writer, params RepoLogParams) error { ··· 467 RepoInfo repoinfo.RepoInfo 468 Active string 469 EmailToDidOrHandle map[string]string 470 + 471 + // singular because it's always going to be just one 472 + VerifiedCommit commitverify.VerifiedCommits 473 474 types.RepoCommitResponse 475 }
+21 -6
appview/pages/templates/repo/commit.html
··· 46 {{ end }} 47 </p> 48 49 - {{ if .Verified }} 50 - <span class="text-sm bg-green-100 text-green-800 dark:bg-green-900 dark:text-green-200 px-2 py-1 rounded"> 51 - <div class="flex items-center gap-2"> 52 - {{ i "shield-check" "w-4 h-4" }} 53 - verified 54 </div> 55 - </span> 56 {{ end }} 57 </div> 58 ··· 61 {{end}} 62 63 {{ define "repoAfter" }} 64 {{ template "repo/fragments/diff" (list .RepoInfo.FullName .Diff) }} 65 {{end}}
··· 46 {{ end }} 47 </p> 48 49 + {{ if .VerifiedCommit.IsVerified $commit.This }} 50 + <div class="group relative inline-block text-sm"> 51 + <div class="bg-green-100 text-green-800 dark:bg-green-900 dark:text-green-200 px-2 py-1 rounded cursor-pointer"> 52 + <div class="flex items-center gap-2"> 53 + {{ i "shield-check" "w-4 h-4" }} 54 + verified 55 + </div> 56 + </div> 57 + <div class="absolute z-[9999] hidden group-hover:block bg-white dark:bg-gray-900 text-sm text-black dark:text-white rounded-md shadow-md p-4 w-80 top-full mt-2"> 58 + <div class="mb-1">This commit was signed with the committer's <span class="text-green-600 font-semibold">known signature</span>.</div> 59 + <div class="flex items-center gap-2 my-2"> 60 + {{ i "user" "w-4 h-4" }} 61 + <a href="/{{ $didOrHandle }}">{{ $didOrHandle }}</a> 62 + </div> 63 + <div class="my-1 pt-2 text-xs border-t"> 64 + <div class="text-gray-600 dark:text-gray-300">SSH Key Fingerprint:</div> 65 + <div class="break-all">{{ .VerifiedCommit.Fingerprint $commit.This }}</div> 66 + </div> 67 </div> 68 + </div> 69 {{ end }} 70 </div> 71 ··· 74 {{end}} 75 76 {{ define "repoAfter" }} 77 + <div class="-z-[9999]"> 78 {{ template "repo/fragments/diff" (list .RepoInfo.FullName .Diff) }} 79 + </div> 80 {{end}}
+1 -2
appview/pages/templates/repo/index.html
··· 223 </div> 224 225 <div class="text-xs mt-2 text-gray-500 dark:text-gray-400 flex items-center"> 226 - {{ $verified := false }} 227 - {{ $verified = index $.VerifiedCommits .Hash.String }} 228 {{ $hashStyle := "text-gray-700 dark:text-gray-300 bg-gray-100 dark:bg-gray-900" }} 229 {{ if $verified }} 230 {{ $hashStyle = "bg-green-100 text-green-800 dark:bg-green-900 dark:text-green-200 px-2 rounded" }}
··· 223 </div> 224 225 <div class="text-xs mt-2 text-gray-500 dark:text-gray-400 flex items-center"> 226 + {{ $verified := $.VerifiedCommits.IsVerified .Hash.String }} 227 {{ $hashStyle := "text-gray-700 dark:text-gray-300 bg-gray-100 dark:bg-gray-900" }} 228 {{ if $verified }} 229 {{ $hashStyle = "bg-green-100 text-green-800 dark:bg-green-900 dark:text-green-200 px-2 rounded" }}
+13 -15
appview/pages/templates/repo/log.html
··· 3 {{ define "extrameta" }} 4 {{ $title := printf "commits &middot; %s" .RepoInfo.FullName }} 5 {{ $url := printf "https://tangled.sh/%s/commits" .RepoInfo.FullName }} 6 - 7 {{ template "repo/fragments/og" (dict "RepoInfo" .RepoInfo "Title" $title "Url" $url) }} 8 {{ end }} 9 10 {{ define "repoContent" }} 11 <section id="commit-table" class="overflow-x-auto"> 12 <h2 class="font-bold text-sm mb-4 uppercase dark:text-white"> 13 - commits 14 </h2> 15 16 <!-- desktop view (hidden on small screens) --> ··· 36 {{ end }} 37 </td> 38 <td class="py-3 align-top font-mono flex items-center"> 39 - {{ $verified := false }} 40 - {{ $verified = index $.VerifiedCommits $commit.Hash.String }} 41 {{ $hashStyle := "text-gray-700 dark:text-gray-300 bg-gray-100 dark:bg-gray-900" }} 42 {{ if $verified }} 43 {{ $hashStyle = "bg-green-100 text-green-800 dark:bg-green-900 dark:text-green-200 px-2 rounded" }} ··· 49 {{ end }} 50 </a> 51 <div class="{{ if not $verified }} ml-6 {{ end }}inline-flex"> 52 - <button class="p-1 mx-1 hover:bg-gray-100 dark:hover:bg-gray-700 rounded" 53 title="Copy SHA" 54 onclick="navigator.clipboard.writeText('{{ $commit.Hash.String }}'); this.innerHTML=`{{ i "copy-check" "w-4 h-4" }}`; setTimeout(() => this.innerHTML=`{{ i "copy" "w-4 h-4" }}`, 1500)"> 55 {{ i "copy" "w-4 h-4" }} ··· 63 <div> 64 <div class="flex items-center justify-start"> 65 <a href="/{{ $.RepoInfo.FullName }}/commit/{{ $commit.Hash.String }}" class="dark:text-white no-underline hover:underline">{{ index $messageParts 0 }}</a> 66 - {{ if gt (len $messageParts) 1 }} 67 <button class="ml-2 py-1/2 px-1 bg-gray-200 hover:bg-gray-400 dark:bg-gray-700 dark:hover:bg-gray-600 rounded" hx-on:click="this.parentElement.nextElementSibling.classList.toggle('hidden')">{{ i "ellipsis" "w-3 h-3" }}</button> 68 {{ end }} 69 70 - 71 {{ if index $.TagMap $commit.Hash.String }} 72 {{ range $tag := index $.TagMap $commit.Hash.String }} 73 <span class="ml-2 text-xs rounded bg-gray-100 dark:bg-gray-700 text-black dark:text-white font-mono px-2 inline-flex items-center"> ··· 75 </span> 76 {{ end }} 77 {{ end }} 78 - 79 </div> 80 - 81 {{ if gt (len $messageParts) 1 }} 82 <p class="hidden mt-1 text-sm text-gray-600 dark:text-gray-400">{{ nl2br (index $messageParts 1) }}</p> 83 {{ end }} ··· 99 <div class="flex items-center justify-between"> 100 <div class="flex-1"> 101 <div class="inline"> 102 - <a href="/{{ $.RepoInfo.FullName }}/commit/{{ $commit.Hash.String }}" 103 class="inline no-underline hover:underline dark:text-white"> 104 {{ index $messageParts 0 }} 105 </a> 106 {{ if gt (len $messageParts) 1 }} 107 - <button 108 class="py-1/2 px-1 bg-gray-200 hover:bg-gray-400 rounded dark:bg-gray-700 dark:hover:bg-gray-600 ml-2" 109 hx-on:click="this.parentElement.nextElementSibling.classList.toggle('hidden')"> 110 {{ i "ellipsis" "w-3 h-3" }} ··· 126 </p> 127 {{ end }} 128 </div> 129 - <a href="/{{ $.RepoInfo.FullName }}/tree/{{ $commit.Hash.String }}" 130 - class="p-1 mr-1 hover:bg-gray-100 dark:hover:bg-gray-700 rounded" 131 title="Browse repository at this commit"> 132 {{ i "folder-code" "w-4 h-4" }} 133 </a> ··· 137 </div> 138 139 <div class="text-xs mt-2 text-gray-500 dark:text-gray-400 flex items-center"> 140 - {{ $verified := false }} 141 - {{ $verified = index $.VerifiedCommits $commit.Hash.String }} 142 {{ $hashStyle := "text-gray-700 dark:text-gray-300 bg-gray-100 dark:bg-gray-900" }} 143 {{ if $verified }} 144 {{ $hashStyle = "bg-green-100 text-green-800 dark:bg-green-900 dark:text-green-200 px-2 rounded" }}
··· 3 {{ define "extrameta" }} 4 {{ $title := printf "commits &middot; %s" .RepoInfo.FullName }} 5 {{ $url := printf "https://tangled.sh/%s/commits" .RepoInfo.FullName }} 6 + 7 {{ template "repo/fragments/og" (dict "RepoInfo" .RepoInfo "Title" $title "Url" $url) }} 8 {{ end }} 9 10 {{ define "repoContent" }} 11 <section id="commit-table" class="overflow-x-auto"> 12 <h2 class="font-bold text-sm mb-4 uppercase dark:text-white"> 13 + commits 14 </h2> 15 16 <!-- desktop view (hidden on small screens) --> ··· 36 {{ end }} 37 </td> 38 <td class="py-3 align-top font-mono flex items-center"> 39 + {{ $verified := $.VerifiedCommits.IsVerified $commit.Hash.String }} 40 {{ $hashStyle := "text-gray-700 dark:text-gray-300 bg-gray-100 dark:bg-gray-900" }} 41 {{ if $verified }} 42 {{ $hashStyle = "bg-green-100 text-green-800 dark:bg-green-900 dark:text-green-200 px-2 rounded" }} ··· 48 {{ end }} 49 </a> 50 <div class="{{ if not $verified }} ml-6 {{ end }}inline-flex"> 51 + <button class="p-1 mx-1 hover:bg-gray-100 dark:hover:bg-gray-700 rounded" 52 title="Copy SHA" 53 onclick="navigator.clipboard.writeText('{{ $commit.Hash.String }}'); this.innerHTML=`{{ i "copy-check" "w-4 h-4" }}`; setTimeout(() => this.innerHTML=`{{ i "copy" "w-4 h-4" }}`, 1500)"> 54 {{ i "copy" "w-4 h-4" }} ··· 62 <div> 63 <div class="flex items-center justify-start"> 64 <a href="/{{ $.RepoInfo.FullName }}/commit/{{ $commit.Hash.String }}" class="dark:text-white no-underline hover:underline">{{ index $messageParts 0 }}</a> 65 + {{ if gt (len $messageParts) 1 }} 66 <button class="ml-2 py-1/2 px-1 bg-gray-200 hover:bg-gray-400 dark:bg-gray-700 dark:hover:bg-gray-600 rounded" hx-on:click="this.parentElement.nextElementSibling.classList.toggle('hidden')">{{ i "ellipsis" "w-3 h-3" }}</button> 67 {{ end }} 68 69 + 70 {{ if index $.TagMap $commit.Hash.String }} 71 {{ range $tag := index $.TagMap $commit.Hash.String }} 72 <span class="ml-2 text-xs rounded bg-gray-100 dark:bg-gray-700 text-black dark:text-white font-mono px-2 inline-flex items-center"> ··· 74 </span> 75 {{ end }} 76 {{ end }} 77 + 78 </div> 79 + 80 {{ if gt (len $messageParts) 1 }} 81 <p class="hidden mt-1 text-sm text-gray-600 dark:text-gray-400">{{ nl2br (index $messageParts 1) }}</p> 82 {{ end }} ··· 98 <div class="flex items-center justify-between"> 99 <div class="flex-1"> 100 <div class="inline"> 101 + <a href="/{{ $.RepoInfo.FullName }}/commit/{{ $commit.Hash.String }}" 102 class="inline no-underline hover:underline dark:text-white"> 103 {{ index $messageParts 0 }} 104 </a> 105 {{ if gt (len $messageParts) 1 }} 106 + <button 107 class="py-1/2 px-1 bg-gray-200 hover:bg-gray-400 rounded dark:bg-gray-700 dark:hover:bg-gray-600 ml-2" 108 hx-on:click="this.parentElement.nextElementSibling.classList.toggle('hidden')"> 109 {{ i "ellipsis" "w-3 h-3" }} ··· 125 </p> 126 {{ end }} 127 </div> 128 + <a href="/{{ $.RepoInfo.FullName }}/tree/{{ $commit.Hash.String }}" 129 + class="p-1 mr-1 hover:bg-gray-100 dark:hover:bg-gray-700 rounded" 130 title="Browse repository at this commit"> 131 {{ i "folder-code" "w-4 h-4" }} 132 </a> ··· 136 </div> 137 138 <div class="text-xs mt-2 text-gray-500 dark:text-gray-400 flex items-center"> 139 + {{ $verified := $.VerifiedCommits.IsVerified $commit.Hash.String }} 140 {{ $hashStyle := "text-gray-700 dark:text-gray-300 bg-gray-100 dark:bg-gray-900" }} 141 {{ if $verified }} 142 {{ $hashStyle = "bg-green-100 text-green-800 dark:bg-green-900 dark:text-green-200 px-2 rounded" }}
+5 -4
appview/repo/repo.go
··· 18 19 "tangled.sh/tangled.sh/core/api/tangled" 20 "tangled.sh/tangled.sh/core/appview" 21 "tangled.sh/tangled.sh/core/appview/config" 22 "tangled.sh/tangled.sh/core/appview/db" 23 "tangled.sh/tangled.sh/core/appview/idresolver" ··· 144 log.Println("failed to get email to did map", err) 145 } 146 147 - vc, err := verifiedObjectCommits(rp, emailToDidMap, commitsTrunc) 148 if err != nil { 149 log.Println(err) 150 } ··· 310 log.Println("failed to fetch email to did mapping", err) 311 } 312 313 - vc, err := verifiedObjectCommits(rp, emailToDidMap, repolog.Commits) 314 if err != nil { 315 log.Println(err) 316 } ··· 466 log.Println("failed to get email to did mapping:", err) 467 } 468 469 - vc, err := verifiedCommits(rp, emailToDidMap, []types.NiceDiff{*result.Diff}) 470 if err != nil { 471 log.Println(err) 472 } ··· 477 RepoInfo: f.RepoInfo(user), 478 RepoCommitResponse: result, 479 EmailToDidOrHandle: emailToDidOrHandle(rp, emailToDidMap), 480 - Verified: vc[result.Diff.Commit.This], 481 }) 482 return 483 }
··· 18 19 "tangled.sh/tangled.sh/core/api/tangled" 20 "tangled.sh/tangled.sh/core/appview" 21 + "tangled.sh/tangled.sh/core/appview/commitverify" 22 "tangled.sh/tangled.sh/core/appview/config" 23 "tangled.sh/tangled.sh/core/appview/db" 24 "tangled.sh/tangled.sh/core/appview/idresolver" ··· 145 log.Println("failed to get email to did map", err) 146 } 147 148 + vc, err := commitverify.GetVerifiedObjectCommits(rp.db, emailToDidMap, commitsTrunc) 149 if err != nil { 150 log.Println(err) 151 } ··· 311 log.Println("failed to fetch email to did mapping", err) 312 } 313 314 + vc, err := commitverify.GetVerifiedObjectCommits(rp.db, emailToDidMap, repolog.Commits) 315 if err != nil { 316 log.Println(err) 317 } ··· 467 log.Println("failed to get email to did mapping:", err) 468 } 469 470 + vc, err := commitverify.GetVerifiedCommits(rp.db, emailToDidMap, []types.NiceDiff{*result.Diff}) 471 if err != nil { 472 log.Println(err) 473 } ··· 478 RepoInfo: f.RepoInfo(user), 479 RepoCommitResponse: result, 480 EmailToDidOrHandle: emailToDidOrHandle(rp, emailToDidMap), 481 + VerifiedCommit: vc, 482 }) 483 return 484 }