Implement per board post number incrementing
This commit is contained in:
+2
-5
@@ -78,7 +78,6 @@ func main() {
|
||||
// THREAD PAGE
|
||||
r.Get("/{slug}/threads/{threadId}", func(w http.ResponseWriter, r *http.Request) {
|
||||
slug := chi.URLParam(r, "slug")
|
||||
// TODO: use relative thread_nums (see issue #1)
|
||||
threadIdStr := chi.URLParam(r, "threadId")
|
||||
threadId, err := strconv.Atoi(threadIdStr)
|
||||
if err != nil {
|
||||
@@ -165,8 +164,7 @@ func main() {
|
||||
return
|
||||
}
|
||||
|
||||
// slug := chi.URLParam(r, "slug")
|
||||
// TODO: use relative thread_nums (see issue #1)
|
||||
slug := chi.URLParam(r, "slug")
|
||||
threadIdStr := chi.URLParam(r, "threadId")
|
||||
threadId, err := strconv.Atoi(threadIdStr)
|
||||
if err != nil {
|
||||
@@ -201,7 +199,7 @@ func main() {
|
||||
mediaPath = filename
|
||||
}
|
||||
|
||||
if err := database.PutPost(db, threadId, body, mediaPath, util.HashIp(ip)); err != nil {
|
||||
if err := database.PutPost(db, slug, threadId, body, mediaPath, util.HashIp(ip)); err != nil {
|
||||
http.Error(w, "Failed to create post", http.StatusInternalServerError)
|
||||
log.Printf("PutPost: %v", err)
|
||||
return
|
||||
@@ -256,7 +254,6 @@ func main() {
|
||||
// THREAD POSTS
|
||||
r.Get("/hx/{slug}/threads/{threadId}/posts", func(w http.ResponseWriter, r *http.Request) {
|
||||
// slug := chi.URLParam(r, "slug")
|
||||
// TODO: use relative thread_nums (see issue #1)
|
||||
threadIdStr := chi.URLParam(r, "threadId")
|
||||
threadId, err := strconv.Atoi(threadIdStr)
|
||||
if err != nil {
|
||||
|
||||
@@ -10,7 +10,7 @@ import (
|
||||
|
||||
templ PostOriginal(post database.Post, thread *database.Thread) {
|
||||
{{ imgInfo := util.GetPostImageInfo(post.MediaPath) }}
|
||||
<article id={ fmt.Sprintf("post-%d", post.Id) } class="post-op">
|
||||
<article id={ fmt.Sprintf("post-%d", post.Number) } class="post-op">
|
||||
<div>
|
||||
File:
|
||||
<a href={ templ.URL("/static/img/posts/full/" + post.MediaPath) } class="post-filename">
|
||||
@@ -28,9 +28,9 @@ templ PostOriginal(post database.Post, thread *database.Thread) {
|
||||
<span class="post-author">{ post.Author }</span>
|
||||
<span class="post-date">{ post.CreatedAt.Format("01/02/2006") }</span>
|
||||
<span class="post-time">{ post.CreatedAt.Format("15:04") }</span>
|
||||
<span _={ fmt.Sprintf("on click set #newPostBody.value to #newPostBody.value + '>>%d\n'", post.Id) }
|
||||
<span _={ fmt.Sprintf("on click set #newPostBody.value to #newPostBody.value + '>>%d\n'", post.Number) }
|
||||
class=" post-num">
|
||||
No.{ strconv.Itoa(post.Id) }
|
||||
No.{ strconv.Itoa(post.Number) }
|
||||
</span>
|
||||
<span class="post-replies"></span>
|
||||
</header>
|
||||
@@ -42,14 +42,14 @@ templ PostOriginal(post database.Post, thread *database.Thread) {
|
||||
|
||||
templ PostReply(post database.Post) {
|
||||
{{ imgInfo := util.GetPostImageInfo(post.MediaPath) }}
|
||||
<article id={ fmt.Sprintf("post-%d", post.Id) } class="post">
|
||||
<article id={ fmt.Sprintf("post-%d", post.Number) } class="post">
|
||||
<header class="post-header">
|
||||
<span class="post-author">{ post.Author }</span>
|
||||
<span class="post-date">{ post.CreatedAt.Format("01/02/2006") }</span>
|
||||
<span class="post-time">{ post.CreatedAt.Format("15:04") }</span>
|
||||
<span _={ fmt.Sprintf("on click set #newPostBody.value to #newPostBody.value + '>>%d\n'", post.Id) }
|
||||
<span _={ fmt.Sprintf("on click set #newPostBody.value to #newPostBody.value + '>>%d\n'", post.Number) }
|
||||
class=" post-num">
|
||||
No.{ strconv.Itoa(post.Id) }
|
||||
No.{ strconv.Itoa(post.Number) }
|
||||
</span>
|
||||
<span class="post-replies"></span>
|
||||
</header>
|
||||
|
||||
Reference in New Issue
Block a user