Home

ugit @main - refs - log -
-
https://git.jolheiser.com/ugit.git
The code powering this h*ckin' site
ugit / internal / html / repo_refs.go
- raw
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
package html

import (
	"fmt"

	"go.jolheiser.com/ugit/internal/git"
	. "maragu.dev/gomponents"
	. "maragu.dev/gomponents/html"
)

type RepoRefsContext struct {
	BaseContext
	RepoHeaderComponentContext
	Branches []string
	Tags     []git.Tag
}

func RepoRefsTemplate(rrc RepoRefsContext) Node {
	return base(rrc.BaseContext, []Node{
		repoHeaderComponent(rrc.RepoHeaderComponentContext),
		If(len(rrc.Branches) > 0, Group([]Node{
			H3(Class("text-text text-lg mt-5"), Text("Branches")),
			Div(Class("text-text grid grid-cols-4 sm:grid-cols-8"),
				Map(rrc.Branches, func(branch string) Node {
					return Group([]Node{
						Div(Class("col-span-2 sm:col-span-1 font-bold"), Text(branch)),
						Div(Class("col-span-2 sm:col-span-7"),
							A(Class("underline decoration-text/50 decoration-dashed hover:decoration-solid"), Href(fmt.Sprintf("/%s/tree/%s/", rrc.RepoHeaderComponentContext.Name, branch)), Text("tree")),
							Text(" "),
							A(Class("underline decoration-text/50 decoration-dashed hover:decoration-solid"), Href(fmt.Sprintf("/%s/log/%s", rrc.RepoHeaderComponentContext.Name, branch)), Text("log")),
						),
					})
				}),
			),
		})),
		If(len(rrc.Tags) > 0, Group([]Node{
			H3(Class("text-text text-lg mt-5"), Text("Tags")),
			Div(Class("text-text grid grid-cols-8"),
				Map(rrc.Tags, func(tag git.Tag) Node {
					return Group([]Node{
						Div(Class("col-span-1 font-bold"), Text(tag.Name)),
						Div(Class("col-span-7"),
							A(Class("underline decoration-text/50 decoration-dashed hover:decoration-solid"), Href(fmt.Sprintf("/%s/tree/%s/", rrc.RepoHeaderComponentContext.Name, tag.Name)), Text("tree")),
							Text(" "),
							A(Class("underline decoration-text/50 decoration-dashed hover:decoration-solid"), Href(fmt.Sprintf("/%s/log/%s", rrc.RepoHeaderComponentContext.Name, tag.Name)), Text("log")),
						),
						If(tag.Signature != "",
							Details(Class("col-span-8 whitespace-pre"),
								Summary(Class("cursor-pointer"), Text("Signature")),
								Code(Text(tag.Signature)),
							),
						),
						If(tag.Annotation != "",
							Div(Class("col-span-8 mb-3"), Text(tag.Annotation)),
						),
					})
				}),
			),
		})),
	}...)
}