fix note rendering
This commit is contained in:
parent
c67535c1d9
commit
48a11ab6d7
6
post.go
6
post.go
|
@ -168,7 +168,7 @@ func (post *Post) Content() []byte {
|
||||||
return data
|
return data
|
||||||
}
|
}
|
||||||
|
|
||||||
func (post *Post) RenderedContent() bytes.Buffer {
|
func (post *Post) RenderedContent() string {
|
||||||
data := post.Content()
|
data := post.Content()
|
||||||
|
|
||||||
// trim yaml block
|
// trim yaml block
|
||||||
|
@ -204,7 +204,7 @@ func (post *Post) RenderedContent() bytes.Buffer {
|
||||||
panic(err)
|
panic(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
return buf
|
return buf.String()
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -366,7 +366,7 @@ 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 := post.RenderedContent()
|
postHtml := post.RenderedContent()
|
||||||
links, _ := post.user.repo.Parser.ParseLinksFromString(postHtml.String())
|
links, _ := post.user.repo.Parser.ParseLinksFromString(postHtml)
|
||||||
// add reply url if set
|
// add reply url if set
|
||||||
if post.Meta().Reply.Url != "" {
|
if post.Meta().Reply.Url != "" {
|
||||||
links = append(links, post.Meta().Reply.Url)
|
links = append(links, post.Meta().Reply.Url)
|
||||||
|
|
|
@ -80,8 +80,7 @@ func TestNoRawHTMLIfDisallowedByRepo(t *testing.T) {
|
||||||
content += "<script>alert('foo')</script>\n"
|
content += "<script>alert('foo')</script>\n"
|
||||||
os.WriteFile(post.ContentFile(), []byte(content), 0644)
|
os.WriteFile(post.ContentFile(), []byte(content), 0644)
|
||||||
html := post.RenderedContent()
|
html := post.RenderedContent()
|
||||||
html_str := html.String()
|
assertions.AssertNotContains(t, html, "<script>")
|
||||||
assertions.AssertNotContains(t, html_str, "<script>")
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestRawHTMLIfAllowedByRepo(t *testing.T) {
|
func TestRawHTMLIfAllowedByRepo(t *testing.T) {
|
||||||
|
@ -96,8 +95,7 @@ func TestRawHTMLIfAllowedByRepo(t *testing.T) {
|
||||||
content += "<script>alert('foo')</script>\n"
|
content += "<script>alert('foo')</script>\n"
|
||||||
os.WriteFile(post.ContentFile(), []byte(content), 0644)
|
os.WriteFile(post.ContentFile(), []byte(content), 0644)
|
||||||
html := post.RenderedContent()
|
html := post.RenderedContent()
|
||||||
html_str := html.String()
|
assertions.AssertContains(t, html, "<script>")
|
||||||
assertions.AssertContains(t, html_str, "<script>")
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestLoadMeta(t *testing.T) {
|
func TestLoadMeta(t *testing.T) {
|
||||||
|
|
|
@ -99,7 +99,7 @@ func renderPostContent(post *Post) (string, error) {
|
||||||
postHtml, err := renderEmbedTemplate("embed/post.html", PostRenderData{
|
postHtml, err := renderEmbedTemplate("embed/post.html", PostRenderData{
|
||||||
Title: post.Title(),
|
Title: post.Title(),
|
||||||
Post: post,
|
Post: post,
|
||||||
Content: template.HTML(buf.String()),
|
Content: template.HTML(buf),
|
||||||
})
|
})
|
||||||
return postHtml, err
|
return postHtml, err
|
||||||
}
|
}
|
||||||
|
|
|
@ -143,9 +143,11 @@ func TestCanRenderIndexPageNoTitle(t *testing.T) {
|
||||||
|
|
||||||
func TestRenderNoteAsFullContent(t *testing.T) {
|
func TestRenderNoteAsFullContent(t *testing.T) {
|
||||||
user := getTestUser()
|
user := getTestUser()
|
||||||
post, _ := user.CreateNewPostFull(owl.PostMeta{Type: "note"}, "hi")
|
user.CreateNewPostFull(owl.PostMeta{Type: "note"}, "This is a note")
|
||||||
result, _ := owl.RenderPost(post)
|
result, _ := owl.RenderPostList(user, &owl.PostList{
|
||||||
assertions.AssertContains(t, result, "hi")
|
Include: []string{"note"},
|
||||||
|
})
|
||||||
|
assertions.AssertContains(t, result, "This is a note")
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestIndexPageContainsHFeedContainer(t *testing.T) {
|
func TestIndexPageContainsHFeedContainer(t *testing.T) {
|
||||||
|
|
Loading…
Reference in New Issue