Sending Webmentions #10

Merged
h4kor merged 18 commits from webmention into master 2022-09-06 19:49:00 +00:00
3 changed files with 17 additions and 5 deletions
Showing only changes of commit 945a13ed2f - Show all commits

View File

@ -6,6 +6,7 @@
<time class="dt-published" datetime="{{.Post.Meta.Date}}">
{{.Post.Meta.Date}}
</time>
<a class="u-url" href="{{.Post.FullUrl}}">#</a>
</small>
</hgroup>
<hr>

View File

@ -358,11 +358,8 @@ func (post *Post) OutgoingWebmentions() []WebmentionOut {
func (post *Post) ScanForLinks() error {
// this could be done in markdown parsing, but I don't want to
// rely on goldmark for this (yet)
postHtml, err := renderPostContent(post)
if err != nil {
return err
}
links, _ := post.user.repo.Parser.ParseLinks([]byte(postHtml))
postHtml := post.RenderedContent()
links, _ := post.user.repo.Parser.ParseLinks(postHtml.Bytes())
for _, link := range links {
post.AddOutgoingWebmention(link)
}

View File

@ -199,3 +199,17 @@ func TestRenderPostNotMentioningWebmentionsIfNoAvail(t *testing.T) {
}
}
func TestRenderIncludesFullUrl(t *testing.T) {
user := getTestUser()
post, _ := user.CreateNewPost("testpost")
result, _ := owl.RenderPost(&post)
if !strings.Contains(result, "class=\"u-url\"") {
t.Error("u-url not rendered. Got: " + result)
}
if !strings.Contains(result, post.FullUrl()) {
t.Error("Full url not rendered. Got: " + result)
t.Error("Expected: " + post.FullUrl())
}
}