tangled
alpha
login
or
join now
veryroundbird.house
/
core
forked from
tangled.org/core
0
fork
atom
this repo has no description
0
fork
atom
overview
issues
pulls
pipelines
appview: pages: show tags against commits
anirudh.fi
10 months ago
f5f258b2
2f49ac9b
verified
This commit was signed with the committer's
known signature
.
anirudh.fi
SSH Key Fingerprint:
SHA256:cz35vdbiWEzCNEfuL9fMC2JVIhtXavXBHrRjv8gxpAk=
+73
-22
4 changed files
expand all
collapse all
unified
split
appview
pages
pages.go
templates
repo
index.html
log.html
state
repo.go
+1
appview/pages/pages.go
···
499
499
type RepoLogParams struct {
500
500
LoggedInUser *auth.User
501
501
RepoInfo RepoInfo
502
502
+
TagMap map[string][]string
502
503
types.RepoLogResponse
503
504
Active string
504
505
EmailToDidOrHandle map[string]string
+5
-6
appview/pages/templates/repo/index.html
···
151
151
<div id="commit-log" class="md:col-span-1 px-2 pb-4">
152
152
<div class="flex justify-between items-center">
153
153
<a href="/{{ .RepoInfo.FullName }}/commits/{{ .Ref | urlquery }}" class="flex text-black dark:text-white items-center gap-4 pb-2 no-underline hover:no-underline group">
154
154
-
<div class="flex gap-2 items-center">
155
155
-
{{ i "git-commit-horizontal" "w-4 h-4" }} commits
154
154
+
<div class="flex gap-2 items-center font-bold">
155
155
+
{{ i "logs" "w-4 h-4" }} commits
156
156
</div>
157
157
<span class="hidden group-hover:flex gap-2 items-center text-sm text-gray-500 dark:text-gray-400 ">
158
158
view {{ .TotalCommits }} commits {{ i "chevron-right" "w-4 h-4" }}
···
248
248
{{ if gt (len .BranchesTrunc) 0 }}
249
249
<div id="branches" class="md:col-span-1 px-2 py-4 border-t border-gray-200 dark:border-gray-700">
250
250
<a href="/{{ .RepoInfo.FullName }}/branches" class="flex text-black dark:text-white items-center gap-4 pb-2 no-underline hover:no-underline group">
251
251
-
<div class="flex gap-2 items-center">
252
252
-
<!-- git-branch icon is seemingly bigger than others at 4x4 -->
253
253
-
{{ i "git-branch" "w-3 h-3" }} branches
251
251
+
<div class="flex gap-2 items-center font-bold">
252
252
+
{{ i "git-branch" "w-4 h-4" }} branches
254
253
</div>
255
254
<span class="hidden group-hover:flex gap-2 items-center text-sm text-gray-500 dark:text-gray-400 ">
256
255
view {{ len .Branches }} branches {{ i "chevron-right" "w-4 h-4" }}
···
283
282
<div id="tags" class="md:col-span-1 px-2 py-4 border-t border-gray-200 dark:border-gray-700">
284
283
<div class="flex justify-between items-center">
285
284
<a href="/{{ .RepoInfo.FullName }}/tags" class="flex text-black dark:text-white items-center gap-4 pb-2 no-underline hover:no-underline group">
286
286
-
<div class="flex gap-2 items-center">
285
285
+
<div class="flex gap-2 items-center font-bold">
287
286
{{ i "tags" "w-4 h-4" }} tags
288
287
</div>
289
288
<span class="hidden group-hover:flex gap-2 items-center text-sm text-gray-500 dark:text-gray-400 ">
+41
-16
appview/pages/templates/repo/log.html
···
43
43
</td>
44
44
<td class=" py-3 align-top">
45
45
<div>
46
46
-
<a href="/{{ $.RepoInfo.FullName }}/commit/{{ $commit.Hash.String }}" class="dark:text-white no-underline hover:underline">{{ index $messageParts 0 }}</a>
47
47
-
{{ if gt (len $messageParts) 1 }}
48
48
-
<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.nextElementSibling.classList.toggle('hidden')">{{ i "ellipsis" "w-3 h-3" }}</button>
46
46
+
<div class="flex items-center justify-start">
47
47
+
<a href="/{{ $.RepoInfo.FullName }}/commit/{{ $commit.Hash.String }}" class="dark:text-white no-underline hover:underline">{{ index $messageParts 0 }}</a>
48
48
+
{{ if gt (len $messageParts) 1 }}
49
49
+
<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>
50
50
+
{{ end }}
51
51
+
52
52
+
53
53
+
{{ if index $.TagMap $commit.Hash.String }}
54
54
+
{{ range $tag := index $.TagMap $commit.Hash.String }}
55
55
+
<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">
56
56
+
{{ $tag }}
57
57
+
</span>
58
58
+
{{ end }}
59
59
+
{{ end }}
60
60
+
61
61
+
</div>
62
62
+
63
63
+
{{ if gt (len $messageParts) 1 }}
49
64
<p class="hidden mt-1 text-sm text-gray-600 dark:text-gray-400">{{ nl2br (index $messageParts 1) }}</p>
50
65
{{ end }}
51
51
-
</div>
52
66
</td>
53
67
<td class=" py-3 align-top text-gray-500 dark:text-gray-400">{{ timeFmt $commit.Author.When }}</td>
54
68
</tr>
55
55
-
{{ end }}
69
69
+
{{ end }}
56
70
</tbody>
57
71
</table>
58
72
···
66
80
<div>
67
81
<div class="flex items-center justify-between">
68
82
<div class="flex-1">
69
69
-
<a href="/{{ $.RepoInfo.FullName }}/commit/{{ $commit.Hash.String }}"
70
70
-
class="inline no-underline hover:underline dark:text-white">
71
71
-
{{ index $messageParts 0 }}
72
72
-
</a>
73
73
-
{{ if gt (len $messageParts) 1 }}
74
74
-
<button
75
75
-
class="py-1/2 px-1 bg-gray-200 hover:bg-gray-400 rounded dark:bg-gray-700 dark:hover:bg-gray-600"
76
76
-
hx-on:click="this.nextElementSibling.classList.toggle('hidden')">
77
77
-
{{ i "ellipsis" "w-3 h-3" }}
78
78
-
</button>
79
79
-
{{ end }}
83
83
+
<div class="flex items-center">
84
84
+
<a href="/{{ $.RepoInfo.FullName }}/commit/{{ $commit.Hash.String }}"
85
85
+
class="inline no-underline hover:underline dark:text-white">
86
86
+
{{ index $messageParts 0 }}
87
87
+
</a>
88
88
+
{{ if gt (len $messageParts) 1 }}
89
89
+
<button
90
90
+
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"
91
91
+
hx-on:click="this.parentElement.nextElementSibling.classList.toggle('hidden')">
92
92
+
{{ i "ellipsis" "w-3 h-3" }}
93
93
+
</button>
94
94
+
{{ end }}
95
95
+
96
96
+
{{ if index $.TagMap $commit.Hash.String }}
97
97
+
{{ range $tag := index $.TagMap $commit.Hash.String }}
98
98
+
<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">
99
99
+
{{ $tag }}
100
100
+
</span>
101
101
+
{{ end }}
102
102
+
{{ end }}
103
103
+
</div>
104
104
+
80
105
{{ if gt (len $messageParts) 1 }}
81
106
<p class="hidden mt-1 text-sm cursor-text pb-2 dark:text-gray-300">
82
107
{{ nl2br (index $messageParts 1) }}
+26
appview/state/repo.go
···
167
167
return
168
168
}
169
169
170
170
+
resp, err = us.Tags(f.OwnerDid(), f.RepoName)
171
171
+
if err != nil {
172
172
+
log.Println("failed to reach knotserver", err)
173
173
+
return
174
174
+
}
175
175
+
176
176
+
body, err = io.ReadAll(resp.Body)
177
177
+
if err != nil {
178
178
+
log.Printf("error reading response body: %v", err)
179
179
+
return
180
180
+
}
181
181
+
182
182
+
var result types.RepoTagsResponse
183
183
+
err = json.Unmarshal(body, &result)
184
184
+
if err != nil {
185
185
+
log.Printf("Error unmarshalling response body: %v", err)
186
186
+
return
187
187
+
}
188
188
+
189
189
+
tagMap := make(map[string][]string)
190
190
+
for _, tag := range result.Tags {
191
191
+
hash := tag.Hash
192
192
+
tagMap[hash] = append(tagMap[hash], tag.Name)
193
193
+
}
194
194
+
170
195
user := s.auth.GetUser(r)
171
196
s.pages.RepoLog(w, pages.RepoLogParams{
172
197
LoggedInUser: user,
198
198
+
TagMap: tagMap,
173
199
RepoInfo: f.RepoInfo(s, user),
174
200
RepoLogResponse: repolog,
175
201
EmailToDidOrHandle: EmailToDidOrHandle(s, uniqueEmails(repolog.Commits)),