cmd/sgblog/gopher.go | 18 +++++++++++++++--- cmd/sgblog/http.go | 18 ++++++++++++++++-- common.go | 2 +- diff --git a/cmd/sgblog/gopher.go b/cmd/sgblog/gopher.go index a2e0be51a11b42ceec0d32d45f934f41eab6ab299c98b6c92c999eb6c5b70daf..47fc4eb632dc0e7b35a85debe2f9880f32d7771bdf2b607b84549e311a44e7ab 100644 --- a/cmd/sgblog/gopher.go +++ b/cmd/sgblog/gopher.go @@ -30,6 +30,7 @@ "log" "os" "strconv" "strings" + "time" "github.com/hjson/hjson-go" "go.stargrave.org/sgblog" @@ -95,22 +96,33 @@ } logEnded := false var menu bytes.Buffer + var yearPrev int + var monthPrev time.Month + var dayPrev int for i := 0; i < PageEntries; i++ { commit, err := repoLog.Next() if err != nil { logEnded = true break } + yearCur, monthCur, dayCur := commit.Author.When.Date() + if dayCur != dayPrev || monthCur != monthPrev || yearCur != yearPrev { + menu.WriteString(fmt.Sprintf( + "i%04d-%02d-%02d\t\tnull.host\t1%s", + yearCur, monthCur, dayCur, CRLF, + )) + yearPrev, monthPrev, dayPrev = yearCur, monthCur, dayCur + } commitN++ lines := msgSplit(commit.Message) - var commentsValue string if l := len(parseComments(getNote(commentsTree, commit.Hash))); l > 0 { commentsValue = fmt.Sprintf(" (%dC)", l) } menu.WriteString(fmt.Sprintf( - "0[%s] %s (%dL)%s\t/%s\t%s\t%d%s", - commit.Author.When.Format(sgblog.WhenFmt), + "0[%02d:%02d] %s (%dL)%s\t/%s\t%s\t%d%s", + commit.Author.When.Hour(), + commit.Author.When.Minute(), lines[0], len(lines)-2, commentsValue, diff --git a/cmd/sgblog/http.go b/cmd/sgblog/http.go index a8bc14525cdb902a08f97d303ab007a0ae6d79181698c136764c7892f5998087..4d6b47221a2396682d1eb24e73383994bd1e502d7d5f8b80fbee2f8c825e89b9 100644 --- a/cmd/sgblog/http.go +++ b/cmd/sgblog/http.go @@ -35,6 +35,7 @@ "net/url" "os" "strconv" "strings" + "time" "github.com/hjson/hjson-go" "go.stargrave.org/sgblog" @@ -300,7 +301,18 @@ "Title" + `L` + `C` + "Linked to\n") + var yearPrev int + var monthPrev time.Month + var dayPrev int for _, entry := range entries { + yearCur, monthCur, dayCur := entry.commit.Author.When.Date() + if dayCur != dayPrev || monthCur != monthPrev || yearCur != yearPrev { + table.WriteString(fmt.Sprintf( + "
%04d-%02d-%02d
\n", + yearCur, monthCur, dayCur, + )) + yearPrev, monthPrev, dayPrev = yearCur, monthCur, dayCur + } commitN++ lines := msgSplit(entry.commit.Message) domains := []string{} @@ -318,11 +330,13 @@ } else { commentsValue = " " } table.WriteString(fmt.Sprintf( - "%d%s"+ + "%d%02d:%02d"+ "%s"+ "%d%s"+ "%s\n", - commitN, entry.commit.Author.When.Format(sgblog.WhenFmt), + commitN, + entry.commit.Author.When.Hour(), + entry.commit.Author.When.Minute(), makeA(cfg.URLPrefix+"/"+entry.commit.Hash.String(), lines[0]), len(lines)-2, commentsValue, diff --git a/common.go b/common.go index 9bf0d73a787e92f741ca0e0a0eb04328a3bf44402005110a20828c79ebeab6f1..4c68325391df2dc65c5b65c87fc35716fcd4a1ee0b8c6927cb90ead8f17e8620 100644 --- a/common.go +++ b/common.go @@ -2,6 +2,6 @@ // SGBlog -- Git-based CGI blogging engine package sgblog const ( + Version = "0.4.0" WhenFmt = "2006-01-02 15:04:05Z07:00" - Version = "0.3.5" )