all repos — elgit @ 9c336ff148d48d09a4f4866798511cdcce50202a

fork of legit: web frontend for git, written in go

templates/refs.go (view 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 templates

import (
	"fmt"

	"github.com/go-git/go-git/v5/plumbing"
	"go.alanpearce.eu/elgit/git"
	g "go.alanpearce.eu/gomponents"
	. "go.alanpearce.eu/gomponents/html"
)

// Refs renders the repository references page
func Refs(data PageData, branches []*plumbing.Reference, tags []*git.TagReference) g.Node {
	return Page(data, []g.Node{
		RepoHeader(data),
		RenderNav(data),
		Main(
			H3(g.Text("branches")),
			Div(Class("refs"),
				g.Map(branches, func(branch *plumbing.Reference) g.Node {
					return Div(
						Strong(g.Text(branch.Name().Short())),
						A(
							Href(fmt.Sprintf("/%s/tree/%s/", data.Name, branch.Name().Short())),
							g.Text("browse"),
						),
						g.Text(" "),
						A(Href(fmt.Sprintf("/%s/log/%s", data.Name, branch.Name().Short())), g.Text("log")),
						g.Text(" "),
						A(
							Href(fmt.Sprintf("/%s/archive/%s.tar.gz", data.Name, branch.Name().Short())),
							g.Text("tar.gz"),
						),
					)
				}),
			),
			g.If(len(tags) > 0,
				g.Group([]g.Node{
					H3(g.Text("tags")),
					Div(Class("refs"),
						g.Map(tags, func(tag *git.TagReference) g.Node {
							return Div(
								Strong(Class("tag-name"), g.Text(tag.Name())),
								A(Href(fmt.Sprintf("/%s/tree/%s/", data.Name, tag.Name())), g.Text("browse")),
								g.Text(" "),
								A(Href(fmt.Sprintf("/%s/log/%s", data.Name, tag.Name())), g.Text("log")),
								g.Text(" "),
								A(
									Href(fmt.Sprintf("/%s/archive/%s.tar.gz", data.Name, tag.Name())),
									g.Text("tar.gz"),
								),
								g.Text(" "),
								g.If(tag.Message() != "", Pre(g.Text(tag.Message()))),
							)
						}),
					),
				}),
			),
		),
	})
}