]> Sergey Matveev's repositories - sgblog.git/blobdiff - cmd/sgblog/http.go
URLize feed entry, not just escape it
[sgblog.git] / cmd / sgblog / http.go
index 4712a50f13584b98a81542a1d71cdd69c44307df..11dd51566c18b3b81480b8bf8b760ad9e8325d0a 100644 (file)
@@ -142,7 +142,7 @@ Topics: {{range .Topics}}[<tt><a href="{{$Cfg.URLPrefix}}?topic={{.}}">{{.}}</a>
 {{end}}</pre>
 <hr/>{{end}}
 
-{{if .Cfg.CommentsEmail}}[<a href="mailto:{{.Cfg.CommentsEmail}}?subject=Re:%20{{.TitleEscaped}}%20({{.Commit.Hash.String}})">leave comment</a>]{{end}}
+{{if .Cfg.CommentsEmail}}[<a href="mailto:{{.Cfg.CommentsEmail}}?subject={{.TitleEscaped}}">leave comment</a>]{{end}}
 
 <dl>{{range $idx, $comment := .Comments}}
 <dt><a name="comment{{$idx}}"><a href="#comment{{$idx}}">comment {{$idx}}</a>:</dt>
@@ -550,6 +550,12 @@ func serveHTTP() {
                        for _, topic := range parseTopics(getNote(topicsTree, commit.Hash)) {
                                categories = append(categories, atom.Category{Term: topic})
                        }
+                       htmlized := make([]string, 0, len(lines))
+                       htmlized = append(htmlized, "<pre>")
+                       for _, l := range lines[2:] {
+                               htmlized = append(htmlized, lineURLize(cfg.AtomBaseURL+cfg.URLPrefix, l))
+                       }
+                       htmlized = append(htmlized, "</pre>")
                        feed.Entry = append(feed.Entry, &atom.Entry{
                                Title: lines[0],
                                ID:    "urn:uuid:" + bytes2uuid(commit.Hash[:]),
@@ -561,8 +567,8 @@ func serveHTTP() {
                                Updated:   atom.Time(commit.Author.When),
                                Summary:   &atom.Text{Type: "text", Body: lines[0]},
                                Content: &atom.Text{
-                                       Type: "text",
-                                       Body: strings.Join(lines[2:], "\n"),
+                                       Type: "html",
+                                       Body: strings.Join(htmlized, "\n"),
                                },
                                Category: categories,
                        })
@@ -798,7 +804,7 @@ func serveHTTP() {
                        Version:         sgblog.Version,
                        Cfg:             cfg,
                        Title:           title,
-                       TitleEscaped:    strings.ReplaceAll(title, " ", "%20"),
+                       TitleEscaped:    url.PathEscape(fmt.Sprintf("Re: %s (%s)", title, commit.Hash)),
                        When:            when,
                        AtomCommentsURL: atomCommentsURL,
                        Parent:          parent,