]> Sergey Matveev's repositories - sgblog.git/blobdiff - cmd/sgblog/main.go
Configurable comments commits author
[sgblog.git] / cmd / sgblog / main.go
index 5ee199e331a0720b2a92fb9a79b896fd878c0d0e..2173580bc2ebdc2bad162d61614c5edd1b5c5c75 100644 (file)
@@ -39,6 +39,7 @@ import (
 
        "github.com/hjson/hjson-go"
        "go.cypherpunks.ru/netstring/v2"
+       "go.stargrave.org/sgblog"
        "golang.org/x/crypto/blake2b"
        "golang.org/x/tools/blog/atom"
        "gopkg.in/src-d/go-git.v4"
@@ -48,12 +49,10 @@ import (
 
 const (
        PageEntries = 50
-       WhenFmt     = "2006-01-02 15:04:05Z07:00"
        AtomFeed    = "feed.atom"
 )
 
 var (
-       Version      = "0.2.0"
        sha1DigestRe = regexp.MustCompilePOSIX("([0-9a-f]{40,40})")
        defaultLinks = []string{}
        repo         *git.Repository
@@ -204,7 +203,7 @@ func startHTML(title string, additional []string) string {
 </head>
 <body>
 `,
-               Version, title,
+               sgblog.Version, title,
                strings.Join(append(defaultLinks, additional...), "\n   "),
        )
 }
@@ -259,6 +258,7 @@ func main() {
                panic(err)
        }
        etagHash.Write([]byte("SGBLOG"))
+       etagHash.Write([]byte(sgblog.Version))
        etagHash.Write([]byte(cfg.GitPath))
        etagHash.Write([]byte(cfg.Branch))
        etagHash.Write([]byte(cfg.Title))
@@ -409,7 +409,7 @@ func main() {
                                        "<td>%s</td>"+
                                        "<td>%d</td><td>%s</td>"+
                                        "<td>%s</td></tr>\n",
-                               commentN, entry.commit.Author.When.Format(WhenFmt),
+                               commentN, entry.commit.Author.When.Format(sgblog.WhenFmt),
                                makeA(cfg.URLPrefix+"/"+entry.commit.Hash.String(), lines[0]),
                                len(lines)-2,
                                commentsValue,
@@ -539,7 +539,7 @@ func main() {
                checkETag(etagHash)
                lines := msgSplit(commit.Message)
                title := lines[0]
-               when := commit.Author.When.Format(WhenFmt)
+               when := commit.Author.When.Format(sgblog.WhenFmt)
                os.Stdout.Write([]byte(startHeader(etagHash, gzipWriter != nil)))
                links := []string{}
                var parent string