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(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()))), ) }), ), }), ), ), }) }