add u-url to post page

This commit is contained in:
Niko Abeler 2022-09-06 20:00:12 +02:00
parent 6e6d8005da
commit 945a13ed2f
3 changed files with 17 additions and 5 deletions

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())
}
}