Threaded comments (Reply UI)

This commit is contained in:
2018-11-05 20:57:37 +09:00
parent 08497f0c37
commit 960b1e4b92
14 changed files with 133 additions and 46 deletions

View File

@ -3,8 +3,7 @@ component ActivityFeed(entries []*arn.EditLogEntry, user *arn.User)
.activities
each entry in entries
.activity
ActivityPost(entry.Object().(arn.Postable), user)
ActivityPost(entry.Object().(arn.Postable), user)
component ActivityPost(post arn.Postable, user *arn.User)
if post.Parent() != nil

View File

@ -2,10 +2,4 @@
vertical
width 100%
max-width forum-width
margin 0 auto
// .activity
// margin-bottom 1rem
.activity-header
font-size 0.9rem
margin 0 auto

View File

@ -3,6 +3,9 @@ package apiroutes
import (
"strings"
"github.com/animenotifier/notify.moe/pages/post"
"github.com/animenotifier/notify.moe/pages/thread"
"github.com/aerogo/aero"
"github.com/aerogo/layout"
@ -39,6 +42,12 @@ func Register(l *layout.Layout, app *aero.Application) {
app.Get("/api/next/soundtrack", soundtrack.Next)
app.Get("/api/character/:id/ranking", character.Ranking)
// Thread
app.Get("/api/thread/:id/reply/ui", thread.ReplyUI)
// Post
app.Get("/api/post/:id/reply/ui", post.ReplyUI)
// SoundTrack
app.Post("/api/soundtrack/:id/download", soundtrack.Download)

View File

@ -1,13 +0,0 @@
package post
import (
"github.com/aerogo/aero"
"github.com/animenotifier/notify.moe/components"
"github.com/animenotifier/notify.moe/utils"
)
// NewPostArea renders a new post area.
func NewPostArea(ctx *aero.Context) string {
user := utils.GetUser(ctx)
return ctx.HTML(components.NewPostArea(user, "Reply"))
}

23
pages/post/reply-ui.go Normal file
View File

@ -0,0 +1,23 @@
package post
import (
"net/http"
"github.com/aerogo/aero"
"github.com/animenotifier/arn"
"github.com/animenotifier/notify.moe/components"
"github.com/animenotifier/notify.moe/utils"
)
// ReplyUI renders a new post area.
func ReplyUI(ctx *aero.Context) string {
id := ctx.Get("id")
user := utils.GetUser(ctx)
post, err := arn.GetPost(id)
if err != nil {
return ctx.Error(http.StatusNotFound, "Post not found", err)
}
return ctx.HTML(components.NewPostArea(user, "Reply") + components.NewPostActions(post.Type(), post.ID))
}

23
pages/thread/reply-ui.go Normal file
View File

@ -0,0 +1,23 @@
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"
)
// ReplyUI renders a new post area.
func ReplyUI(ctx *aero.Context) string {
id := ctx.Get("id")
user := utils.GetUser(ctx)
thread, err := arn.GetThread(id)
if err != nil {
return ctx.Error(http.StatusNotFound, "Thread not found", err)
}
return ctx.HTML(components.NewPostArea(user, "Reply") + components.NewPostActions(thread.Type(), thread.ID))
}

View File

@ -15,9 +15,7 @@ component Thread(thread *arn.Thread, user *arn.User)
.buttons
if !thread.Locked
button.mountable.action(data-action="createPost", data-trigger="click", data-parent-type="Thread", data-parent-id=thread.ID)
Icon("mail-reply")
span Reply
NewPostActions("Thread", thread.ID)
if user.Role == "admin" || user.Role == "editor"
if thread.Locked

View File

@ -11,6 +11,9 @@
vertical
margin-bottom 1.75rem
:last-child
margin-bottom 0
.post-author
margin-bottom 0.25rem
@ -25,9 +28,12 @@
margin-top 0.75rem
margin-left content-padding
:empty
margin-top 0
> 600px
.post
margin-bottom 0
margin-bottom 0.75rem
.post-author
margin-bottom 0