1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
|
diff --git a/pkg/apps/prose/api.go b/pkg/apps/prose/api.go
index 7225ca6..eaef804 100644
--- a/pkg/apps/prose/api.go
+++ b/pkg/apps/prose/api.go
@@ -90,6 +90,7 @@ type PostPageData struct {
Diff template.HTML
UpdatedAtISO string
UpdatedAt string
+ List *shared.ListParsedText
}
type HeaderTxt struct {
@@ -427,22 +428,47 @@ func postHandler(w http.ResponseWriter, r *http.Request) {
post, err := dbpool.FindPostWithSlug(slug, user.ID, cfg.Space)
if err == nil {
logger.Info("post found", "id", post.ID, "filename", post.FileSize)
- parsedText, err := shared.ParseText(post.Text)
- if err != nil {
- logger.Error("find post with slug", "err", err.Error())
- }
+ ext := filepath.Ext(post.Filename)
+ contents := template.HTML("")
+ tags := []string{}
+ unlisted := false
+ var list *shared.ListParsedText
+
+ switch ext {
+ case ".lxt":
+ list = shared.ListParseText(post.Text)
+
+ // if parsedText.Image != "" {
+ // ogImage = parsedText.Image
+ // }
+ //
+ // if parsedText.ImageCard != "" {
+ // ogImageCard = parsedText.ImageCard
+ // }
+ tags = list.Tags
+
+ if post.Hidden || post.PublishAt.After(time.Now()) {
+ unlisted = true
+ }
+ case ".md":
+ parsedText, err := shared.ParseText(post.Text)
+ if err != nil {
+ logger.Error("could not parse md text", "err", err.Error())
+ }
- if parsedText.Image != "" {
- ogImage = parsedText.Image
- }
+ if parsedText.Image != "" {
+ ogImage = parsedText.Image
+ }
- if parsedText.ImageCard != "" {
- ogImageCard = parsedText.ImageCard
- }
+ if parsedText.ImageCard != "" {
+ ogImageCard = parsedText.ImageCard
+ }
+ tags = parsedText.Tags
- unlisted := false
- if post.Hidden || post.PublishAt.After(time.Now()) {
- unlisted = true
+ if post.Hidden || post.PublishAt.After(time.Now()) {
+ unlisted = true
+ }
+ contents = template.HTML(parsedText.Html)
}
data = PostPageData{
@@ -459,10 +485,10 @@ func postHandler(w http.ResponseWriter, r *http.Request) {
UpdatedAtISO: post.UpdatedAt.Format(time.RFC3339),
Username: username,
BlogName: blogName,
- Contents: template.HTML(parsedText.Html),
+ Contents: contents,
HasCSS: hasCSS,
CssURL: template.URL(cfg.CssURL(username)),
- Tags: parsedText.Tags,
+ Tags: tags,
Image: template.URL(ogImage),
ImageCard: ogImageCard,
Favicon: template.URL(favicon),
@@ -470,6 +496,7 @@ func postHandler(w http.ResponseWriter, r *http.Request) {
Unlisted: unlisted,
Diff: template.HTML(diff),
WithStyles: withStyles,
+ List: list,
}
} else {
logger.Info("post not found")
@@ -522,6 +549,7 @@ func postHandler(w http.ResponseWriter, r *http.Request) {
}
ts, err := shared.RenderTemplate(cfg, []string{
+ cfg.StaticPath("html/list.partial.tmpl"),
cfg.StaticPath("html/post.page.tmpl"),
})
|