Add minimal feeds without TTS audio and interactions link (.min.rss, .min.atom and .min.atom) (#23)

pull/31/head
Jan-Lukas Else 2 months ago
parent 38e8ac934f
commit 013bfe84b8
  1. 8
      docs/index.md
  2. 24
      feeds.go
  3. 2
      http.go
  4. 9
      postsFuncs.go
  5. 8
      ui.go

@ -6,9 +6,9 @@ License: MIT License
[Blog](https://goblog.app/)
[Documentation](https://docs.goblog.app)
[Main repository](https://git.jlel.se/jlelse/GoBlog)
[GitHub mirror](https://github.com/jlelse/GoBlog)
[Codeberg mirror](https://codeberg.org/jlelse/GoBlog)
[Main repository](https://github.com/jlelse/GoBlog)
[Mirror](https://git.jlel.se/jlelse/GoBlog)
[Mirror on Codeberg](https://codeberg.org/jlelse/GoBlog)
## Features
@ -33,7 +33,7 @@ Here's an (incomplete) list of features:
- Publish posts to the Fediverse (Mastodon etc.)
- ActivityPub-based commenting
- Web feeds
- Multiple feed formats: RSS, Atom, JSON
- Multiple feed formats (.rss, .atom, .json, .min.rss, .min.atom, .min.json)
- Feeds on any archive page
- Sitemap
- Automatic HTTPS using Let's Encrypt

@ -15,10 +15,13 @@ import (
type feedType string
const (
noFeed feedType = ""
rssFeed feedType = "rss"
atomFeed feedType = "atom"
jsonFeed feedType = "json"
noFeed feedType = ""
rssFeed feedType = "rss"
atomFeed feedType = "atom"
jsonFeed feedType = "json"
minRssFeed feedType = "min.rss"
minAtomFeed feedType = "min.atom"
minJsonFeed feedType = "min.json"
)
func (a *goBlog) generateFeed(blog string, f feedType, w http.ResponseWriter, r *http.Request, posts []*post, title, description string) {
@ -40,7 +43,12 @@ func (a *goBlog) generateFeed(blog string, f feedType, w http.ResponseWriter, r
}
for _, p := range posts {
buf := bufferpool.Get()
a.feedHtml(buf, p)
switch f {
case minRssFeed, minAtomFeed, minJsonFeed:
a.minFeedHtml(buf, p)
default:
a.feedHtml(buf, p)
}
feed.Add(&feeds.Item{
Title: p.RenderedTitle,
Link: &feeds.Link{Href: a.fullPostURL(p)},
@ -55,13 +63,13 @@ func (a *goBlog) generateFeed(blog string, f feedType, w http.ResponseWriter, r
var feedWriteFunc func(w io.Writer) error
var feedMediaType string
switch f {
case rssFeed:
case rssFeed, minRssFeed:
feedMediaType = contenttype.RSS
feedWriteFunc = feed.WriteRss
case atomFeed:
case atomFeed, minAtomFeed:
feedMediaType = contenttype.ATOM
feedWriteFunc = feed.WriteAtom
case jsonFeed:
case jsonFeed, minJsonFeed:
feedMediaType = contenttype.JSONFeed
feedWriteFunc = feed.WriteJSON
default:

@ -117,7 +117,7 @@ func (*goBlog) redirectToHttps(w http.ResponseWriter, r *http.Request) {
const (
paginationPath = "/page/{page:[0-9-]+}"
feedPath = ".{feed:(rss|json|atom)}"
feedPath = ".{feed:(rss|json|atom|min\\.rss|min\\.json|min\\.atom)}"
)
func (a *goBlog) reloadRouter() {

@ -89,6 +89,15 @@ func (a *goBlog) feedHtml(w io.Writer, p *post) {
}
}
func (a *goBlog) minFeedHtml(w io.Writer, p *post) {
hb := newHtmlBuilder(w)
// Add IndieWeb context
a.renderPostReplyContext(hb, p, "p")
a.renderPostLikeContext(hb, p, "p")
// Add post HTML
a.postHtmlToWriter(hb, p, true)
}
const summaryDivider = "<!--more-->"
func (a *goBlog) postSummary(p *post) (summary string) {

@ -40,13 +40,10 @@ func (a *goBlog) renderBase(hb *htmlBuilder, rd *renderData, title, main func(hb
} else {
a.renderTitleTag(hb, rd.Blog, "")
}
// Feeds
renderedBlogTitle := a.renderMdTitle(rd.Blog.Title)
// RSS
// Feeds
hb.writeElementOpen("link", "rel", "alternate", "type", "application/rss+xml", "title", fmt.Sprintf("RSS (%s)", renderedBlogTitle), "href", a.getFullAddress(rd.Blog.Path+".rss"))
// ATOM
hb.writeElementOpen("link", "rel", "alternate", "type", "application/atom+xml", "title", fmt.Sprintf("ATOM (%s)", renderedBlogTitle), "href", a.getFullAddress(rd.Blog.Path+".atom"))
// JSON Feed
hb.writeElementOpen("link", "rel", "alternate", "type", "application/feed+json", "title", fmt.Sprintf("JSON Feed (%s)", renderedBlogTitle), "href", a.getFullAddress(rd.Blog.Path+".json"))
// Webmentions
hb.writeElementOpen("link", "rel", "webmention", "href", a.getFullAddress("/webmention"))
@ -368,11 +365,8 @@ func (a *goBlog) renderIndex(hb *htmlBuilder, rd *renderData) {
if renderedIndexTitle != "" {
feedTitle = " (" + renderedIndexTitle + ")"
}
// RSS
hb.writeElementOpen("link", "rel", "alternate", "type", "application/rss+xml", "title", "RSS"+feedTitle, "href", a.getFullAddress(id.first+".rss"))
// ATOM
hb.writeElementOpen("link", "rel", "alternate", "type", "application/atom+xml", "title", "ATOM"+feedTitle, "href", a.getFullAddress(id.first+".atom"))
// JSON Feed
hb.writeElementOpen("link", "rel", "alternate", "type", "application/feed+json", "title", "JSON Feed"+feedTitle, "href", a.getFullAddress(id.first+".json"))
},
func(hb *htmlBuilder) {

Loading…
Cancel
Save