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

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) {