Added forum post editing

This commit is contained in:
2017-07-06 16:54:10 +02:00
parent 9de86a83f9
commit 5070600964
13 changed files with 139 additions and 78 deletions

View File

@ -6,16 +6,18 @@ import (
"github.com/aerogo/aero"
"github.com/animenotifier/arn"
"github.com/animenotifier/notify.moe/components"
"github.com/animenotifier/notify.moe/utils"
)
// Get post.
func Get(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.Post(post))
return ctx.HTML(components.Post(post, user))
}

View File

@ -1,5 +1,5 @@
component Post(post *arn.Post)
Postable(post.ToPostable(), "")
component Post(post *arn.Post, user *arn.User)
Postable(post.ToPostable(), user, "")
.side-note
a.ajax(href=post.Thread().Link())= post.Thread().Title

View File

@ -3,6 +3,6 @@ component LatestPosts(postables []arn.Postable, viewUser *arn.User, user *arn.Us
if len(postables) > 0
h2.page-title= len(postables), " latest posts by ", postables[0].Author().Nick
PostableList(postables)
PostableList(postables, user)
else
p.no-data.mountable= viewUser.Nick + " hasn't written any posts yet."

View File

@ -3,10 +3,10 @@ component Thread(thread *arn.Thread, posts []*arn.Post, user *arn.User)
#thread.thread(data-id=thread.ID)
.posts
Postable(thread.ToPostable(), thread.Author().ID)
Postable(thread.ToPostable(), user, thread.Author().ID)
each post in posts
Postable(post.ToPostable(), thread.Author().ID)
Postable(post.ToPostable(), user, thread.Author().ID)
// Reply
if user != nil