From 3d20b3e77a26b78a1a208b6d3fd8ce1ba64d19f7 Mon Sep 17 00:00:00 2001 From: bouncepaw Date: Sun, 29 Nov 2020 22:06:45 +0500 Subject: [PATCH] Make history page easier to use --- history/information.go | 68 +++++++++-- http_readers.go | 8 +- templates/asset.qtpl.go | 9 +- templates/default.css | 9 +- templates/http_readers.qtpl | 18 +-- templates/http_readers.qtpl.go | 212 ++++++++++++++++----------------- 6 files changed, 184 insertions(+), 140 deletions(-) diff --git a/history/information.go b/history/information.go index bc65cac..80d5b5d 100644 --- a/history/information.go +++ b/history/information.go @@ -7,8 +7,10 @@ import ( "regexp" "strconv" "strings" + "time" "github.com/bouncepaw/mycorrhiza/templates" + "github.com/bouncepaw/mycorrhiza/util" ) func RecentChanges(n int) string { @@ -37,8 +39,8 @@ func Revisions(hyphaName string) ([]Revision, error) { var ( out, err = gitsh( "log", "--oneline", "--no-merges", - // Hash, Commiter email, Commiter time, Commit msg separated by tab - "--pretty=format:\"%h\t%ce\t%ct\t%s\"", + // Hash, author email, author time, commit msg separated by tab + "--pretty=format:\"%h\t%ae\t%at\t%s\"", "--", hyphaName+".*", ) revs []Revision @@ -53,6 +55,58 @@ func Revisions(hyphaName string) ([]Revision, error) { return revs, err } +// HistoryWithRevisions returns an html representation of `revs` that is meant to be inserted in a history page. +func HistoryWithRevisions(hyphaName string, revs []Revision) (html string) { + var ( + currentYear int + currentMonth time.Month + ) + for i, rev := range revs { + if rev.Time.Month() != currentMonth || rev.Time.Year() != currentYear { + currentYear = rev.Time.Year() + currentMonth = rev.Time.Month() + if i != 0 { + html += ` + +` + } + html += fmt.Sprintf(` +
+ +

%[3]s

+
+