mirror of https://github.com/jlelse/GoBlog
Add email option to feeds
This commit is contained in:
parent
78f3d3c07b
commit
9efa26a96d
|
@ -135,6 +135,7 @@ type configUser struct {
|
||||||
Password string `mapstructure:"password"`
|
Password string `mapstructure:"password"`
|
||||||
Picture string `mapstructure:"picture"`
|
Picture string `mapstructure:"picture"`
|
||||||
Emoji string `mapstructure:"emoji"`
|
Emoji string `mapstructure:"emoji"`
|
||||||
|
Email string `mapstructure:"email"`
|
||||||
Link string `mapstructure:"link"`
|
Link string `mapstructure:"link"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
18
feeds.go
18
feeds.go
|
@ -36,7 +36,8 @@ func generateFeed(blog string, f feedType, w http.ResponseWriter, r *http.Reques
|
||||||
Link: &feeds.Link{Href: appConfig.Server.PublicAddress + strings.TrimSuffix(r.URL.Path, "."+string(f))},
|
Link: &feeds.Link{Href: appConfig.Server.PublicAddress + strings.TrimSuffix(r.URL.Path, "."+string(f))},
|
||||||
Created: now,
|
Created: now,
|
||||||
Author: &feeds.Author{
|
Author: &feeds.Author{
|
||||||
Name: appConfig.User.Name,
|
Name: appConfig.User.Name,
|
||||||
|
Email: appConfig.User.Email,
|
||||||
},
|
},
|
||||||
Image: &feeds.Image{
|
Image: &feeds.Image{
|
||||||
Url: appConfig.User.Picture,
|
Url: appConfig.User.Picture,
|
||||||
|
@ -64,18 +65,17 @@ func generateFeed(blog string, f feedType, w http.ResponseWriter, r *http.Reques
|
||||||
Enclosure: enc,
|
Enclosure: enc,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
var feedStr string
|
|
||||||
var err error
|
var err error
|
||||||
switch f {
|
switch f {
|
||||||
case rssFeed:
|
case rssFeed:
|
||||||
w.Header().Add(contentType, "application/rss+xml; charset=utf-8")
|
w.Header().Set(contentType, "application/rss+xml; charset=utf-8")
|
||||||
feedStr, err = feed.ToRss()
|
err = feed.WriteRss(w)
|
||||||
case atomFeed:
|
case atomFeed:
|
||||||
w.Header().Add(contentType, "application/atom+xml; charset=utf-8")
|
w.Header().Set(contentType, "application/atom+xml; charset=utf-8")
|
||||||
feedStr, err = feed.ToAtom()
|
err = feed.WriteAtom(w)
|
||||||
case jsonFeed:
|
case jsonFeed:
|
||||||
w.Header().Add(contentType, "application/feed+json; charset=utf-8")
|
w.Header().Set(contentType, "application/feed+json; charset=utf-8")
|
||||||
feedStr, err = feed.ToJSON()
|
err = feed.WriteJSON(w)
|
||||||
default:
|
default:
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
@ -84,6 +84,4 @@ func generateFeed(blog string, f feedType, w http.ResponseWriter, r *http.Reques
|
||||||
serveError(w, r, err.Error(), http.StatusInternalServerError)
|
serveError(w, r, err.Error(), http.StatusInternalServerError)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
w.WriteHeader(http.StatusOK)
|
|
||||||
_, _ = w.Write([]byte(feedStr))
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue