Added activity feed
This commit is contained in:
parent
8e1578f2cb
commit
97c8f99499
@ -30,10 +30,10 @@ component Sidebar(user *arn.User)
|
|||||||
SidebarButton("Home", "/+" + user.Nick + "/animelist/watching", "home")
|
SidebarButton("Home", "/+" + user.Nick + "/animelist/watching", "home")
|
||||||
else
|
else
|
||||||
SidebarButton("Home", "/", "home")
|
SidebarButton("Home", "/", "home")
|
||||||
|
|
||||||
|
SidebarButton("Activity", "/activity", "rss")
|
||||||
SidebarButton("Forum", "/forum", "comment")
|
SidebarButton("Forum", "/forum", "comment")
|
||||||
SidebarButton("Explore", "/explore", "th")
|
SidebarButton("Explore", "/explore", "th")
|
||||||
SidebarButton("Calendar", "/calendar", "calendar")
|
|
||||||
SidebarButton("AMVs", "/amvs", "video-camera")
|
SidebarButton("AMVs", "/amvs", "video-camera")
|
||||||
SidebarButton("Soundtracks", "/soundtracks", "headphones")
|
SidebarButton("Soundtracks", "/soundtracks", "headphones")
|
||||||
SidebarButton("Quotes", "/quotes", "quote-left")
|
SidebarButton("Quotes", "/quotes", "quote-left")
|
||||||
|
@ -5,7 +5,7 @@ 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.Posts()
|
each post in parent.Posts()
|
||||||
Postable(post.ToPostable(), user, "")
|
Postable(post.ToPostable(), user, "", "")
|
||||||
|
|
||||||
if user != nil
|
if user != nil
|
||||||
if parent.IsLocked()
|
if parent.IsLocked()
|
||||||
|
@ -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.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
|
.post-author
|
||||||
Avatar(post.Creator())
|
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
|
.post-content
|
||||||
|
if headerContent != ""
|
||||||
|
div!= headerContent
|
||||||
|
|
||||||
div(id="render-" + post.ID())!= post.HTML()
|
div(id="render-" + post.ID())!= post.HTML()
|
||||||
|
|
||||||
if user != nil && user.ID == post.Creator().ID
|
if user != nil && user.ID == post.Creator().ID
|
||||||
|
@ -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, "")
|
Postable(post, user, "", "")
|
||||||
|
34
pages/activity/activity.go
Normal file
34
pages/activity/activity.go
Normal 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))
|
||||||
|
}
|
@ -1,2 +1,16 @@
|
|||||||
component ActivityFeed
|
component ActivityFeed(entries []*arn.EditLogEntry, user *arn.User)
|
||||||
h1 Hello
|
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)), "")
|
11
pages/activity/activity.scarlet
Normal file
11
pages/activity/activity.scarlet
Normal 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
|
@ -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")
|
button.action(data-trigger="click", data-action="toggleHideAddedAnime", title="Hide anime in my collection")
|
||||||
RawIcon("eye-slash")
|
RawIcon("eye-slash")
|
||||||
|
|
||||||
|
a.button(href="/calendar", title="Calendar")
|
||||||
|
RawIcon("calendar")
|
||||||
|
|
||||||
a.button(href="/halloffame", title="Hall of Fame")
|
a.button(href="/halloffame", title="Hall of Fame")
|
||||||
RawIcon("trophy")
|
RawIcon("trophy")
|
||||||
|
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
component HallOfFame(entries []*utils.HallOfFameEntry, user *arn.User)
|
component HallOfFame(entries []*utils.HallOfFameEntry, user *arn.User)
|
||||||
h1.hall-of-fame-page-title Hall of Fame
|
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
|
.hall-of-fame
|
||||||
each entry in entries
|
each entry in entries
|
||||||
|
@ -2,6 +2,7 @@ package coreroutes
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/aerogo/layout"
|
"github.com/aerogo/layout"
|
||||||
|
"github.com/animenotifier/notify.moe/pages/activity"
|
||||||
"github.com/animenotifier/notify.moe/pages/calendar"
|
"github.com/animenotifier/notify.moe/pages/calendar"
|
||||||
"github.com/animenotifier/notify.moe/pages/embed"
|
"github.com/animenotifier/notify.moe/pages/embed"
|
||||||
"github.com/animenotifier/notify.moe/pages/home"
|
"github.com/animenotifier/notify.moe/pages/home"
|
||||||
@ -18,6 +19,9 @@ func Register(l *layout.Layout) {
|
|||||||
// Login
|
// Login
|
||||||
l.Page("/login", login.Get)
|
l.Page("/login", login.Get)
|
||||||
|
|
||||||
|
// Activity
|
||||||
|
l.Page("/activity", activity.Get)
|
||||||
|
|
||||||
// Calendar
|
// Calendar
|
||||||
l.Page("/calendar", calendar.Get)
|
l.Page("/calendar", calendar.Get)
|
||||||
|
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
component Post(post *arn.Post, user *arn.User)
|
component Post(post *arn.Post, user *arn.User)
|
||||||
.thread
|
.thread
|
||||||
.posts
|
.posts
|
||||||
Postable(post.ToPostable(), user, "")
|
Postable(post.ToPostable(), user, "", "")
|
||||||
|
|
||||||
.side-note.mountable
|
.side-note-container.mountable
|
||||||
a(href=post.Parent().Link())= post.Parent().TitleByUser(user)
|
a.side-note(href=post.Parent().Link())= post.Parent().TitleByUser(user)
|
||||||
|
@ -1,3 +1,6 @@
|
|||||||
|
.side-note-container
|
||||||
|
horizontal
|
||||||
|
justify-content flex-end
|
||||||
|
|
||||||
.side-note
|
.side-note
|
||||||
font-size 0.9rem
|
font-size 0.9rem
|
||||||
text-align right !important
|
|
@ -79,7 +79,7 @@ component ProfileHead(viewUser *arn.User, user *arn.User, uri string)
|
|||||||
//- span= viewUser.Accounts.FinalFantasyXIV.Class
|
//- span= viewUser.Accounts.FinalFantasyXIV.Class
|
||||||
|
|
||||||
if viewUser.Registered != ""
|
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")
|
Icon("calendar")
|
||||||
span= viewUser.RegisteredTime().Format("Jan 2006")
|
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")
|
a.profile-tag.mountable.never-unmount(href="/users/staff", aria-label="Staff member", data-mountable-type="header")
|
||||||
Icon("rocket")
|
Icon("rocket")
|
||||||
span= stringutils.Capitalize(viewUser.Role)
|
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
|
//- if user != nil && user.ID != viewUser.ID
|
||||||
//- a.button.profile-action(href="/compare/animelist/" + user.Nick + "/" + viewUser.Nick)
|
//- a.button.profile-action(href="/compare/animelist/" + user.Nick + "/" + viewUser.Nick)
|
||||||
|
@ -3,10 +3,10 @@ component Thread(thread *arn.Thread, posts []*arn.Post, user *arn.User)
|
|||||||
|
|
||||||
#thread.thread(data-id=thread.ID)
|
#thread.thread(data-id=thread.ID)
|
||||||
.posts
|
.posts
|
||||||
Postable(thread.ToPostable(), user, thread.Creator().ID)
|
Postable(thread.ToPostable(), user, "", thread.Creator().ID)
|
||||||
|
|
||||||
each post in posts
|
each post in posts
|
||||||
Postable(post.ToPostable(), user, thread.Creator().ID)
|
Postable(post.ToPostable(), user, "", thread.Creator().ID)
|
||||||
|
|
||||||
//- Reply
|
//- Reply
|
||||||
if user != nil
|
if user != nil
|
||||||
|
Loading…
Reference in New Issue
Block a user