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: repo: show ssh fingerprint info on hover

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

authored by

Anirudh Oppiliappan and committed by
Tangled
c0660c1f c3c81fda

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