render webmentions in post
This commit is contained in:
parent
8d1dacc1f5
commit
4aaa14e30c
|
@ -13,4 +13,24 @@
|
|||
<div class="e-content">
|
||||
{{.Content}}
|
||||
</div>
|
||||
|
||||
<hr>
|
||||
{{if .Post.ApprovedWebmentions}}
|
||||
<h3>
|
||||
Webmentions
|
||||
</h3>
|
||||
<ul>
|
||||
{{range .Post.ApprovedWebmentions}}
|
||||
<li>
|
||||
<a href="{{.Source}}">
|
||||
{{if .Title}}
|
||||
{{.Title}}
|
||||
{{else}}
|
||||
{{.Source}}
|
||||
{{end}}
|
||||
</a>
|
||||
</li>
|
||||
{{end}}
|
||||
</ul>
|
||||
{{end}}
|
||||
</div>
|
|
@ -6,6 +6,7 @@ import (
|
|||
"path"
|
||||
"strings"
|
||||
"testing"
|
||||
"time"
|
||||
)
|
||||
|
||||
func TestCanRenderPost(t *testing.T) {
|
||||
|
@ -157,3 +158,44 @@ func TestRenderPostIncludesRelToWebMention(t *testing.T) {
|
|||
t.Error("webmention href not rendered. Got: " + result)
|
||||
}
|
||||
}
|
||||
|
||||
func TestRenderPostAddsLinksToApprovedWebmention(t *testing.T) {
|
||||
user := getTestUser()
|
||||
post, _ := user.CreateNewPost("testpost")
|
||||
webmention := owl.Webmention{
|
||||
Source: "http://example.com/source3",
|
||||
Title: "Test Title",
|
||||
ApprovalStatus: "approved",
|
||||
RetrievedAt: time.Now().Add(time.Hour * -2),
|
||||
}
|
||||
post.PersistWebmention(webmention)
|
||||
webmention = owl.Webmention{
|
||||
Source: "http://example.com/source4",
|
||||
ApprovalStatus: "rejected",
|
||||
RetrievedAt: time.Now().Add(time.Hour * -3),
|
||||
}
|
||||
post.PersistWebmention(webmention)
|
||||
|
||||
result, _ := owl.RenderPost(&post)
|
||||
if !strings.Contains(result, "http://example.com/source3") {
|
||||
t.Error("webmention not rendered. Got: " + result)
|
||||
}
|
||||
if !strings.Contains(result, "Test Title") {
|
||||
t.Error("webmention title not rendered. Got: " + result)
|
||||
}
|
||||
if strings.Contains(result, "http://example.com/source4") {
|
||||
t.Error("unapproved webmention rendered. Got: " + result)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
func TestRenderPostNotMentioningWebmentionsIfNoAvail(t *testing.T) {
|
||||
user := getTestUser()
|
||||
post, _ := user.CreateNewPost("testpost")
|
||||
result, _ := owl.RenderPost(&post)
|
||||
|
||||
if strings.Contains(result, "Webmention") {
|
||||
t.Error("Webmention mentioned. Got: " + result)
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue