diff --git a/internal/util/util.go b/internal/util/util.go
new file mode 100644
index 0000000..abf4272
--- /dev/null
+++ b/internal/util/util.go
@@ -0,0 +1,19 @@
+package util
+
+import (
+ "html/template"
+ "strings"
+)
+
+func EnrichPost(body string) string {
+ lines := strings.Split(body, "\n")
+ for i, line := range lines {
+ if strings.HasPrefix(line, ">") {
+ escaped := template.HTMLEscapeString(line)
+ lines[i] = `` + escaped + ``
+ } else {
+ lines[i] = template.HTMLEscapeString(line)
+ }
+ }
+ return strings.Join(lines, "
")
+}
diff --git a/web/static/index.css b/web/static/index.css
index 1545d25..06ab7bb 100644
--- a/web/static/index.css
+++ b/web/static/index.css
@@ -55,6 +55,7 @@ body {
#catalog {
display: flex;
margin: 2rem;
+ flex-wrap: wrap;
}
.catalog-preview {
@@ -62,8 +63,7 @@ body {
text-align: center;
padding: 10px;
border: 2px solid rgba(111, 111, 111, 0.34);
- min-width: 140px;
- max-width: 200px;
+ width: 200px;
max-height: 192px;
}
@@ -187,6 +187,10 @@ body {
margin-bottom: 10px;
}
+.greentext {
+ color: #789922
+}
+
/* GENERAL LAYOUT */
.container {
diff --git a/web/views/thread.templ b/web/views/thread.templ
index 2800695..e29cb5c 100644
--- a/web/views/thread.templ
+++ b/web/views/thread.templ
@@ -3,6 +3,7 @@ package views
import (
"fmt"
"github.com/dominicf2001/comfychan/internal/database"
+ "github.com/dominicf2001/comfychan/internal/util"
"github.com/dominicf2001/comfychan/web/views/shared"
"strconv"
)
@@ -21,7 +22,9 @@ templ ThreadPosts(posts []database.Post) {
{ post.CreatedAt.Format("15:04") }
No. { strconv.Itoa(post.Id) }
-
{ post.Body }
++ @templ.Raw(util.EnrichPost(post.Body)) +
{ posts[0].Body }
++ @templ.Raw(util.EnrichPost(posts[0].Body)) +
{ preview.Body }
++ @templ.Raw(util.EnrichPost(preview.Body)) +