summaryrefslogtreecommitdiff
path: root/srv/src/post/post.go
diff options
context:
space:
mode:
authorBrian Picciano <mediocregopher@gmail.com>2022-05-13 11:47:29 -0600
committerBrian Picciano <mediocregopher@gmail.com>2022-05-14 15:22:10 -0600
commit2929b4279c7a8128bd305290cc4187b6afb11cde (patch)
treed5ee6a82a21cc3c74c5f5359479b67291b9dbb27 /srv/src/post/post.go
parentd284fe2d2518c43097c0fea436d2073de14f3ada (diff)
Implement rendering Posts to html
Diffstat (limited to 'srv/src/post/post.go')
-rw-r--r--srv/src/post/post.go20
1 files changed, 6 insertions, 14 deletions
diff --git a/srv/src/post/post.go b/srv/src/post/post.go
index bdc48af..5835995 100644
--- a/srv/src/post/post.go
+++ b/srv/src/post/post.go
@@ -5,7 +5,6 @@ import (
"database/sql"
"errors"
"fmt"
- "path"
"regexp"
"strings"
"time"
@@ -37,6 +36,12 @@ type Post struct {
Body string
}
+// HTTPPath returns the relative URL path of the StoredPost, when querying it
+// over HTTP.
+func (p Post) HTTPPath() string {
+ return fmt.Sprintf("%s.html", p.ID)
+}
+
// StoredPost is a Post which has been stored in a Store, and has been given
// some extra fields as a result.
type StoredPost struct {
@@ -46,19 +51,6 @@ type StoredPost struct {
LastUpdatedAt time.Time
}
-// URL returns the relative URL of the StoredPost.
-func (p StoredPost) URL() string {
- return path.Join(
- fmt.Sprintf(
- "%d/%0d/%0d",
- p.PublishedAt.Year(),
- p.PublishedAt.Month(),
- p.PublishedAt.Day(),
- ),
- p.ID+".html",
- )
-}
-
// Store is used for storing posts to a persistent storage.
type Store interface {