- commit
- 51d0ef3
- parent
- b4c0f63
- author
- Eric Bower
- date
- 2024-06-25 21:21:00 -0400 EDT
style: tweaks
6 files changed,
+36,
-7
+5,
-0
1@@ -37,6 +37,11 @@ func (be *Backend) KeyForFingerprint(pk ssh.PublicKey) string {
2 return gossh.FingerprintSHA256(pk)
3 }
4
5+func (be *Backend) PubkeyToPublicKey(pubkey string) (ssh.PublicKey, error) {
6+ kk, _, _, _, err := ssh.ParseAuthorizedKey([]byte(pubkey))
7+ return kk, err
8+}
9+
10 func (be *Backend) KeyForKeyText(pk ssh.PublicKey) string {
11 kb := base64.StdEncoding.EncodeToString(pk.Marshal())
12 return fmt.Sprintf("%s %s", pk.Type(), kb)
+4,
-4
1@@ -14,16 +14,16 @@
2 <main class="group">
3 <div class="group">
4 {{range $idx, $val := .Patches}}
5- <div class="box group" id="{{$val.Url}}">
6+ <div class="box{{if $val.Review}}-alert{{end}} group" id="{{$val.Url}}">
7 <div>
8 <h2 class="text-lg m-0 p-0 mb">
9- <code>#{{$idx}}</code>
10- {{if $val.Review}}<code>REVIEW</code>{{end}}
11+ <code>{{$idx}}</code>
12+ {{if $val.Review}}<code class="pill-alert">REVIEW</code>{{end}}
13 <a href="#{{$val.Url}}">{{$val.Title}}</a>
14 </h2>
15
16 <div class="group-h text-sm">
17- <code>{{$val.AuthorName}} <{{$val.AuthorEmail}}></code>
18+ <code class="pill{{if $val.Review}}-alert{{end}}">{{$val.AuthorName}} <{{$val.AuthorEmail}}></code>
19 <date>{{$val.AuthorDate}}</date>
20 </div>
21 </div>
+2,
-2
1@@ -6,9 +6,9 @@
2 </h1>
3
4 <div class="text-sm">
5- <code>{{.Pr.Status}}</code>
6+ {{template "pr-status" .Pr.Status}}
7 <span>opened on <date>{{.Pr.Date}}</date> by</span>
8- <code title="{{.Pr.Pubkey}}">{{.Pr.UserName}}</code>
9+ <code class="{{if .Pr.IsAdmin}}pill-alert{{end}}" title="{{.Pr.Pubkey}}">{{.Pr.UserName}}</code>
10 </div>
11
12 <details>
+4,
-1
1@@ -1,6 +1,9 @@
2 {{define "pr-list-item"}}
3 <div>
4- <div style="margin-bottom: 0.15rem;"><a href="{{.Url}}">{{.Text}}</a> <code>{{.Status}}</code></div>
5+ <div style="margin-bottom: 0.15rem;">
6+ <a href="{{.Url}}">{{.Text}}</a>
7+ {{template "pr-status" .Status}}
8+ </div>
9 <div>
10 <code>#{{.ID}}</code>
11 <span>opened on <date>{{.Date}}</date> by </span>
+11,
-0
1@@ -0,0 +1,11 @@
2+{{define "pr-status"}}
3+ {{if eq . "reviewed"}}
4+ <code class="pill-alert">{{.}}</code>
5+ {{else if eq . "opened"}}
6+ <code class="pill-info">{{.}}</code>
7+ {{else if eq . "accepted"}}
8+ <code class="pill-success">{{.}}</code>
9+ {{else}}
10+ <code>{{.}}</code>
11+ {{end}}
12+{{end}}
M
web.go
+10,
-0
1@@ -71,6 +71,7 @@ func getTemplate(file string) *template.Template {
2 filepath.Join("tmpl", file),
3 filepath.Join("tmpl", "pr-header.html"),
4 filepath.Join("tmpl", "pr-list-item.html"),
5+ filepath.Join("tmpl", "pr-status.html"),
6 filepath.Join("tmpl", "base.html"),
7 ),
8 )
9@@ -237,6 +238,7 @@ func repoDetailHandler(w http.ResponseWriter, r *http.Request) {
10
11 type PrData struct {
12 ID int64
13+ IsAdmin bool
14 Title string
15 Date string
16 UserName string
17@@ -316,6 +318,13 @@ func prDetailHandler(w http.ResponseWriter, r *http.Request) {
18
19 w.Header().Set("content-type", "text/html")
20 tmpl := getTemplate("pr-detail.html")
21+ pk, err := web.Backend.PubkeyToPublicKey(user.Pubkey)
22+ if err != nil {
23+ w.WriteHeader(http.StatusUnprocessableEntity)
24+ return
25+ }
26+ isAdmin := web.Backend.IsAdmin(pk)
27+
28 err = tmpl.Execute(w, PrHeaderData{
29 Page: "pr",
30 Repo: LinkData{
31@@ -326,6 +335,7 @@ func prDetailHandler(w http.ResponseWriter, r *http.Request) {
32 Patches: patchesData,
33 Pr: PrData{
34 ID: pr.ID,
35+ IsAdmin: isAdmin,
36 Title: pr.Name,
37 UserName: user.Name,
38 Pubkey: user.Pubkey,