Started working on thread view
This commit is contained in:
parent
b5be7e9cef
commit
95ddd6774b
@ -21,7 +21,7 @@ component ForumHeader
|
||||
a.ajax(href="/forum/bug") Bugs
|
||||
|
||||
component ThreadLink(thread *arn.Thread)
|
||||
.thread(data-stick=toString(thread.Sticky))
|
||||
.thread-link(data-sticky=thread.Sticky)
|
||||
.post-author.thread-author
|
||||
Avatar(thread.Author)
|
||||
.thread-content-container
|
||||
|
@ -2,7 +2,7 @@
|
||||
text-align left
|
||||
margin-bottom 1.5rem
|
||||
|
||||
.thread
|
||||
.thread-link
|
||||
display flex
|
||||
flex-flow row
|
||||
width 100%
|
||||
|
54
pages/threads/threads.pixy
Normal file
54
pages/threads/threads.pixy
Normal file
@ -0,0 +1,54 @@
|
||||
component Thread(thread *arn.Thread)
|
||||
.thread
|
||||
h2.thread-title= thread.Title
|
||||
|
||||
.posts
|
||||
Post(thread.ToPostable(), nil, "Threads", "Thread", thread.AuthorID)
|
||||
//- +renderMessage(thread, user, "Threads", thread.author.ID)
|
||||
|
||||
//- each post in posts
|
||||
//- +renderMessage(post, user, "Posts", thread.author.ID)
|
||||
|
||||
component Post(post arn.Postable, viewUser *arn.User, postType string, postTypeSingular string, highlightAuthorID string)
|
||||
.post(class=[]string{"", "special-post"}[post.Author().ID == highlightAuthorID])
|
||||
.post-author
|
||||
Avatar(post.Author())
|
||||
|
||||
//- if post.recipient && post.recipient.ID !== post.author.ID
|
||||
//- a.user.post-recipient(href="/+" + post.recipient.nick, title=post.recipient.nick)
|
||||
//- img.user-image(src=post.recipient.avatar ? (post.recipient.avatar + "?s=100&r=x&d=mm") : "/images/elements/no-gravatar.svg", alt=post.recipient.nick)
|
||||
.post-content
|
||||
div(id="render-" + post.ID())!= aero.Markdown(post.Text())
|
||||
|
||||
//- if user && user.ID === post.authorId
|
||||
//- textarea.post-input.hidden(id="source-" + post.ID)= post.text
|
||||
//- a.post-save.hidden(id="save-" + post.ID, onclick=`$.saveEdit("${type.toLowerCase()}", "${post.ID}")`)
|
||||
//- i.fa.fa-save
|
||||
//- span Save
|
||||
|
||||
.post-toolbar(id="toolbar-" + post.ID())
|
||||
.spacer
|
||||
.post-likes(id="likes-" + post.ID())= len(post.Likes())
|
||||
|
||||
//- if user != nil
|
||||
//- if user.ID !== post.authorId
|
||||
//- - var liked = post.likes && post.likes.indexOf(user.ID) !== -1
|
||||
|
||||
//- a.post-tool.post-like(id="like-" + post.ID, onclick=`$.like("${type.toLowerCase()}", "${post.ID}")`, title="Like", class=liked ? "hidden" : ")
|
||||
//- i.fa.fa-thumbs-up.fa-fw
|
||||
|
||||
//- a.post-tool.post-unlike(id="unlike-" + post.ID, onclick=`$.unlike("${type.toLowerCase()}", "${post.ID}")`, title="Unlike", class=!liked ? "hidden" : ")
|
||||
//- i.fa.fa-thumbs-down.fa-fw
|
||||
|
||||
//- if type === "Posts" || type === "Threads"
|
||||
//- if user.ID === post.authorId
|
||||
//- a.post-tool.post-edit(onclick=`$.edit("${post.ID}")`, title="Edit")
|
||||
//- i.fa.fa-pencil.fa-fw
|
||||
|
||||
//- if type !== "Threads"
|
||||
//- a.post-tool.post-permalink.ajax(href="/" + type.toLowerCase() + "/" + post.ID, title="Permalink")
|
||||
//- i.fa.fa-link.fa-fw
|
||||
|
||||
//- if type === "Messages" && user && (user.ID === post.authorId || user.ID === post.recipientId)
|
||||
//- a.post-tool.post-delete(onclick=`if(confirm("Do you really want to delete this ${typeSingular.toLowerCase()} from ${post.author.nick}?")) $.delete${typeSingular}("${post.ID}")`, title="Delete")
|
||||
//- i.fa.fa-trash.fa-fw
|
17
router.go
17
router.go
@ -1,6 +1,8 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"sort"
|
||||
|
||||
"github.com/aerogo/aero"
|
||||
"github.com/animenotifier/arn"
|
||||
"github.com/animenotifier/notify.moe/components"
|
||||
@ -45,6 +47,8 @@ func init() {
|
||||
tag := ctx.Get("tag")
|
||||
threads, _ := arn.GetThreadsByTag(tag)
|
||||
|
||||
sort.Sort(threads)
|
||||
|
||||
if len(threads) > threadsPerPage {
|
||||
threads = threads[:threadsPerPage]
|
||||
}
|
||||
@ -58,4 +62,17 @@ func init() {
|
||||
|
||||
app.Ajax("/forum", forumHandler)
|
||||
app.Ajax("/forum/:tag", forumHandler)
|
||||
|
||||
app.Ajax("/threads/:id", func(ctx *aero.Context) string {
|
||||
id := ctx.Get("id")
|
||||
thread, err := arn.GetThread(id)
|
||||
|
||||
if err != nil {
|
||||
return ctx.Text("Thread not found")
|
||||
}
|
||||
|
||||
thread.Author, _ = arn.GetUser(thread.AuthorID)
|
||||
|
||||
return ctx.HTML(components.Thread(thread))
|
||||
})
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user