repos / pico

pico services - prose.sh, pastes.sh, imgs.sh, feeds.sh, pgs.sh
git clone https://github.com/picosh/pico.git

commit
0a3f88a
parent
f13ddd4
author
Eric Bower
date
2023-11-12 19:16:05 +0000 UTC
feat(prose): render `unlisted` on post when hidden
2 files changed,  +9, -0
M prose/api.go
+8, -0
 1@@ -82,6 +82,7 @@ type PostPageData struct {
 2 	ImageCard    string
 3 	Footer       template.HTML
 4 	Favicon      template.URL
 5+	Unlisted     bool
 6 }
 7 
 8 type TransparencyPageData struct {
 9@@ -405,6 +406,11 @@ func postHandler(w http.ResponseWriter, r *http.Request) {
10 			}
11 		}
12 
13+		unlisted := false
14+		if post.Hidden || post.PublishAt.After(time.Now()) {
15+			unlisted = true
16+		}
17+
18 		data = PostPageData{
19 			Site:         *cfg.GetSiteData(),
20 			PageTitle:    GetPostTitle(post),
21@@ -425,6 +431,7 @@ func postHandler(w http.ResponseWriter, r *http.Request) {
22 			ImageCard:    ogImageCard,
23 			Favicon:      template.URL(favicon),
24 			Footer:       footerHTML,
25+			Unlisted:     unlisted,
26 		}
27 	} else {
28 		data = PostPageData{
29@@ -438,6 +445,7 @@ func postHandler(w http.ResponseWriter, r *http.Request) {
30 			Username:     username,
31 			BlogName:     blogName,
32 			Contents:     "Oops!  we can't seem to find this post.",
33+			Unlisted:     true,
34 		}
35 		logger.Infof("post not found %s/%s", username, slug)
36 	}
M prose/html/post.page.tmpl
+1, -0
1@@ -50,6 +50,7 @@
2 <header>
3     <h1 class="text-2xl font-bold">{{.Title}}</h1>
4     <p class="font-bold m-0">
5+        {{if .Unlisted}} <code>unlisted</code>{{end}}
6         <time datetime="{{.PublishAtISO}}">{{.PublishAt}}</time>
7         <span> on </span>
8         <a href="{{.BlogURL}}">{{.BlogName}}</a></p>