diff --git a/web/main.go b/web/main.go index af301a5..da55f8d 100644 --- a/web/main.go +++ b/web/main.go @@ -226,14 +226,13 @@ func main() { previews := make([]views.CatalogThreadPreview, 0, len(threads)) for _, thread := range threads { - op, err := database.GetOriginalPost(db, thread.Id) + posts, err := database.GetPosts(db, thread.Id) if err != nil { http.Error(w, "Failed to get posts", http.StatusBadRequest) log.Printf("GetOriginalPost: %v", err) return } - - log.Printf("OP: %+v", op) + op := posts[0] if op.MediaPath == "" { http.Error(w, "Malformed thread", http.StatusInternalServerError) @@ -242,10 +241,12 @@ func main() { } previews = append(previews, views.CatalogThreadPreview{ - Subject: thread.Subject, - Body: op.Body, - ThreadURL: fmt.Sprintf("/%s/threads/%d", slug, thread.Id), - MediaPath: op.MediaPath, + Subject: thread.Subject, + Body: op.Body, + ThreadURL: fmt.Sprintf("/%s/threads/%d", slug, thread.Id), + MediaPath: op.MediaPath, + ReplyCount: len(posts), + IpCount: 0, // TODO }) } diff --git a/web/static/index.css b/web/static/index.css index 1ad5ae7..823b34d 100644 --- a/web/static/index.css +++ b/web/static/index.css @@ -62,7 +62,6 @@ body { margin: 10px; text-align: center; padding: 10px; - border: 2px solid rgba(111, 111, 111, 0.34); width: 200px; max-height: 192px; overflow: scroll; @@ -87,11 +86,17 @@ body { .catalog-preview-img { max-height: 70%; max-width: 80%; - margin-bottom: 10px; border: 1px solid #B7C5D9; box-shadow: 0 0 3px rgba(0, 0, 0, 0.25); } +.catalog-preview-counts { + display: block; + font-size: 12px; + margin-bottom: 5px; + margin-top: 2.5px; +} + /* NEW THREAD BUTTON/FORM */ #newThreadBtn { diff --git a/web/views/board.templ b/web/views/board.templ index 8a1ea6f..e154a08 100644 --- a/web/views/board.templ +++ b/web/views/board.templ @@ -5,6 +5,7 @@ import ( "github.com/dominicf2001/comfychan/internal/database" "github.com/dominicf2001/comfychan/internal/util" "github.com/dominicf2001/comfychan/web/views/shared" + "strconv" ) templ NewThreadForm(board database.Board) { @@ -72,15 +73,19 @@ templ Board(board database.Board) { } type CatalogThreadPreview struct { - Subject string - Body string - ThreadURL string - MediaPath string + Subject string + Body string + ThreadURL string + MediaPath string + ReplyCount int + IpCount int } templ ThreadsCatalog(previews []CatalogThreadPreview) {
for _, preview := range previews { + {{ replyCount := strconv.FormatInt(int64(preview.ReplyCount), 10) }} + {{ ipCount := strconv.FormatInt(int64(preview.IpCount), 10) }}
+ R: { replyCount } / I: { ipCount }

{ preview.Subject }