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}}"> <time class="dt-published" datetime="{{.Post.Meta.Date}}">
{{.Post.Meta.Date}} {{.Post.Meta.Date}}
</time> </time>
<a class="u-url" href="{{.Post.FullUrl}}">#</a>
</small> </small>
</hgroup> </hgroup>
<hr> <hr>

View File

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