Reply / like context in feeds (#22)

pull/31/head
Jan-Lukas Else 2 weeks ago
parent b72089bc4a
commit e8189acb40
  1. 4
      config.go
  2. 5
      postsFuncs.go
  3. 56
      uiComponents.go

@ -546,3 +546,7 @@ func (a *goBlog) getBlog(r *http.Request) (string, *configBlog) {
}
return blog, a.cfg.Blogs[blog]
}
func (a *goBlog) getBlogFromPost(p *post) *configBlog {
return a.cfg.Blogs[defaultIfEmpty(p.Blog, a.cfg.DefaultBlog)]
}

@ -73,10 +73,13 @@ func (a *goBlog) feedHtml(w io.Writer, p *post) {
hb.writeElementClose("source")
hb.writeElementClose("audio")
}
// Add IndieWeb context
a.renderPostReplyContext(hb, p, "p")
a.renderPostLikeContext(hb, p, "p")
// Add post HTML
a.postHtmlToWriter(hb, p, true)
// Add link to interactions and comments
blogConfig := a.cfg.Blogs[defaultIfEmpty(p.Blog, a.cfg.DefaultBlog)]
blogConfig := a.getBlogFromPost(p)
if cc := blogConfig.Comments; cc != nil && cc.Enabled {
hb.writeElementOpen("p")
hb.writeElementOpen("a", "href", a.getFullAddress(p.Path)+"#interactions")

@ -160,20 +160,8 @@ func (a *goBlog) renderPostMeta(hb *htmlBuilder, p *post, b *configBlog, typ str
hb.writeElementClose("div")
}
// IndieWeb Meta
// Reply ("u-in-reply-to")
if replyLink := a.replyLink(p); replyLink != "" {
hb.writeElementOpen("div")
hb.writeEscaped(a.ts.GetTemplateStringVariant(b.Lang, "replyto"))
hb.writeEscaped(": ")
hb.writeElementOpen("a", "class", "u-in-reply-to", "rel", "noopener", "target", "_blank", "href", replyLink)
if replyTitle := a.replyTitle(p); replyTitle != "" {
hb.writeEscaped(replyTitle)
} else {
hb.writeEscaped(replyLink)
}
hb.writeElementClose("a")
hb.writeElementClose("div")
}
a.renderPostReplyContext(hb, p, "")
a.renderPostLikeContext(hb, p, "")
// Like ("u-like-of")
if likeLink := a.likeLink(p); likeLink != "" {
hb.writeElementOpen("div")
@ -249,6 +237,46 @@ func (a *goBlog) renderPostMeta(hb *htmlBuilder, p *post, b *configBlog, typ str
}
}
// Reply ("u-in-reply-to")
func (a *goBlog) renderPostReplyContext(hb *htmlBuilder, p *post, htmlWrapperElement string) {
if htmlWrapperElement == "" {
htmlWrapperElement = "div"
}
if replyLink := a.replyLink(p); replyLink != "" {
hb.writeElementOpen(htmlWrapperElement)
hb.writeEscaped(a.ts.GetTemplateStringVariant(a.getBlogFromPost(p).Lang, "replyto"))
hb.writeEscaped(": ")
hb.writeElementOpen("a", "class", "u-in-reply-to", "rel", "noopener", "target", "_blank", "href", replyLink)
if replyTitle := a.replyTitle(p); replyTitle != "" {
hb.writeEscaped(replyTitle)
} else {
hb.writeEscaped(replyLink)
}
hb.writeElementClose("a")
hb.writeElementClose(htmlWrapperElement)
}
}
// Like ("u-like-of")
func (a *goBlog) renderPostLikeContext(hb *htmlBuilder, p *post, htmlWrapperElement string) {
if htmlWrapperElement == "" {
htmlWrapperElement = "div"
}
if likeLink := a.likeLink(p); likeLink != "" {
hb.writeElementOpen(htmlWrapperElement)
hb.writeEscaped(a.ts.GetTemplateStringVariant(a.getBlogFromPost(p).Lang, "likeof"))
hb.writeEscaped(": ")
hb.writeElementOpen("a", "class", "u-like-of", "rel", "noopener", "target", "_blank", "href", likeLink)
if likeTitle := a.likeTitle(p); likeTitle != "" {
hb.writeEscaped(likeTitle)
} else {
hb.writeEscaped(likeLink)
}
hb.writeElementClose("a")
hb.writeElementClose(htmlWrapperElement)
}
}
// warning for old posts
func (a *goBlog) renderOldContentWarning(hb *htmlBuilder, p *post, b *configBlog) {
if b == nil || b.hideOldContentWarning || p == nil || !p.Old() {

Loading…
Cancel
Save