]> Sergey Matveev's repositories - sgblog.git/blobdiff - cmd/sgblog/http.go
No new/old terminology
[sgblog.git] / cmd / sgblog / http.go
index 18477a6c53fa6b7c81159a040daae8e067247125..7275c718919c98733f193128998ee3933df14cb8 100644 (file)
@@ -1,5 +1,5 @@
 /*
-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
@@ -15,7 +15,6 @@ You should have received a copy of the GNU Affero General Public License
 along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */
 
-// Git-based CGI blogging engine
 package main
 
 import (
@@ -35,6 +34,7 @@ import (
        "os"
        "strconv"
        "strings"
+       "time"
 
        "github.com/hjson/hjson-go"
        "go.stargrave.org/sgblog"
@@ -293,14 +293,24 @@ func serveHTTP() {
                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{}
@@ -318,11 +328,13 @@ func serveHTTP() {
                                commentsValue = "&nbsp;"
                        }
                        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,
@@ -340,12 +352,12 @@ func serveHTTP() {
                        } 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]"))
                }
 
@@ -458,7 +470,7 @@ func serveHTTP() {
                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 != "" {
@@ -466,10 +478,7 @@ func serveHTTP() {
                }
                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"+