Editors can now lock threads
This commit is contained in:
36
pages/thread/thread.go
Normal file
36
pages/thread/thread.go
Normal file
@ -0,0 +1,36 @@
|
||||
package thread
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
|
||||
"github.com/aerogo/aero"
|
||||
"github.com/animenotifier/arn"
|
||||
"github.com/animenotifier/notify.moe/components"
|
||||
"github.com/animenotifier/notify.moe/utils"
|
||||
)
|
||||
|
||||
// Get thread.
|
||||
func Get(ctx *aero.Context) string {
|
||||
id := ctx.Get("id")
|
||||
user := utils.GetUser(ctx)
|
||||
|
||||
// Fetch thread
|
||||
thread, err := arn.GetThread(id)
|
||||
|
||||
if err != nil {
|
||||
return ctx.Error(http.StatusNotFound, "Thread not found", err)
|
||||
}
|
||||
|
||||
// Fetch posts
|
||||
postObjects := arn.DB.GetMany("Post", thread.Posts)
|
||||
posts := make([]*arn.Post, len(postObjects), len(postObjects))
|
||||
|
||||
for i, obj := range postObjects {
|
||||
posts[i] = obj.(*arn.Post)
|
||||
}
|
||||
|
||||
// Sort posts
|
||||
arn.SortPostsLatestLast(posts)
|
||||
|
||||
return ctx.HTML(components.Thread(thread, posts, user))
|
||||
}
|
37
pages/thread/thread.pixy
Normal file
37
pages/thread/thread.pixy
Normal file
@ -0,0 +1,37 @@
|
||||
component Thread(thread *arn.Thread, posts []*arn.Post, user *arn.User)
|
||||
h1.thread-title= thread.Title
|
||||
|
||||
#thread.thread(data-id=thread.ID)
|
||||
.posts
|
||||
Postable(thread.ToPostable(), user, thread.Creator().ID)
|
||||
|
||||
each post in posts
|
||||
Postable(post.ToPostable(), user, thread.Creator().ID)
|
||||
|
||||
//- Reply
|
||||
if user != nil
|
||||
if thread.Locked
|
||||
footer.footer.mountable
|
||||
p.text-center This topic is locked.
|
||||
else
|
||||
NewPostArea(user, "Reply")
|
||||
|
||||
.buttons
|
||||
if !thread.Locked
|
||||
button.mountable.action(data-action="forumReply", data-trigger="click")
|
||||
Icon("mail-reply")
|
||||
span Reply
|
||||
|
||||
if user.Role == "admin" || user.Role == "editor"
|
||||
if thread.Locked
|
||||
button.mountable.action(data-action="unlockThread", data-trigger="click", data-api="/api/thread/" + thread.ID)
|
||||
Icon("unlock")
|
||||
span Unlock
|
||||
else
|
||||
button.mountable.action(data-action="lockThread", data-trigger="click", data-api="/api/thread/" + thread.ID)
|
||||
Icon("lock")
|
||||
span Lock
|
||||
|
||||
button.mountable.action(data-action="deleteObject", data-trigger="click", data-return-path="/forum", data-confirm-type="thread", data-api="/api/thread/" + thread.ID)
|
||||
Icon("trash")
|
||||
span Delete
|
31
pages/thread/thread.scarlet
Normal file
31
pages/thread/thread.scarlet
Normal file
@ -0,0 +1,31 @@
|
||||
.thread
|
||||
horizontal
|
||||
justify-content center
|
||||
|
||||
.posts
|
||||
vertical
|
||||
width 100%
|
||||
max-width forum-width
|
||||
|
||||
.post
|
||||
vertical
|
||||
margin-bottom 1.75rem
|
||||
|
||||
.post-author
|
||||
margin-bottom 0.25rem
|
||||
|
||||
[data-highlight="true"]
|
||||
.post-content
|
||||
border 2px solid post-highlight-color
|
||||
|
||||
// [data-pro="true"]
|
||||
// .post-content
|
||||
// border 2px solid pro-color
|
||||
|
||||
> 600px
|
||||
.post
|
||||
horizontal
|
||||
margin-bottom 0.75rem
|
||||
|
||||
.post-author
|
||||
margin-bottom 0
|
Reference in New Issue
Block a user