From cc110e327d5df988f9a5d94c02af5673e05f9b73 Mon Sep 17 00:00:00 2001 From: Sergey Matveev Date: Sun, 28 Feb 2021 11:54:08 +0300 Subject: [PATCH] Title in phlog's comment links --- cmd/sgblog/gopher.go | 21 +++++++++++++-------- common.go | 2 +- 2 files changed, 14 insertions(+), 9 deletions(-) diff --git a/cmd/sgblog/gopher.go b/cmd/sgblog/gopher.go index ce820d1..183914c 100644 --- a/cmd/sgblog/gopher.go +++ b/cmd/sgblog/gopher.go @@ -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 %s... } 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 %s... 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) diff --git a/common.go b/common.go index 3002596..ea1e7db 100644 --- a/common.go +++ b/common.go @@ -2,6 +2,6 @@ package sgblog const ( - Version = "0.15.0" + Version = "0.16.0" WhenFmt = "2006-01-02 15:04:05Z07:00" ) -- 2.44.0