diff --git a/mixins/Comments.pixy b/mixins/Comments.pixy new file mode 100644 index 00000000..8f760c5c --- /dev/null +++ b/mixins/Comments.pixy @@ -0,0 +1,18 @@ +component Comments(parent arn.PostParent, user *arn.User) + .thread + .posts + each post in parent.Posts() + Postable(post.ToPostable(), user, "") + + if user != nil + if parent.IsLocked() + footer.footer.mountable + p.text-center= "This " + strings.ToLower(reflect.TypeOf(parent).Elem().Name()) + " is locked." + else + NewPostArea(user, "Comment") + + .buttons + if !parent.IsLocked() + button.mountable.action(data-action="createPost", data-trigger="click", data-parent-type=reflect.TypeOf(parent).Elem().Name(), data-parent-id=parent.GetID()) + Icon("mail-reply") + span Reply \ No newline at end of file diff --git a/pages/soundtrack/soundtrack.go b/pages/soundtrack/soundtrack.go index 81fa63cf..de1cdc80 100644 --- a/pages/soundtrack/soundtrack.go +++ b/pages/soundtrack/soundtrack.go @@ -20,10 +20,5 @@ func Get(ctx *aero.Context) string { } ctx.Data = getOpenGraph(ctx, track) - - // Comments - posts := track.Posts() - arn.SortPostsLatestFirst(posts) - - return ctx.HTML(components.SoundTrackPage(track, posts, user)) + return ctx.HTML(components.SoundTrackPage(track, user)) } diff --git a/pages/soundtrack/soundtrack.pixy b/pages/soundtrack/soundtrack.pixy index 819429f2..8fd5dc09 100644 --- a/pages/soundtrack/soundtrack.pixy +++ b/pages/soundtrack/soundtrack.pixy @@ -1,4 +1,4 @@ -component SoundTrackPage(track *arn.SoundTrack, posts []*arn.Post, user *arn.User) +component SoundTrackPage(track *arn.SoundTrack, user *arn.User) SoundTrackTabs(track, user) .soundtrack-full-page @@ -55,27 +55,10 @@ component SoundTrackPage(track *arn.SoundTrack, posts []*arn.Post, user *arn.Use .tags each tag in track.Tags a.tag(href="/soundtracks/tag/" + tag)= tag - + .widget.mountable h3.widget-title Comments - - .thread - .posts - each post in posts - Postable(post.ToPostable(), user, "") - - if user != nil - if track.Locked - footer.footer.mountable - p.text-center This soundtrack is locked. - else - NewPostArea(user, "Comment") - - .buttons - if !track.Locked - button.mountable.action(data-action="createPost", data-trigger="click", data-parent-type="SoundTrack", data-parent-id=track.ID) - Icon("mail-reply") - span Reply + Comments(track, user) .footer.mountable if track.EditedBy != ""