all repos — elgit @ 74eea2ebbccc8458b5b62002d281b2b49f5c30c4

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

switch to gomponents

Alan Pearce
commit

74eea2ebbccc8458b5b62002d281b2b49f5c30c4

parent

776a7b0dafa651c5ba71381608e9726d9756c3b1

1 file changed, 52 insertions(+), 0 deletions(-)

changed files
A templates/repo.go
@@ -0,0 +1,52 @@
+package templates + +import ( + "fmt" + + "github.com/go-git/go-git/v5/plumbing/object" + g "go.alanpearce.eu/gomponents" + . "go.alanpearce.eu/gomponents/html" +) + +// Repo renders the repository summary page +func Repo(data PageData, commits []*object.Commit, readme string) g.Node { + return Page(data, []g.Node{ + RepoHeader(data), + RenderNav(data), + Main( + Div(Class("log"), + g.Map(commits, func(commit *object.Commit) 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]), + ), + ), + Pre(g.Text(commit.Message)), + ), + Div(Class("commit-info"), + g.Text(commit.Author.Name), + g.Text(" "), + 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"))), + ), + } + }), + ), + g.If(readme != "", + Article(Class("readme"), g.Raw(readme)), + ), + Div(Class("clone-url"), + Strong(g.Text("clone")), + Pre(g.Text(fmt.Sprintf("git clone https://%s/%s", data.Servername, data.Name))), + ), + ), + }) +}