Add reply count to catalog previews. Stage ip count
This commit is contained in:
+8
-7
@@ -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
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
@@ -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 {
|
||||
|
||||
+10
-4
@@ -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) {
|
||||
<div id="catalog">
|
||||
for _, preview := range previews {
|
||||
{{ replyCount := strconv.FormatInt(int64(preview.ReplyCount), 10) }}
|
||||
{{ ipCount := strconv.FormatInt(int64(preview.IpCount), 10) }}
|
||||
<div class="catalog-preview">
|
||||
<a href={ templ.URL(preview.ThreadURL) }>
|
||||
<img
|
||||
@@ -90,6 +95,7 @@ templ ThreadsCatalog(previews []CatalogThreadPreview) {
|
||||
preview.MediaPath) }
|
||||
/>
|
||||
</a>
|
||||
<strong class="catalog-preview-counts">R: { replyCount } / I: { ipCount }</strong>
|
||||
<h1>
|
||||
<a href={ templ.URL(preview.ThreadURL) } class="catalog-preview-link">{ preview.Subject }</a>
|
||||
</h1>
|
||||
|
||||
Reference in New Issue
Block a user