all repos — elgit @ edbc1a7ebeb920119f4c094bde4382bacadf851a

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

wrap dates in <time> tags with datetime attribute

Alan Pearce
commit

edbc1a7ebeb920119f4c094bde4382bacadf851a

parent

5ce8c1235f20ffcf31de84e198b7ccb3c8569c35

2 files changed, 15 insertions(+), 2 deletions(-)

jump to
M templates/commit.gotemplates/commit.go
@@ -2,6 +2,7 @@ package templates
import ( "fmt" + "time" "github.com/bluekeyes/go-gitdiff/gitdiff" "github.com/go-git/go-git/v5/plumbing/object"
@@ -115,7 +116,12 @@ Href(fmt.Sprintf("mailto:%s", author.Email)),
Class("commit-email"), g.Text(author.Email), ), - Div(g.Text(author.When.Format("Mon, 02 Jan 2006 15:04:05 -0700"))), + Div( + Time( + DateTime(author.When.Format(time.RFC3339)), + g.Text(author.When.Format("Mon, 02 Jan 2006 15:04:05 -0700")), + ), + ), ) }
M templates/index.gotemplates/index.go
@@ -1,6 +1,8 @@
package templates import ( + "time" + "github.com/dustin/go-humanize" "go.alanpearce.eu/elgit/data" g "go.alanpearce.eu/gomponents"
@@ -46,6 +48,11 @@ },
A(Href("/"+repo.Slug), g.Text(repo.Name)), ), Div(Class("desc"), g.Text(repo.Description)), - Div(g.Text(humanize.Time(repo.LastCommit))), + Div( + Time( + DateTime(repo.LastCommit.Format(time.RFC3339)), + g.Text(humanize.Time(repo.LastCommit)), + ), + ), } }