/*
-SGBlog -- Git-based CGI blogging engine
+SGBlog -- Git-based CGI/inetd blogging/phlogging engine
Copyright (C) 2020 Sergey Matveev <stargrave@stargrave.org>
This program is free software: you can redistribute it and/or modify
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-// Git-based CGI blogging engine
package main
import (
"os"
"strconv"
"strings"
+ "time"
"github.com/hjson/hjson-go"
"go.stargrave.org/sgblog"
var table bytes.Buffer
table.WriteString(
"<table border=1>\n" +
- "<caption>Comments</caption>\n<tr>" +
"<th>N</th>" +
"<th>When</th>" +
"<th>Title</th>" +
`<th size="5%"><a title="Lines">L</a></th>` +
`<th size="5%"><a title="Comments">C</a></th>` +
"<th>Linked to</th></tr>\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(
+ "<tr><td colspan=6><center><tt>%04d-%02d-%02d</tt></center></td></tr>\n",
+ yearCur, monthCur, dayCur,
+ ))
+ yearPrev, monthPrev, dayPrev = yearCur, monthCur, dayCur
+ }
commitN++
lines := msgSplit(entry.commit.Message)
domains := []string{}
commentsValue = " "
}
table.WriteString(fmt.Sprintf(
- "<tr><td>%d</td><td><tt>%s</tt></td>"+
+ "<tr><td>%d</td><td><tt>%02d:%02d</tt></td>"+
"<td>%s</td>"+
"<td>%d</td><td>%s</td>"+
"<td>%s</td></tr>\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,
} else {
href = cfg.URLPrefix + "/"
}
- links = append(links, `<link rel="prev" href="`+href+`" title="newer">`)
+ links = append(links, `<link rel="prev" href="`+href+`" title="prev">`)
refs.WriteString("\n" + makeA(href, "[prev]"))
}
if !logEnded {
href = cfg.URLPrefix + "/?offset=" + strconv.Itoa(offset+PageEntries)
- links = append(links, `<link rel="next" href="`+href+`" title="older">`)
+ links = append(links, `<link rel="next" href="`+href+`" title="next">`)
refs.WriteString("\n" + makeA(href, "[next]"))
}
var parent string
if len(commit.ParentHashes) > 0 {
parent = commit.ParentHashes[0].String()
- links = append(links, `<link rel="prev" href="`+cfg.URLPrefix+"/"+parent+`" title="older">`)
+ links = append(links, `<link rel="prev" href="`+cfg.URLPrefix+"/"+parent+`" title="prev">`)
}
out.Write([]byte(startHTML(fmt.Sprintf("%s (%s)", title, when), links)))
if cfg.AboutURL != "" {
}
out.Write([]byte(fmt.Sprintf("[%s]\n", makeA(cfg.URLPrefix+"/", "index"))))
if parent != "" {
- out.Write([]byte(fmt.Sprintf(
- "[%s]\n",
- makeA(cfg.URLPrefix+"/"+parent, "older"),
- )))
+ out.Write([]byte(fmt.Sprintf("[%s]\n", makeA(cfg.URLPrefix+"/"+parent, "prev"))))
}
out.Write([]byte(fmt.Sprintf(
"[<tt><a title=\"When\">%s</a></tt>]\n"+
- "[<tt><a title=\"Hash\">%s</a></tt>]\n"+
+ "[<tt><a title=\"What\">%s</a></tt>]\n"+
"<hr/>\n<h2>%s</h2>\n<pre>\n",
when, commit.Hash.String(), title,
)))
if cfg.CommentsEmail != "" {
out.Write([]byte("[" + makeA(
"mailto:"+cfg.CommentsEmail+"?subject="+commit.Hash.String(),
- "write comment",
+ "leave comment",
) + "]\n"))
}
out.Write([]byte("<dl>\n"))