]> Sergey Matveev's repositories - sgblog.git/blobdiff - cmd/sgblog/gopher.go
Title in phlog's comment links
[sgblog.git] / cmd / sgblog / gopher.go
index 86fb5692d81ea055c8b16cf98aac7979007c267e..183914c8c582399b621c2506e5c01c42eb836b2c 100644 (file)
@@ -1,6 +1,6 @@
 /*
 SGBlog -- Git-backed CGI/inetd blogging/phlogging engine
-Copyright (C) 2020 Sergey Matveev <stargrave@stargrave.org>
+Copyright (C) 2020-2021 Sergey Matveev <stargrave@stargrave.org>
 
 This program is free software: you can redistribute it and/or modify
 it under the terms of the GNU Affero General Public License as
@@ -25,6 +25,7 @@ import (
        "io"
        "io/ioutil"
        "log"
+       "net/url"
        "os"
        "strconv"
        "strings"
@@ -66,7 +67,7 @@ Note:
 {{.Note}}{{end -}}
 {{- if .Cfg.CommentsEmail}}
 ------------------------------------------------------------------------
-leave comment: mailto:{{.Cfg.CommentsEmail}}?subject={{.Commit.Hash.String}}
+leave comment: mailto:{{.Cfg.CommentsEmail}}?subject={{.TitleEscaped}}
 {{end}}{{range $idx, $comment := .Comments}}
 ------------------------------------------------------------------------
 comment {{$idx}}:
@@ -140,13 +141,14 @@ Redirecting to <a href="%s">%s</a>...
                }
                tmpl := template.Must(template.New("entry").Parse(TmplGopherEntry))
                err = tmpl.Execute(os.Stdout, struct {
-                       Commit   *object.Commit
-                       When     string
-                       Cfg      *Cfg
-                       Note     string
-                       Comments []string
-                       Topics   []string
-                       Version  string
+                       Commit       *object.Commit
+                       When         string
+                       Cfg          *Cfg
+                       Note         string
+                       Comments     []string
+                       Topics       []string
+                       Version      string
+                       TitleEscaped string
                }{
                        Commit:   commit,
                        When:     commit.Author.When.Format(sgblog.WhenFmt),
@@ -155,6 +157,9 @@ Redirecting to <a href="%s">%s</a>...
                        Comments: parseComments(getNote(commentsTree, commit.Hash)),
                        Topics:   parseTopics(getNote(topicsTree, commit.Hash)),
                        Version:  sgblog.Version,
+                       TitleEscaped: url.PathEscape(fmt.Sprintf(
+                               "Re: %s (%s)", msgSplit(commit.Message)[0], commit.Hash,
+                       )),
                })
                if err != nil {
                        log.Fatalln(err)