Signed-off-by: oppiliappan me@oppi.li
+14
appview/pages/pages.go
+14
appview/pages/pages.go
···
844
844
return p.executeRepo("repo/tags", w, params)
845
845
}
846
846
847
+
type RepoTagParams struct {
848
+
LoggedInUser *oauth.MultiAccountUser
849
+
RepoInfo repoinfo.RepoInfo
850
+
Active string
851
+
types.RepoTagResponse
852
+
ArtifactMap map[plumbing.Hash][]models.Artifact
853
+
DanglingArtifacts []models.Artifact
854
+
}
855
+
856
+
func (p *Pages) RepoTag(w io.Writer, params RepoTagParams) error {
857
+
params.Active = "overview"
858
+
return p.executeRepo("repo/tag", w, params)
859
+
}
860
+
847
861
type RepoArtifactParams struct {
848
862
LoggedInUser *oauth.MultiAccountUser
849
863
RepoInfo repoinfo.RepoInfo
+3
-2
appview/pages/templates/repo/fragments/artifact.html
+3
-2
appview/pages/templates/repo/fragments/artifact.html
···
19
19
{{ if and .LoggedInUser (eq .LoggedInUser.Did .Artifact.Did) }}
20
20
<button
21
21
id="delete-{{ $unique }}"
22
-
class="btn text-red-500 hover:text-red-700 dark:text-red-400 dark:hover:text-red-300 gap-2"
22
+
class="btn text-red-500 hover:text-red-700 dark:text-red-400 dark:hover:text-red-300 gap-2 group"
23
23
title="Delete artifact"
24
24
hx-delete="/{{ .RepoInfo.FullName }}/tags/{{ .Artifact.Tag.String }}/{{ .Artifact.Name | urlquery }}"
25
25
hx-swap="outerHTML"
26
26
hx-target="#artifact-{{ $unique }}"
27
27
hx-disabled-elt="#delete-{{ $unique }}"
28
28
hx-confirm="Are you sure you want to delete the artifact '{{ .Artifact.Name }}'?">
29
-
{{ i "trash-2" "w-4 h-4" }}
29
+
{{ i "trash-2" "size-4 inline group-[.htmx-request]:hidden" }}
30
+
{{ i "loader-circle" "size-4 animate-spin hidden group-[.htmx-request]:inline" }}
30
31
</button>
31
32
{{ end }}
32
33
</div>
+70
appview/pages/templates/repo/fragments/artifactList.html
+70
appview/pages/templates/repo/fragments/artifactList.html
···
1
+
{{ define "repo/fragments/artifactList" }}
2
+
{{ $root := index . 0 }}
3
+
{{ $tag := index . 1 }}
4
+
{{ $isPushAllowed := $root.RepoInfo.Roles.IsPushAllowed }}
5
+
{{ $artifacts := index $root.ArtifactMap $tag.Tag.Hash }}
6
+
7
+
<h2 class="my-4 text-sm text-left text-gray-700 dark:text-gray-300 uppercase font-bold">artifacts</h2>
8
+
<div class="flex flex-col rounded border border-gray-200 dark:border-gray-700">
9
+
{{ range $artifact := $artifacts }}
10
+
{{ $args := dict "LoggedInUser" $root.LoggedInUser "RepoInfo" $root.RepoInfo "Artifact" $artifact }}
11
+
{{ template "repo/fragments/artifact" $args }}
12
+
{{ end }}
13
+
<div id="artifact-git-source" class="flex items-center justify-between p-2 border-b border-gray-200 dark:border-gray-700">
14
+
<div id="left-side" class="flex items-center gap-2 min-w-0 max-w-[60%]">
15
+
{{ i "archive" "w-4 h-4" }}
16
+
<a href="/{{ $root.RepoInfo.FullName }}/archive/{{ pathEscape (print "refs/tags/" $tag.Name) }}" class="no-underline hover:no-underline">
17
+
Source code (.tar.gz)
18
+
</a>
19
+
</div>
20
+
</div>
21
+
{{ if $isPushAllowed }}
22
+
{{ template "uploadArtifact" (list $root $tag) }}
23
+
{{ end }}
24
+
</div>
25
+
{{ end }}
26
+
27
+
{{ define "uploadArtifact" }}
28
+
{{ $root := index . 0 }}
29
+
{{ $tag := index . 1 }}
30
+
{{ $unique := $tag.Tag.Target.String }}
31
+
<form
32
+
id="upload-{{$unique}}"
33
+
method="post"
34
+
enctype="multipart/form-data"
35
+
hx-post="/{{ $root.RepoInfo.FullName }}/tags/{{ $tag.Name | urlquery }}/upload"
36
+
hx-on::after-request="if(event.detail.successful) this.reset()"
37
+
hx-disabled-elt="#upload-btn-{{$unique}}"
38
+
hx-swap="beforebegin"
39
+
hx-target="#artifact-git-source"
40
+
class="flex items-center gap-2 px-2 group">
41
+
<div class="flex-grow">
42
+
<input type="file"
43
+
name="artifact"
44
+
required
45
+
class="block py-2 px-0 w-full border-none
46
+
text-black dark:text-white
47
+
bg-white dark:bg-gray-800
48
+
file:mr-4 file:px-2 file:py-2
49
+
file:rounded file:border-0
50
+
file:text-sm file:font-medium
51
+
file:text-gray-700 file:dark:text-gray-300
52
+
file:bg-gray-200 file:dark:bg-gray-700
53
+
file:hover:bg-gray-100 file:hover:dark:bg-gray-600
54
+
">
55
+
</input>
56
+
</div>
57
+
<div class="flex justify-end">
58
+
<button
59
+
type="submit"
60
+
class="btn-create gap-2"
61
+
id="upload-btn-{{$unique}}"
62
+
title="Upload artifact">
63
+
{{ i "upload" "size-4 inline group-[.htmx-request]:hidden" }}
64
+
{{ i "loader-circle" "size-4 animate-spin hidden group-[.htmx-request]:inline" }}
65
+
<span class="hidden md:inline">upload</span>
66
+
</button>
67
+
</div>
68
+
</form>
69
+
{{ end }}
70
+
+67
appview/pages/templates/repo/fragments/singleTag.html
+67
appview/pages/templates/repo/fragments/singleTag.html
···
1
+
{{ define "repo/fragments/singleTag" }}
2
+
{{ $root := index . 0 }}
3
+
{{ $item := index . 1 }}
4
+
{{ with $item }}
5
+
<div class="md:grid md:grid-cols-12 md:items-start flex flex-col">
6
+
<!-- Header column (top on mobile, left on md+) -->
7
+
<div class="md:col-span-2 md:border-r border-b md:border-b-0 border-gray-200 dark:border-gray-700 w-full md:h-full">
8
+
<!-- Mobile layout: horizontal -->
9
+
<div class="flex md:hidden flex-col py-2 px-2 text-xl">
10
+
<a href="/{{ $root.RepoInfo.FullName }}/tags/{{ .Name | urlquery }}" class="no-underline hover:underline flex items-center gap-2 font-bold">
11
+
{{ i "tag" "w-4 h-4" }}
12
+
{{ .Name }}
13
+
</a>
14
+
15
+
<div class="flex items-center gap-3 text-gray-500 dark:text-gray-400 text-sm">
16
+
{{ if .Tag }}
17
+
<a href="/{{ $root.RepoInfo.FullName }}/commit/{{ .Tag.Target.String }}"
18
+
class="no-underline hover:underline text-gray-500 dark:text-gray-400">
19
+
{{ slice .Tag.Target.String 0 8 }}
20
+
</a>
21
+
22
+
<span class="px-1 text-gray-500 dark:text-gray-400 select-none after:content-['路']"></span>
23
+
<span>{{ .Tag.Tagger.Name }}</span>
24
+
25
+
<span class="px-1 text-gray-500 dark:text-gray-400 select-none after:content-['路']"></span>
26
+
{{ template "repo/fragments/shortTime" .Tag.Tagger.When }}
27
+
{{ end }}
28
+
</div>
29
+
</div>
30
+
31
+
<!-- Desktop layout: vertical and left-aligned -->
32
+
<div class="hidden md:block text-left px-2 pb-6">
33
+
<a href="/{{ $root.RepoInfo.FullName }}/tags/{{ .Name | urlquery }}" class="no-underline hover:underline flex items-center gap-2 font-bold">
34
+
{{ i "tag" "w-4 h-4" }}
35
+
{{ .Name }}
36
+
</a>
37
+
<div class="flex flex-grow flex-col text-gray-500 dark:text-gray-400 text-sm">
38
+
{{ if .Tag }}
39
+
<a href="/{{ $root.RepoInfo.FullName }}/commit/{{ .Tag.Target.String }}"
40
+
class="no-underline hover:underline text-gray-500 dark:text-gray-400 flex items-center gap-2">
41
+
{{ i "git-commit-horizontal" "w-4 h-4" }}
42
+
{{ slice .Tag.Target.String 0 8 }}
43
+
</a>
44
+
<span>{{ .Tag.Tagger.Name }}</span>
45
+
{{ template "repo/fragments/time" .Tag.Tagger.When }}
46
+
{{ end }}
47
+
</div>
48
+
</div>
49
+
</div>
50
+
51
+
<!-- Content column (bottom on mobile, right on md+) -->
52
+
<div class="md:col-span-10 px-2 py-3 md:py-0 md:pb-6">
53
+
{{ if .Tag }}
54
+
{{ $messageParts := splitN .Tag.Message "\n\n" 2 }}
55
+
<p class="font-bold text-lg">{{ index $messageParts 0 }}</p>
56
+
{{ if gt (len $messageParts) 1 }}
57
+
<p class="cursor-text py-2">{{ nl2br (index $messageParts 1) }}</p>
58
+
{{ end }}
59
+
{{ template "repo/fragments/artifactList" (list $root .) }}
60
+
{{ else }}
61
+
<p class="italic text-gray-500 dark:text-gray-400">no message</p>
62
+
{{ end }}
63
+
</div>
64
+
</div>
65
+
{{ end }}
66
+
{{ end }}
67
+
+1
-1
appview/pages/templates/repo/index.html
+1
-1
appview/pages/templates/repo/index.html
···
334
334
{{ with $tag }}
335
335
<div>
336
336
<div class="text-base flex items-center gap-2">
337
-
<a href="/{{ $.RepoInfo.FullName }}/tree/{{ .Reference.Name | urlquery }}"
337
+
<a href="/{{ $.RepoInfo.FullName }}/tags/{{ .Reference.Name | urlquery }}"
338
338
class="inline no-underline hover:underline dark:text-white">
339
339
{{ .Reference.Name }}
340
340
</a>
+16
appview/pages/templates/repo/tag.html
+16
appview/pages/templates/repo/tag.html
···
1
+
{{ define "title" }}
2
+
tags 路 {{ .RepoInfo.FullName }}
3
+
{{ end }}
4
+
5
+
{{ define "extrameta" }}
6
+
{{ $title := printf "tags · %s" .RepoInfo.FullName }}
7
+
{{ $url := printf "https://tangled.org/%s/tag/%s" .RepoInfo.FullName .Tag.Name }}
8
+
9
+
{{ template "repo/fragments/og" (dict "RepoInfo" .RepoInfo "Title" $title "Url" $url) }}
10
+
{{ end }}
11
+
12
+
{{ define "repoContent" }}
13
+
<section class="flex flex-col py-2 gap-12 md:gap-0">
14
+
{{ template "repo/fragments/singleTag" (list $ .Tag ) }}
15
+
</section>
16
+
{{ end }}
History
1 round
0 comments
oppi.li
submitted
#0
1 commit
expand
collapse
appview/repo: add route to /tag/{name} to view a single tag
Signed-off-by: oppiliappan <me@oppi.li>
2/3 timeout, 1/3 success
expand
collapse
expand 0 comments
pull request successfully merged