+
+ {{.Title}}
+
+ #
+ Published:
+
+ {{.Post.Meta.FormattedDate}}
+
+ {{ if .Post.User.Config.AuthorName }}
+ by
+
+ {{ if .Post.User.AvatarUrl }}
+
+ {{ end }}
+ {{.Post.User.Config.AuthorName}}
+
+ {{ end }}
+
+
+
+
+
+ {{ if .Post.Meta.Reply.Url }}
+
+ In reply to:
+ {{ if .Post.Meta.Reply.Text }}
+ {{.Post.Meta.Reply.Text}}
+ {{ else }}
+ {{.Post.Meta.Reply.Url}}
+ {{ end }}
+
+
+ {{ end }}
+
+ {{ if .Post.Meta.Bookmark.Url }}
+
+ Bookmark:
+ {{ if .Post.Meta.Bookmark.Text }}
+ {{.Post.Meta.Bookmark.Text}}
+ {{ else }}
+ {{.Post.Meta.Bookmark.Url}}
+ {{ end }}
+
+
+ {{ end }}
+
+
+ {{.Content}}
+
+
+
+ {{if .Post.ApprovedIncomingWebmentions}}
+
+ Webmentions
+
+
+ {{end}}
+
\ No newline at end of file
diff --git a/embed/note/detail.html b/embed/note/detail.html
index ece34bc..0bf38cf 100644
--- a/embed/note/detail.html
+++ b/embed/note/detail.html
@@ -1,6 +1,5 @@
- {{.Title}}
#
Published:
@@ -22,30 +21,6 @@
- {{ if .Post.Meta.Reply.Url }}
-
- In reply to:
- {{ if .Post.Meta.Reply.Text }}
- {{.Post.Meta.Reply.Text}}
- {{ else }}
- {{.Post.Meta.Reply.Url}}
- {{ end }}
-
-
- {{ end }}
-
- {{ if .Post.Meta.Bookmark.Url }}
-
- Bookmark:
- {{ if .Post.Meta.Bookmark.Text }}
- {{.Post.Meta.Bookmark.Text}}
- {{ else }}
- {{.Post.Meta.Bookmark.Url}}
- {{ end }}
-
-
- {{ end }}
-
{{.Content}}
diff --git a/embed/reply/detail.html b/embed/reply/detail.html
new file mode 100644
index 0000000..c74f6bd
--- /dev/null
+++ b/embed/reply/detail.html
@@ -0,0 +1,60 @@
+
+
+ {{.Title}}
+
+ #
+ Published:
+
+ {{.Post.Meta.FormattedDate}}
+
+ {{ if .Post.User.Config.AuthorName }}
+ by
+
+ {{ if .Post.User.AvatarUrl }}
+
+ {{ end }}
+ {{.Post.User.Config.AuthorName}}
+
+ {{ end }}
+
+
+
+
+
+ {{ if .Post.Meta.Reply.Url }}
+
+ In reply to:
+ {{ if .Post.Meta.Reply.Text }}
+ {{.Post.Meta.Reply.Text}}
+ {{ else }}
+ {{.Post.Meta.Reply.Url}}
+ {{ end }}
+
+
+ {{ end }}
+
+
+ {{.Content}}
+
+
+
+ {{if .Post.ApprovedIncomingWebmentions}}
+
+ Webmentions
+
+
+ {{end}}
+
\ No newline at end of file
diff --git a/embed/untyped/detail.html b/embed/untyped/detail.html
new file mode 100644
index 0000000..ece34bc
--- /dev/null
+++ b/embed/untyped/detail.html
@@ -0,0 +1,72 @@
+
+
+ {{.Title}}
+
+ #
+ Published:
+
+ {{.Post.Meta.FormattedDate}}
+
+ {{ if .Post.User.Config.AuthorName }}
+ by
+
+ {{ if .Post.User.AvatarUrl }}
+
+ {{ end }}
+ {{.Post.User.Config.AuthorName}}
+
+ {{ end }}
+
+
+
+
+
+ {{ if .Post.Meta.Reply.Url }}
+
+ In reply to:
+ {{ if .Post.Meta.Reply.Text }}
+ {{.Post.Meta.Reply.Text}}
+ {{ else }}
+ {{.Post.Meta.Reply.Url}}
+ {{ end }}
+
+
+ {{ end }}
+
+ {{ if .Post.Meta.Bookmark.Url }}
+
+ Bookmark:
+ {{ if .Post.Meta.Bookmark.Text }}
+ {{.Post.Meta.Bookmark.Text}}
+ {{ else }}
+ {{.Post.Meta.Bookmark.Url}}
+ {{ end }}
+
+
+ {{ end }}
+
+
+ {{.Content}}
+
+
+
+ {{if .Post.ApprovedIncomingWebmentions}}
+
+ Webmentions
+
+
+ {{end}}
+
\ No newline at end of file
diff --git a/post.go b/post.go
index 03adbed..caf2794 100644
--- a/post.go
+++ b/post.go
@@ -59,24 +59,24 @@ type IPost interface {
SendWebmention(webmention WebmentionOut) error
}
-type Reply struct {
+type ReplyData struct {
Url string `yaml:"url"`
Text string `yaml:"text"`
}
-type Bookmark struct {
+type BookmarkData struct {
Url string `yaml:"url"`
Text string `yaml:"text"`
}
type PostMeta struct {
- Type string `yaml:"type"`
- Title string `yaml:"title"`
- Description string `yaml:"description"`
- Aliases []string `yaml:"aliases"`
- Date time.Time `yaml:"date"`
- Draft bool `yaml:"draft"`
- Reply Reply `yaml:"reply"`
- Bookmark Bookmark `yaml:"bookmark"`
+ Type string `yaml:"type"`
+ Title string `yaml:"title"`
+ Description string `yaml:"description"`
+ Aliases []string `yaml:"aliases"`
+ Date time.Time `yaml:"date"`
+ Draft bool `yaml:"draft"`
+ Reply ReplyData `yaml:"reply"`
+ Bookmark BookmarkData `yaml:"bookmark"`
}
func (pm PostMeta) FormattedDate() string {
@@ -85,13 +85,13 @@ func (pm PostMeta) FormattedDate() string {
func (pm *PostMeta) UnmarshalYAML(unmarshal func(interface{}) error) error {
type T struct {
- Type string `yaml:"type"`
- Title string `yaml:"title"`
- Description string `yaml:"description"`
- Aliases []string `yaml:"aliases"`
- Draft bool `yaml:"draft"`
- Reply Reply `yaml:"reply"`
- Bookmark Bookmark `yaml:"bookmark"`
+ Type string `yaml:"type"`
+ Title string `yaml:"title"`
+ Description string `yaml:"description"`
+ Aliases []string `yaml:"aliases"`
+ Draft bool `yaml:"draft"`
+ Reply ReplyData `yaml:"reply"`
+ Bookmark BookmarkData `yaml:"bookmark"`
}
type S struct {
Date string `yaml:"date"`
diff --git a/post_types.go b/post_types.go
index 2f0cdeb..b70da67 100644
--- a/post_types.go
+++ b/post_types.go
@@ -23,3 +23,19 @@ type Page struct {
func (p *Page) TemplateDir() string {
return "page"
}
+
+type Bookmark struct {
+ Post
+}
+
+func (b *Bookmark) TemplateDir() string {
+ return "bookmark"
+}
+
+type Reply struct {
+ Post
+}
+
+func (r *Reply) TemplateDir() string {
+ return "reply"
+}
diff --git a/renderer_test.go b/renderer_test.go
index ed17f37..81c3024 100644
--- a/renderer_test.go
+++ b/renderer_test.go
@@ -180,7 +180,7 @@ func TestIndexPageDoesNotContainsArticle(t *testing.T) {
func TestIndexPageDoesNotContainsReply(t *testing.T) {
user := getTestUser()
- user.CreateNewPostFull(owl.PostMeta{Type: "reply", Reply: owl.Reply{Url: "https://example.com/post"}}, "hi")
+ user.CreateNewPostFull(owl.PostMeta{Type: "reply", Reply: owl.ReplyData{Url: "https://example.com/post"}}, "hi")
result, _ := owl.RenderIndexPage(user)
assertions.AssertContains(t, result, "class=\"h-entry\"")
@@ -301,17 +301,12 @@ func TestAuthorNameInPost(t *testing.T) {
func TestRenderReplyWithoutText(t *testing.T) {
user := getTestUser()
- post, _ := user.CreateNewPost("testpost", false)
-
- content := "---\n"
- content += "title: test\n"
- content += "date: Wed, 17 Aug 2022 10:50:02 +0000\n"
- content += "reply: \n"
- content += " url: https://example.com/post\n"
- content += "---\n"
- content += "\n"
- content += "Hi \n"
- os.WriteFile(post.ContentFile(), []byte(content), 0644)
+ post, _ := user.CreateNewPostFull(owl.PostMeta{
+ Type: "reply",
+ Reply: owl.ReplyData{
+ Url: "https://example.com/post",
+ },
+ }, "Hi ")
result, _ := owl.RenderPost(post)
assertions.AssertContains(t, result, "https://example.com/post")
@@ -320,17 +315,13 @@ func TestRenderReplyWithoutText(t *testing.T) {
func TestRenderReplyWithText(t *testing.T) {
user := getTestUser()
- post, _ := user.CreateNewPost("testpost", false)
-
- content := "---\n"
- content += "title: test\n"
- content += "date: Wed, 17 Aug 2022 10:50:02 +0000\n"
- content += "reply: \n"
- content += " url: https://example.com/post\n"
- content += " text: \"This is a reply\"\n"
- content += "---\n"
- content += "Hi \n"
- os.WriteFile(post.ContentFile(), []byte(content), 0644)
+ post, _ := user.CreateNewPostFull(owl.PostMeta{
+ Type: "reply",
+ Reply: owl.ReplyData{
+ Url: "https://example.com/post",
+ Text: "This is a reply",
+ },
+ }, "Hi ")
result, _ := owl.RenderPost(post)
assertions.AssertContains(t, result, "https://example.com/post")
@@ -340,7 +331,7 @@ func TestRenderReplyWithText(t *testing.T) {
func TestRengerPostContainsBookmark(t *testing.T) {
user := getTestUser()
- post, _ := user.CreateNewPostFull(owl.PostMeta{Type: "bookmark", Bookmark: owl.Bookmark{Url: "https://example.com/post"}}, "hi")
+ post, _ := user.CreateNewPostFull(owl.PostMeta{Type: "bookmark", Bookmark: owl.BookmarkData{Url: "https://example.com/post"}}, "hi")
result, _ := owl.RenderPost(post)
assertions.AssertContains(t, result, "https://example.com/post")
diff --git a/user.go b/user.go
index e264ebb..8dd755d 100644
--- a/user.go
+++ b/user.go
@@ -285,14 +285,17 @@ func (user User) GetPost(id string) (IPost, error) {
}
post := Post{user: &user, id: id}
- if post.Meta().Type == "" {
- return &Article{Post: post}, nil
- }
switch post.Meta().Type {
case "article":
return &Article{Post: post}, nil
case "note":
return &Note{Post: post}, nil
+ case "reply":
+ return &Reply{Post: post}, nil
+ case "bookmark":
+ return &Bookmark{Post: post}, nil
+ case "page":
+ return &Page{Post: post}, nil
}
return &post, nil
}