Added activity feed

This commit is contained in:
Eduard Urbach 2018-10-31 14:27:48 +09:00
parent 8e1578f2cb
commit 97c8f99499
14 changed files with 93 additions and 19 deletions

View File

@ -30,10 +30,10 @@ component Sidebar(user *arn.User)
SidebarButton("Home", "/+" + user.Nick + "/animelist/watching", "home")
else
SidebarButton("Home", "/", "home")
SidebarButton("Activity", "/activity", "rss")
SidebarButton("Forum", "/forum", "comment")
SidebarButton("Explore", "/explore", "th")
SidebarButton("Calendar", "/calendar", "calendar")
SidebarButton("AMVs", "/amvs", "video-camera")
SidebarButton("Soundtracks", "/soundtracks", "headphones")
SidebarButton("Quotes", "/quotes", "quote-left")

View File

@ -5,7 +5,7 @@ component Comments(parent arn.PostParent, user *arn.User)
p.no-data.mountable No comments have been written yet.
else
each post in parent.Posts()
Postable(post.ToPostable(), user, "")
Postable(post.ToPostable(), user, "", "")
if user != nil
if parent.IsLocked()

View File

@ -1,12 +1,12 @@
component Postable(post arn.Postable, user *arn.User, highlightAuthorID string)
component Postable(post arn.Postable, user *arn.User, headerContent string, highlightAuthorID string)
.post.mountable(id=strings.ToLower(post.Type()) + "-" + fmt.Sprint(post.ID()), data-highlight=post.Creator().ID == highlightAuthorID, data-pro=post.Creator().IsPro(), data-api="/api/" + strings.ToLower(post.Type()) + "/" + post.ID())
.post-author
Avatar(post.Creator())
//- if post.recipient && post.recipient.ID !== post.author.ID
//- a.user.post-recipient(href="/+" + post.recipient.nick, title=post.recipient.nick)
//- img.user-image(src=post.recipient.avatar ? (post.recipient.avatar + "?s=100&r=x&d=mm") : "/images/elements/no-gravatar.svg", alt=post.recipient.nick)
.post-content
if headerContent != ""
div!= headerContent
div(id="render-" + post.ID())!= post.HTML()
if user != nil && user.ID == post.Creator().ID

View File

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

View File

@ -0,0 +1,34 @@
package activity
import (
"github.com/aerogo/aero"
"github.com/animenotifier/arn"
"github.com/animenotifier/notify.moe/components"
"github.com/animenotifier/notify.moe/utils"
)
const maxActivitiesPerPage = 40
// Get activity page.
func Get(ctx *aero.Context) string {
user := utils.GetUser(ctx)
// posts := arn.AllPosts()
// arn.SortPostsLatestFirst(posts)
// posts := arn.FilterPosts(func(post *arn.Post) bool {
// return post.
// })
entries := arn.FilterEditLogEntries(func(entry *arn.EditLogEntry) bool {
return entry.Action == "create" && entry.ObjectType == "Post" && entry.Object() != nil
})
arn.SortEditLogEntriesLatestFirst(entries)
if len(entries) > maxActivitiesPerPage {
entries = entries[:maxActivitiesPerPage]
}
return ctx.HTML(components.ActivityFeed(entries, user))
}

View File

@ -1,2 +1,16 @@
component ActivityFeed
h1 Hello
component ActivityFeed(entries []*arn.EditLogEntry, user *arn.User)
h1 Activity
.activities
each entry in entries
if entry.ObjectType == "Post"
.activity
ActivityPost(entry.Object().(*arn.Post), user)
component ActivityPost(post *arn.Post, user *arn.User)
//- .activity-header.mountable
//- a(href=post.Creator().Link())= post.Creator().Nick
//- span commented on
//- a(href=post.Parent().Link())= post.Parent().TitleByUser(user)
Postable(post.ToPostable(), user, fmt.Sprintf(`<p class="activity-header"><a href="%s">%s</a></p>`, post.Parent().Link(), post.Parent().TitleByUser(user)), "")

View File

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

View File

@ -7,6 +7,9 @@ component ExploreAnime(animes []*arn.Anime, year string, season string, status s
button.action(data-trigger="click", data-action="toggleHideAddedAnime", title="Hide anime in my collection")
RawIcon("eye-slash")
a.button(href="/calendar", title="Calendar")
RawIcon("calendar")
a.button(href="/halloffame", title="Hall of Fame")
RawIcon("trophy")

View File

@ -1,6 +1,6 @@
component HallOfFame(entries []*utils.HallOfFameEntry, user *arn.User)
h1.hall-of-fame-page-title Hall of Fame
.footer Best TV series for each year.
.footer Most popular TV series for each year.
.hall-of-fame
each entry in entries

View File

@ -2,6 +2,7 @@ package coreroutes
import (
"github.com/aerogo/layout"
"github.com/animenotifier/notify.moe/pages/activity"
"github.com/animenotifier/notify.moe/pages/calendar"
"github.com/animenotifier/notify.moe/pages/embed"
"github.com/animenotifier/notify.moe/pages/home"
@ -18,6 +19,9 @@ func Register(l *layout.Layout) {
// Login
l.Page("/login", login.Get)
// Activity
l.Page("/activity", activity.Get)
// Calendar
l.Page("/calendar", calendar.Get)

View File

@ -1,7 +1,7 @@
component Post(post *arn.Post, user *arn.User)
.thread
.posts
Postable(post.ToPostable(), user, "")
Postable(post.ToPostable(), user, "", "")
.side-note.mountable
a(href=post.Parent().Link())= post.Parent().TitleByUser(user)
.side-note-container.mountable
a.side-note(href=post.Parent().Link())= post.Parent().TitleByUser(user)

View File

@ -1,3 +1,6 @@
.side-note-container
horizontal
justify-content flex-end
.side-note
font-size 0.9rem
text-align right !important
font-size 0.9rem

View File

@ -79,7 +79,7 @@ component ProfileHead(viewUser *arn.User, user *arn.User, uri string)
//- span= viewUser.Accounts.FinalFantasyXIV.Class
if viewUser.Registered != ""
.profile-tag.tip.mountable.never-unmount(aria-label="Member since", data-mountable-type="header")
.profile-tag.mountable.never-unmount(title="Member since", data-mountable-type="header")
Icon("calendar")
span= viewUser.RegisteredTime().Format("Jan 2006")
@ -92,6 +92,11 @@ component ProfileHead(viewUser *arn.User, user *arn.User, uri string)
a.profile-tag.mountable.never-unmount(href="/users/staff", aria-label="Staff member", data-mountable-type="header")
Icon("rocket")
span= stringutils.Capitalize(viewUser.Role)
if !viewUser.IsActive()
.profile-tag.mountable.never-unmount(title="Hasn't been online for the past 2 weeks", data-mountable-type="header")
Icon("bed")
span Inactive
//- if user != nil && user.ID != viewUser.ID
//- a.button.profile-action(href="/compare/animelist/" + user.Nick + "/" + viewUser.Nick)

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(), user, thread.Creator().ID)
Postable(thread.ToPostable(), user, "", thread.Creator().ID)
each post in posts
Postable(post.ToPostable(), user, thread.Creator().ID)
Postable(post.ToPostable(), user, "", thread.Creator().ID)
//- Reply
if user != nil