Add reply count to catalog previews. Stage ip count
This commit is contained in:
+4
-3
@@ -226,14 +226,13 @@ func main() {
|
|||||||
|
|
||||||
previews := make([]views.CatalogThreadPreview, 0, len(threads))
|
previews := make([]views.CatalogThreadPreview, 0, len(threads))
|
||||||
for _, thread := range threads {
|
for _, thread := range threads {
|
||||||
op, err := database.GetOriginalPost(db, thread.Id)
|
posts, err := database.GetPosts(db, thread.Id)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
http.Error(w, "Failed to get posts", http.StatusBadRequest)
|
http.Error(w, "Failed to get posts", http.StatusBadRequest)
|
||||||
log.Printf("GetOriginalPost: %v", err)
|
log.Printf("GetOriginalPost: %v", err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
op := posts[0]
|
||||||
log.Printf("OP: %+v", op)
|
|
||||||
|
|
||||||
if op.MediaPath == "" {
|
if op.MediaPath == "" {
|
||||||
http.Error(w, "Malformed thread", http.StatusInternalServerError)
|
http.Error(w, "Malformed thread", http.StatusInternalServerError)
|
||||||
@@ -246,6 +245,8 @@ func main() {
|
|||||||
Body: op.Body,
|
Body: op.Body,
|
||||||
ThreadURL: fmt.Sprintf("/%s/threads/%d", slug, thread.Id),
|
ThreadURL: fmt.Sprintf("/%s/threads/%d", slug, thread.Id),
|
||||||
MediaPath: op.MediaPath,
|
MediaPath: op.MediaPath,
|
||||||
|
ReplyCount: len(posts),
|
||||||
|
IpCount: 0, // TODO
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -62,7 +62,6 @@ body {
|
|||||||
margin: 10px;
|
margin: 10px;
|
||||||
text-align: center;
|
text-align: center;
|
||||||
padding: 10px;
|
padding: 10px;
|
||||||
border: 2px solid rgba(111, 111, 111, 0.34);
|
|
||||||
width: 200px;
|
width: 200px;
|
||||||
max-height: 192px;
|
max-height: 192px;
|
||||||
overflow: scroll;
|
overflow: scroll;
|
||||||
@@ -87,11 +86,17 @@ body {
|
|||||||
.catalog-preview-img {
|
.catalog-preview-img {
|
||||||
max-height: 70%;
|
max-height: 70%;
|
||||||
max-width: 80%;
|
max-width: 80%;
|
||||||
margin-bottom: 10px;
|
|
||||||
border: 1px solid #B7C5D9;
|
border: 1px solid #B7C5D9;
|
||||||
box-shadow: 0 0 3px rgba(0, 0, 0, 0.25);
|
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 */
|
/* NEW THREAD BUTTON/FORM */
|
||||||
|
|
||||||
#newThreadBtn {
|
#newThreadBtn {
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ import (
|
|||||||
"github.com/dominicf2001/comfychan/internal/database"
|
"github.com/dominicf2001/comfychan/internal/database"
|
||||||
"github.com/dominicf2001/comfychan/internal/util"
|
"github.com/dominicf2001/comfychan/internal/util"
|
||||||
"github.com/dominicf2001/comfychan/web/views/shared"
|
"github.com/dominicf2001/comfychan/web/views/shared"
|
||||||
|
"strconv"
|
||||||
)
|
)
|
||||||
|
|
||||||
templ NewThreadForm(board database.Board) {
|
templ NewThreadForm(board database.Board) {
|
||||||
@@ -76,11 +77,15 @@ type CatalogThreadPreview struct {
|
|||||||
Body string
|
Body string
|
||||||
ThreadURL string
|
ThreadURL string
|
||||||
MediaPath string
|
MediaPath string
|
||||||
|
ReplyCount int
|
||||||
|
IpCount int
|
||||||
}
|
}
|
||||||
|
|
||||||
templ ThreadsCatalog(previews []CatalogThreadPreview) {
|
templ ThreadsCatalog(previews []CatalogThreadPreview) {
|
||||||
<div id="catalog">
|
<div id="catalog">
|
||||||
for _, preview := range previews {
|
for _, preview := range previews {
|
||||||
|
{{ replyCount := strconv.FormatInt(int64(preview.ReplyCount), 10) }}
|
||||||
|
{{ ipCount := strconv.FormatInt(int64(preview.IpCount), 10) }}
|
||||||
<div class="catalog-preview">
|
<div class="catalog-preview">
|
||||||
<a href={ templ.URL(preview.ThreadURL) }>
|
<a href={ templ.URL(preview.ThreadURL) }>
|
||||||
<img
|
<img
|
||||||
@@ -90,6 +95,7 @@ templ ThreadsCatalog(previews []CatalogThreadPreview) {
|
|||||||
preview.MediaPath) }
|
preview.MediaPath) }
|
||||||
/>
|
/>
|
||||||
</a>
|
</a>
|
||||||
|
<strong class="catalog-preview-counts">R: { replyCount } / I: { ipCount }</strong>
|
||||||
<h1>
|
<h1>
|
||||||
<a href={ templ.URL(preview.ThreadURL) } class="catalog-preview-link">{ preview.Subject }</a>
|
<a href={ templ.URL(preview.ThreadURL) } class="catalog-preview-link">{ preview.Subject }</a>
|
||||||
</h1>
|
</h1>
|
||||||
|
|||||||
Reference in New Issue
Block a user