Added soundtrack comments

This commit is contained in:
Eduard Urbach 2018-10-29 11:30:23 +09:00
parent f4f1531b8b
commit ecceb415ca
7 changed files with 41 additions and 19 deletions

View File

@ -3,4 +3,4 @@ component NewPostArea(user *arn.User, placeholder string)
.post-author
Avatar(user)
textarea#new-reply.post-content(placeholder=placeholder + "...", aria-label=placeholder)
textarea#new-post.post-content(placeholder=placeholder + "...", aria-label=placeholder)

View File

@ -90,9 +90,10 @@ func Forum(ctx *aero.Context) string {
func SoundTracks(ctx *aero.Context) string {
term := ctx.Get("term")
term = strings.TrimPrefix(term, "/")
user := utils.GetUser(ctx)
tracks := search.SoundTracks(term, maxSoundTracks)
return ctx.HTML(components.SoundTrackSearchResults(tracks))
return ctx.HTML(components.SoundTrackSearchResults(tracks, user))
}
// Users search.

View File

@ -32,7 +32,7 @@ component SearchResults(term string, users []*arn.User, animes []*arn.Anime, pos
span Soundtracks
#soundtrack-search-results
SoundTrackSearchResults(tracks)
SoundTrackSearchResults(tracks, user)
//- .widget
//- h3.widget-title
@ -97,14 +97,14 @@ component ForumSearchResults(posts []*arn.Post, threads []*arn.Thread, user *arn
.forum-search-result-author= post.Creator().Nick
.forum-search-result-sample= post.Text
component SoundTrackSearchResults(tracks []*arn.SoundTrack)
component SoundTrackSearchResults(tracks []*arn.SoundTrack, user *arn.User)
if len(tracks) == 0
p.no-search-results.mountable No soundtracks found.
else
ul.soundtrack-search
each track in tracks
li.mountable(data-mountable-type="track")
a(href=track.Link())= track.Title.ByUser(nil)
a(href=track.Link())= track.Title.ByUser(user)
span.soundtrack-search-anime= " - " + track.MainAnime().Title.Canonical
component CompanySearchResults(companies []*arn.Company)

View File

@ -20,5 +20,10 @@ func Get(ctx *aero.Context) string {
}
ctx.Data = getOpenGraph(ctx, track)
return ctx.HTML(components.SoundTrackPage(track, user))
// Comments
posts := track.Posts()
arn.SortPostsLatestFirst(posts)
return ctx.HTML(components.SoundTrackPage(track, posts, user))
}

View File

@ -1,4 +1,4 @@
component SoundTrackPage(track *arn.SoundTrack, user *arn.User)
component SoundTrackPage(track *arn.SoundTrack, posts []*arn.Post, user *arn.User)
SoundTrackTabs(track, user)
.soundtrack-full-page
@ -55,6 +55,27 @@ component SoundTrackPage(track *arn.SoundTrack, user *arn.User)
.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
.footer.mountable
if track.EditedBy != ""

View File

@ -18,7 +18,7 @@ component Thread(thread *arn.Thread, posts []*arn.Post, user *arn.User)
.buttons
if !thread.Locked
button.mountable.action(data-action="forumReply", data-trigger="click")
button.mountable.action(data-action="createPost", data-trigger="click", data-parent-type="Thread", data-parent-id=thread.ID)
Icon("mail-reply")
span Reply

View File

@ -56,15 +56,15 @@ export function deletePost(arn: AnimeNotifier, element: HTMLElement) {
.catch(err => arn.statusMessage.showError(err))
}
// Forum reply
export function forumReply(arn: AnimeNotifier) {
let textarea = document.getElementById("new-reply") as HTMLTextAreaElement
let thread = document.getElementById("thread")
// Create post
export function createPost(arn: AnimeNotifier, element: HTMLElement) {
let textarea = document.getElementById("new-post") as HTMLTextAreaElement
let {parentId, parentType} = element.dataset
let post = {
text: textarea.value,
parentId: thread.dataset.id,
parentType: "Thread",
parentId,
parentType,
tags: []
}
@ -74,11 +74,6 @@ export function forumReply(arn: AnimeNotifier) {
.catch(err => arn.statusMessage.showError(err))
}
// Group post
export function newGroupPost(arn: AnimeNotifier) {
// TODO: ...
}
// Create thread
export function createThread(arn: AnimeNotifier) {
let title = document.getElementById("title") as HTMLInputElement