templates/log.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 | 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"
)
// Log renders the commit log page
func Log(data PageData, commits []*git.CommitReference) g.Node {
return Page(data, []g.Node{
RepoHeader(data),
RenderNav(data),
Main(
Div(Class("log"),
g.Map(commits, func(commit *git.CommitReference) g.Node {
return g.Group{
Div(
Div(
A(
Href(fmt.Sprintf("/%s/commit/%s", data.Name, commit.Hash.String())),
Class("commit-hash"),
g.Text(commit.Hash.String()[:8]),
),
g.Text(" "),
g.If(
commit.HasReference(),
g.Map(commit.References(), func(ref *plumbing.Reference) g.Node {
return A(
Href(fmt.Sprintf("/%s/tree/%s", data.Name, ref.Name().Short())),
Class("commit-hash"),
g.Text(ref.Name().Short()),
)
}),
),
),
Pre(g.Text(commit.Message)),
),
Div(Class("commit-info"),
g.Text(commit.Author.Name+" "),
A(
Href(fmt.Sprintf("mailto:%s", commit.Author.Email)),
Class("commit-email"),
g.Text(commit.Author.Email),
),
Div(g.Text(commit.Author.When.Format("Mon, 02 Jan 2006 15:04:05 -0700"))),
),
}
}),
),
),
})
}
|