render notes fully

This commit is contained in:
Niko Abeler 2022-12-01 19:32:49 +01:00
parent 0db1c7a9ec
commit c67535c1d9
2 changed files with 29 additions and 18 deletions

View File

@ -2,9 +2,13 @@
{{range .}} {{range .}}
<div class="h-entry"> <div class="h-entry">
<hgroup> <hgroup>
{{ if eq .Meta.Type "note"}}
<p>{{.RenderedContent}}</p>
{{ else }}
<h3><a class="u-url" href="{{.UrlPath}}"> <h3><a class="u-url" href="{{.UrlPath}}">
{{ if .Title }}{{.Title}}{{ else }}Note: {{.Id}}{{ end }} {{ if .Title }}{{.Title}}{{ else }}{{.Id}}{{ end }}
</a></h3> </a></h3>
{{ end }}
<small> <small>
Published: Published:
<time class="dt-published" datetime="{{.Meta.Date}}"> <time class="dt-published" datetime="{{.Meta.Date}}">

View File

@ -81,13 +81,14 @@ func TestCanRenderPostList(t *testing.T) {
user := getTestUser() user := getTestUser()
user.CreateNewPost("testpost1", false) user.CreateNewPost("testpost1", false)
user.CreateNewPost("testpost2", false) user.CreateNewPost("testpost2", false)
result, _ := owl.RenderPostList(user, &owl.PostList{ result, err := owl.RenderPostList(user, &owl.PostList{
Id: "testlist", Id: "testlist",
Title: "Test List", Title: "Test List",
Include: []string{ Include: []string{
"article", "article",
}, },
}) })
assertions.AssertNoError(t, err, "Error rendering post list")
assertions.AssertContains(t, result, "testpost1") assertions.AssertContains(t, result, "testpost1")
assertions.AssertContains(t, result, "testpost2") assertions.AssertContains(t, result, "testpost2")
} }
@ -138,7 +139,13 @@ func TestCanRenderIndexPageNoTitle(t *testing.T) {
post, _ := user.CreateNewPostFull(owl.PostMeta{}, "hi") post, _ := user.CreateNewPostFull(owl.PostMeta{}, "hi")
result, _ := owl.RenderIndexPage(user) result, _ := owl.RenderIndexPage(user)
assertions.AssertContains(t, result, post.Id()) assertions.AssertContains(t, result, post.Id())
assertions.AssertContains(t, result, "Note: ") }
func TestRenderNoteAsFullContent(t *testing.T) {
user := getTestUser()
post, _ := user.CreateNewPostFull(owl.PostMeta{Type: "note"}, "hi")
result, _ := owl.RenderPost(post)
assertions.AssertContains(t, result, "hi")
} }
func TestIndexPageContainsHFeedContainer(t *testing.T) { func TestIndexPageContainsHFeedContainer(t *testing.T) {