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

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

View File

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