Improved activity overview

This commit is contained in:
Eduard Urbach 2019-08-30 10:02:22 +09:00
parent 17f734da1e
commit 4976e5ab35
Signed by: akyoto
GPG Key ID: C874F672B1AF20C0
6 changed files with 53 additions and 35 deletions

View File

@ -11,4 +11,4 @@ component Comments(parent arn.PostParent, user *arn.User)
//- p.no-data.mountable No comments have been written yet. //- p.no-data.mountable No comments have been written yet.
//- else //- else
each post in parent.PostsRelevantFirst(5) each post in parent.PostsRelevantFirst(5)
Postable(post, user, true, "") Postable(post, user, true, false, "")

View File

@ -1,5 +1,5 @@
component Postable(post arn.Postable, user *arn.User, includeReplies bool, highlightAuthorID string) component Postable(post arn.Postable, user *arn.User, includeReplies bool, showParent bool, highlightAuthorID string)
.post.mountable(id=strings.ToLower(post.TypeName()) + "-" + fmt.Sprint(post.GetID()), data-pro=post.Creator().IsPro(), data-api="/api/" + strings.ToLower(post.TypeName()) + "/" + post.GetID()) .post.mountable(id=fmt.Sprintf("%s-%s", strings.ToLower(post.TypeName()), post.GetID()), data-pro=post.Creator().IsPro(), data-api=fmt.Sprintf("/api/%s/%s", strings.ToLower(post.TypeName()), post.GetID()))
.post-parent .post-parent
.post-author .post-author
Avatar(post.Creator()) Avatar(post.Creator())
@ -9,6 +9,15 @@ component Postable(post arn.Postable, user *arn.User, includeReplies bool, highl
.post-creator .post-creator
a(href=post.Creator().Link())= post.Creator().Nick a(href=post.Creator().Link())= post.Creator().Nick
if showParent
if post.GetParentType() == "User"
if post.GetParentID() != post.Creator().ID
span to
a(href=post.Parent().Link())= post.Parent().TitleByUser(user)
else if post.GetParentType() != ""
span in
a(href=post.Parent().Link())= post.Parent().TitleByUser(user)
if user == nil || user.ID == post.Creator().ID if user == nil || user.ID == post.Creator().ID
//- Don't display a like icon. //- Don't display a like icon.
else if post.LikedBy(user.ID) else if post.LikedBy(user.ID)
@ -57,4 +66,4 @@ component Postable(post arn.Postable, user *arn.User, includeReplies bool, highl
.replies(id="replies-" + post.GetID()) .replies(id="replies-" + post.GetID())
if includeReplies if includeReplies
each reply in post.Posts() each reply in post.Posts()
Postable(reply, user, true, highlightAuthorID) Postable(reply, user, true, false, highlightAuthorID)

View File

@ -2,4 +2,4 @@ component PostableList(postables []arn.Postable, user *arn.User)
.thread .thread
.posts .posts
each post in postables each post in postables
Postable(post, user, false, "") Postable(post, user, false, false, "")

View File

@ -26,35 +26,43 @@ component ActivitiesScrollable(entries []arn.Activity, user *arn.User)
Activity(entry, user) Activity(entry, user)
component Activity(activity arn.Activity, user *arn.User) component Activity(activity arn.Activity, user *arn.User)
.activity.post-parent.mountable(id=fmt.Sprintf("activity-%s", activity.GetID()), data-api=utils.ActivityAPILink(activity)) if activity.TypeName() == "ActivityCreate"
.post-author ActivityCreate(activity.(*arn.ActivityCreate), user)
Avatar(activity.Creator()) else if activity.TypeName() == "ActivityConsumeAnime"
.post-content ActivityConsumeAnime(activity.(*arn.ActivityConsumeAnime), user)
.post-header
.post-creator
a(href=activity.Creator().Link())= activity.Creator().Nick
if activity.TypeName() == "ActivityCreate" //- .activity.post-parent.mountable(id=fmt.Sprintf("activity-%s", activity.GetID()), data-api=utils.ActivityAPILink(activity))
ActivityCreateMeta(activity.(*arn.ActivityCreate), user) //- .post-author
//- Avatar(activity.Creator())
//- .post-content
//- .post-header
//- .post-creator
//- a(href=activity.Creator().Link())= activity.Creator().Nick
if user != nil //- if activity.TypeName() == "ActivityCreate"
//- button.post-action.tip.action(data-action="like", data-trigger="click", aria-label="Like") //- ActivityCreateMeta(activity.(*arn.ActivityCreate), user)
//- Icon("heart")
//- if activity.TypeName() == "ActivityCreate"
//- span= activity.(*arn.ActivityCreate).Object().CountLikes()
//- else
//- span= len(activity.(*arn.ActivityConsumeAnime).Likes)
if user.ID == activity.GetCreatedBy() && activity.TypeName() == "ActivityConsumeAnime" //- if user != nil
button.post-action.tip.action(data-action="deleteObject", data-trigger="click", aria-label="Delete", data-return-path="/activity", data-confirm-type="activity") //- //- button.post-action.tip.action(data-action="like", data-trigger="click", aria-label="Like")
RawIcon("trash") //- //- Icon("heart")
//- //- if activity.TypeName() == "ActivityCreate"
//- //- span= activity.(*arn.ActivityCreate).Object().CountLikes()
//- //- else
//- //- span= len(activity.(*arn.ActivityConsumeAnime).Likes)
.post-date.utc-date(data-date=activity.GetCreated()) //- if user.ID == activity.GetCreatedBy() && activity.TypeName() == "ActivityConsumeAnime"
//- button.post-action.tip.action(data-action="deleteObject", data-trigger="click", aria-label="Delete", data-return-path="/activity", data-confirm-type="activity")
//- RawIcon("trash")
if activity.TypeName() == "ActivityCreate" //- .post-date.utc-date(data-date=activity.GetCreated())
ActivityCreateText(activity.(*arn.ActivityCreate), user)
else if activity.TypeName() == "ActivityConsumeAnime" //- if activity.TypeName() == "ActivityCreate"
ActivityConsumeAnimeText(activity.(*arn.ActivityConsumeAnime), user) //- ActivityCreateText(activity.(*arn.ActivityCreate), user)
//- else if activity.TypeName() == "ActivityConsumeAnime"
//- ActivityConsumeAnimeText(activity.(*arn.ActivityConsumeAnime), user)
component ActivityConsumeAnime(activity *arn.ActivityConsumeAnime, user *arn.User)
h1 TODO
component ActivityConsumeAnimeText(activity *arn.ActivityConsumeAnime, user *arn.User) component ActivityConsumeAnimeText(activity *arn.ActivityConsumeAnime, user *arn.User)
span watched span watched
@ -65,6 +73,9 @@ component ActivityConsumeAnimeText(activity *arn.ActivityConsumeAnime, user *arn
else else
span= fmt.Sprintf(" episode %d.", activity.ToEpisode) span= fmt.Sprintf(" episode %d.", activity.ToEpisode)
component ActivityCreate(activity *arn.ActivityCreate, user *arn.User)
Postable(activity.Postable(), user, false, true, "")
component ActivityCreateMeta(activity *arn.ActivityCreate, user *arn.User) component ActivityCreateMeta(activity *arn.ActivityCreate, user *arn.User)
if activity.ObjectType == "Post" if activity.ObjectType == "Post"
if activity.Postable().GetParentType() != "User" if activity.Postable().GetParentType() != "User"

View File

@ -1,11 +1,9 @@
component Post(post *arn.Post, user *arn.User) component Post(post *arn.Post, user *arn.User)
.thread .thread
.posts .posts
Postable(post, user, true, "") Postable(post, user, true, true, "")
.side-note-container.mountable if user != nil && user.Role == "admin"
if user != nil && user.Role == "admin" .side-note-container.mountable
a.side-note.tip(href=post.Link() + "/edit", aria-label="Admin Edit") a.side-note.tip(href=post.Link() + "/edit", aria-label="Admin Edit")
Icon("edit") Icon("edit")
a.side-note(href=post.Parent().Link())= post.Parent().TitleByUser(user)

View File

@ -3,7 +3,7 @@ component Thread(thread *arn.Thread, user *arn.User)
#thread.thread(data-id=thread.ID) #thread.thread(data-id=thread.ID)
.posts .posts
Postable(thread, user, true, thread.Creator().ID) Postable(thread, user, true, false, thread.Creator().ID)
//- Reply //- Reply
if user != nil if user != nil