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>

Changed files
+46 -32
appview
commitverify
pages
repo
-2
appview/commitverify/verify.go
···
package commitverify
import (
-
"fmt"
"log"
"github.com/go-git/go-git/v5/plumbing/object"
···
if err != nil {
log.Println("error computing ssh fingerprint:", err)
}
-
fmt.Println(fp)
vc := verifiedCommit{fingerprint: fp, hash: c.This}
vcs[vc] = struct{}{}
+6 -3
appview/pages/pages.go
···
"path/filepath"
"strings"
+
"tangled.sh/tangled.sh/core/appview/commitverify"
"tangled.sh/tangled.sh/core/appview/config"
"tangled.sh/tangled.sh/core/appview/db"
"tangled.sh/tangled.sh/core/appview/oauth"
···
HTMLReadme template.HTML
Raw bool
EmailToDidOrHandle map[string]string
-
VerifiedCommits map[string]bool
+
VerifiedCommits commitverify.VerifiedCommits
Languages *types.RepoLanguageResponse
types.RepoIndexResponse
}
···
types.RepoLogResponse
Active string
EmailToDidOrHandle map[string]string
-
VerifiedCommits map[string]bool
+
VerifiedCommits commitverify.VerifiedCommits
}
func (p *Pages) RepoLog(w io.Writer, params RepoLogParams) error {
···
RepoInfo repoinfo.RepoInfo
Active string
EmailToDidOrHandle map[string]string
-
Verified bool
+
+
// singular because it's always going to be just one
+
VerifiedCommit commitverify.VerifiedCommits
types.RepoCommitResponse
}
+21 -6
appview/pages/templates/repo/commit.html
···
{{ end }}
</p>
-
{{ if .Verified }}
-
<span class="text-sm bg-green-100 text-green-800 dark:bg-green-900 dark:text-green-200 px-2 py-1 rounded">
-
<div class="flex items-center gap-2">
-
{{ i "shield-check" "w-4 h-4" }}
-
verified
+
{{ if .VerifiedCommit.IsVerified $commit.This }}
+
<div class="group relative inline-block text-sm">
+
<div class="bg-green-100 text-green-800 dark:bg-green-900 dark:text-green-200 px-2 py-1 rounded cursor-pointer">
+
<div class="flex items-center gap-2">
+
{{ i "shield-check" "w-4 h-4" }}
+
verified
+
</div>
+
</div>
+
<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">
+
<div class="mb-1">This commit was signed with the committer's <span class="text-green-600 font-semibold">known signature</span>.</div>
+
<div class="flex items-center gap-2 my-2">
+
{{ i "user" "w-4 h-4" }}
+
<a href="/{{ $didOrHandle }}">{{ $didOrHandle }}</a>
+
</div>
+
<div class="my-1 pt-2 text-xs border-t">
+
<div class="text-gray-600 dark:text-gray-300">SSH Key Fingerprint:</div>
+
<div class="break-all">{{ .VerifiedCommit.Fingerprint $commit.This }}</div>
+
</div>
</div>
-
</span>
+
</div>
{{ end }}
</div>
···
{{end}}
{{ define "repoAfter" }}
+
<div class="-z-[9999]">
{{ template "repo/fragments/diff" (list .RepoInfo.FullName .Diff) }}
+
</div>
{{end}}
+1 -2
appview/pages/templates/repo/index.html
···
</div>
<div class="text-xs mt-2 text-gray-500 dark:text-gray-400 flex items-center">
-
{{ $verified := false }}
-
{{ $verified = index $.VerifiedCommits .Hash.String }}
+
{{ $verified := $.VerifiedCommits.IsVerified .Hash.String }}
{{ $hashStyle := "text-gray-700 dark:text-gray-300 bg-gray-100 dark:bg-gray-900" }}
{{ if $verified }}
{{ $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
···
{{ define "extrameta" }}
{{ $title := printf "commits &middot; %s" .RepoInfo.FullName }}
{{ $url := printf "https://tangled.sh/%s/commits" .RepoInfo.FullName }}
-
+
{{ template "repo/fragments/og" (dict "RepoInfo" .RepoInfo "Title" $title "Url" $url) }}
{{ end }}
{{ define "repoContent" }}
<section id="commit-table" class="overflow-x-auto">
<h2 class="font-bold text-sm mb-4 uppercase dark:text-white">
-
commits
+
commits
</h2>
<!-- desktop view (hidden on small screens) -->
···
{{ end }}
</td>
<td class="py-3 align-top font-mono flex items-center">
-
{{ $verified := false }}
-
{{ $verified = index $.VerifiedCommits $commit.Hash.String }}
+
{{ $verified := $.VerifiedCommits.IsVerified $commit.Hash.String }}
{{ $hashStyle := "text-gray-700 dark:text-gray-300 bg-gray-100 dark:bg-gray-900" }}
{{ if $verified }}
{{ $hashStyle = "bg-green-100 text-green-800 dark:bg-green-900 dark:text-green-200 px-2 rounded" }}
···
{{ end }}
</a>
<div class="{{ if not $verified }} ml-6 {{ end }}inline-flex">
-
<button class="p-1 mx-1 hover:bg-gray-100 dark:hover:bg-gray-700 rounded"
+
<button class="p-1 mx-1 hover:bg-gray-100 dark:hover:bg-gray-700 rounded"
title="Copy SHA"
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)">
{{ i "copy" "w-4 h-4" }}
···
<div>
<div class="flex items-center justify-start">
<a href="/{{ $.RepoInfo.FullName }}/commit/{{ $commit.Hash.String }}" class="dark:text-white no-underline hover:underline">{{ index $messageParts 0 }}</a>
-
{{ if gt (len $messageParts) 1 }}
+
{{ if gt (len $messageParts) 1 }}
<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>
{{ end }}
-
+
{{ if index $.TagMap $commit.Hash.String }}
{{ range $tag := index $.TagMap $commit.Hash.String }}
<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">
···
</span>
{{ end }}
{{ end }}
-
+
</div>
-
+
{{ if gt (len $messageParts) 1 }}
<p class="hidden mt-1 text-sm text-gray-600 dark:text-gray-400">{{ nl2br (index $messageParts 1) }}</p>
{{ end }}
···
<div class="flex items-center justify-between">
<div class="flex-1">
<div class="inline">
-
<a href="/{{ $.RepoInfo.FullName }}/commit/{{ $commit.Hash.String }}"
+
<a href="/{{ $.RepoInfo.FullName }}/commit/{{ $commit.Hash.String }}"
class="inline no-underline hover:underline dark:text-white">
{{ index $messageParts 0 }}
</a>
{{ if gt (len $messageParts) 1 }}
-
<button
+
<button
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"
hx-on:click="this.parentElement.nextElementSibling.classList.toggle('hidden')">
{{ i "ellipsis" "w-3 h-3" }}
···
</p>
{{ end }}
</div>
-
<a href="/{{ $.RepoInfo.FullName }}/tree/{{ $commit.Hash.String }}"
-
class="p-1 mr-1 hover:bg-gray-100 dark:hover:bg-gray-700 rounded"
+
<a href="/{{ $.RepoInfo.FullName }}/tree/{{ $commit.Hash.String }}"
+
class="p-1 mr-1 hover:bg-gray-100 dark:hover:bg-gray-700 rounded"
title="Browse repository at this commit">
{{ i "folder-code" "w-4 h-4" }}
</a>
···
</div>
<div class="text-xs mt-2 text-gray-500 dark:text-gray-400 flex items-center">
-
{{ $verified := false }}
-
{{ $verified = index $.VerifiedCommits $commit.Hash.String }}
+
{{ $verified := $.VerifiedCommits.IsVerified $commit.Hash.String }}
{{ $hashStyle := "text-gray-700 dark:text-gray-300 bg-gray-100 dark:bg-gray-900" }}
{{ if $verified }}
{{ $hashStyle = "bg-green-100 text-green-800 dark:bg-green-900 dark:text-green-200 px-2 rounded" }}
+5 -4
appview/repo/repo.go
···
"tangled.sh/tangled.sh/core/api/tangled"
"tangled.sh/tangled.sh/core/appview"
+
"tangled.sh/tangled.sh/core/appview/commitverify"
"tangled.sh/tangled.sh/core/appview/config"
"tangled.sh/tangled.sh/core/appview/db"
"tangled.sh/tangled.sh/core/appview/idresolver"
···
log.Println("failed to get email to did map", err)
}
-
vc, err := verifiedObjectCommits(rp, emailToDidMap, commitsTrunc)
+
vc, err := commitverify.GetVerifiedObjectCommits(rp.db, emailToDidMap, commitsTrunc)
if err != nil {
log.Println(err)
}
···
log.Println("failed to fetch email to did mapping", err)
}
-
vc, err := verifiedObjectCommits(rp, emailToDidMap, repolog.Commits)
+
vc, err := commitverify.GetVerifiedObjectCommits(rp.db, emailToDidMap, repolog.Commits)
if err != nil {
log.Println(err)
}
···
log.Println("failed to get email to did mapping:", err)
}
-
vc, err := verifiedCommits(rp, emailToDidMap, []types.NiceDiff{*result.Diff})
+
vc, err := commitverify.GetVerifiedCommits(rp.db, emailToDidMap, []types.NiceDiff{*result.Diff})
if err != nil {
log.Println(err)
}
···
RepoInfo: f.RepoInfo(user),
RepoCommitResponse: result,
EmailToDidOrHandle: emailToDidOrHandle(rp, emailToDidMap),
-
Verified: vc[result.Diff.Commit.This],
+
VerifiedCommit: vc,
})
return
}