mirror of https://github.com/jlelse/GoBlog
Reply / like context in feeds (#22)
This commit is contained in:
parent
b72089bc4a
commit
e8189acb40
|
@ -546,3 +546,7 @@ func (a *goBlog) getBlog(r *http.Request) (string, *configBlog) {
|
||||||
}
|
}
|
||||||
return blog, a.cfg.Blogs[blog]
|
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("source")
|
||||||
hb.writeElementClose("audio")
|
hb.writeElementClose("audio")
|
||||||
}
|
}
|
||||||
|
// Add IndieWeb context
|
||||||
|
a.renderPostReplyContext(hb, p, "p")
|
||||||
|
a.renderPostLikeContext(hb, p, "p")
|
||||||
// Add post HTML
|
// Add post HTML
|
||||||
a.postHtmlToWriter(hb, p, true)
|
a.postHtmlToWriter(hb, p, true)
|
||||||
// Add link to interactions and comments
|
// 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 {
|
if cc := blogConfig.Comments; cc != nil && cc.Enabled {
|
||||||
hb.writeElementOpen("p")
|
hb.writeElementOpen("p")
|
||||||
hb.writeElementOpen("a", "href", a.getFullAddress(p.Path)+"#interactions")
|
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")
|
hb.writeElementClose("div")
|
||||||
}
|
}
|
||||||
// IndieWeb Meta
|
// IndieWeb Meta
|
||||||
// Reply ("u-in-reply-to")
|
a.renderPostReplyContext(hb, p, "")
|
||||||
if replyLink := a.replyLink(p); replyLink != "" {
|
a.renderPostLikeContext(hb, p, "")
|
||||||
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")
|
|
||||||
}
|
|
||||||
// Like ("u-like-of")
|
// Like ("u-like-of")
|
||||||
if likeLink := a.likeLink(p); likeLink != "" {
|
if likeLink := a.likeLink(p); likeLink != "" {
|
||||||
hb.writeElementOpen("div")
|
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
|
// warning for old posts
|
||||||
func (a *goBlog) renderOldContentWarning(hb *htmlBuilder, p *post, b *configBlog) {
|
func (a *goBlog) renderOldContentWarning(hb *htmlBuilder, p *post, b *configBlog) {
|
||||||
if b == nil || b.hideOldContentWarning || p == nil || !p.Old() {
|
if b == nil || b.hideOldContentWarning || p == nil || !p.Old() {
|
||||||
|
|
Loading…
Reference in New Issue