Added route showing all notifications
This commit is contained in:
parent
40ea58dffe
commit
700bf089bf
@ -144,7 +144,8 @@ func Configure(app *aero.Application) {
|
|||||||
l.Page("/group/:id/forum", group.Forum)
|
l.Page("/group/:id/forum", group.Forum)
|
||||||
|
|
||||||
// Notifications
|
// Notifications
|
||||||
l.Page("/notifications", notifications.All)
|
l.Page("/notifications", notifications.ByUser)
|
||||||
|
l.Page("/notifications/all", notifications.All)
|
||||||
|
|
||||||
// User profiles
|
// User profiles
|
||||||
l.Page("/user", user.Get)
|
l.Page("/user", user.Get)
|
||||||
@ -162,7 +163,7 @@ func Configure(app *aero.Application) {
|
|||||||
l.Page("/user/:nick/animelist/dropped", animelist.FilterByStatus(arn.AnimeListStatusDropped))
|
l.Page("/user/:nick/animelist/dropped", animelist.FilterByStatus(arn.AnimeListStatusDropped))
|
||||||
l.Page("/user/:nick/animelist/anime/:id", animelistitem.Get)
|
l.Page("/user/:nick/animelist/anime/:id", animelistitem.Get)
|
||||||
l.Page("/user/:nick/recommended/anime", recommended.Anime)
|
l.Page("/user/:nick/recommended/anime", recommended.Anime)
|
||||||
l.Page("/user/:nick/notifications", notifications.All)
|
l.Page("/user/:nick/notifications", notifications.ByUser)
|
||||||
|
|
||||||
// Anime list
|
// Anime list
|
||||||
l.Page("/animelist/watching", home.FilterByStatus(arn.AnimeListStatusWatching))
|
l.Page("/animelist/watching", home.FilterByStatus(arn.AnimeListStatusWatching))
|
||||||
|
@ -13,8 +13,8 @@ import (
|
|||||||
|
|
||||||
const maxNotifications = 30
|
const maxNotifications = 30
|
||||||
|
|
||||||
// All shows all notifications sent so far.
|
// ByUser shows all notifications sent to the given user.
|
||||||
func All(ctx *aero.Context) string {
|
func ByUser(ctx *aero.Context) string {
|
||||||
user := utils.GetUser(ctx)
|
user := utils.GetUser(ctx)
|
||||||
|
|
||||||
if user == nil {
|
if user == nil {
|
||||||
@ -44,3 +44,24 @@ func All(ctx *aero.Context) string {
|
|||||||
|
|
||||||
return ctx.HTML(components.Notifications(notifications, viewUser, user))
|
return ctx.HTML(components.Notifications(notifications, viewUser, user))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// All shows all notifications.
|
||||||
|
func All(ctx *aero.Context) string {
|
||||||
|
notifications, err := arn.AllNotifications()
|
||||||
|
|
||||||
|
if err != nil {
|
||||||
|
return ctx.Error(http.StatusInternalServerError, "Could not retrieve notification list", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Sort by date
|
||||||
|
sort.Slice(notifications, func(i, j int) bool {
|
||||||
|
return notifications[i].Created > notifications[j].Created
|
||||||
|
})
|
||||||
|
|
||||||
|
// Limit results
|
||||||
|
if len(notifications) > maxNotifications {
|
||||||
|
notifications = notifications[:maxNotifications]
|
||||||
|
}
|
||||||
|
|
||||||
|
return ctx.HTML(components.AllNotifications(notifications))
|
||||||
|
}
|
||||||
|
@ -12,6 +12,17 @@ component Notifications(notifications []*arn.Notification, viewUser *arn.User, u
|
|||||||
each notification in notifications
|
each notification in notifications
|
||||||
Notification(notification)
|
Notification(notification)
|
||||||
|
|
||||||
|
component AllNotifications(notifications []*arn.Notification)
|
||||||
|
h1 All notifications
|
||||||
|
|
||||||
|
.notifications-container
|
||||||
|
.notifications
|
||||||
|
each notification in notifications
|
||||||
|
Notification(notification)
|
||||||
|
|
||||||
|
.notification-user
|
||||||
|
a.ajax(href=notification.User().Link())= notification.User().Nick
|
||||||
|
|
||||||
component Notification(notification *arn.Notification)
|
component Notification(notification *arn.Notification)
|
||||||
a.notification(href=notification.Link, target="_blank", data-seen=notification.Seen)
|
a.notification(href=notification.Link, target="_blank", data-seen=notification.Seen)
|
||||||
.notification-icon
|
.notification-icon
|
||||||
@ -19,6 +30,7 @@ component Notification(notification *arn.Notification)
|
|||||||
|
|
||||||
.notification-info
|
.notification-info
|
||||||
h3.notification-title= notification.Title
|
h3.notification-title= notification.Title
|
||||||
|
|
||||||
.notification-footer
|
.notification-footer
|
||||||
p.notification-text= notification.Message
|
p.notification-text= notification.Message
|
||||||
.notification-date.utc-date(data-date=notification.Created)
|
.notification-date.utc-date(data-date=notification.Created)
|
||||||
|
@ -15,6 +15,11 @@
|
|||||||
position relative
|
position relative
|
||||||
opacity 0.25
|
opacity 0.25
|
||||||
|
|
||||||
|
.notification-user
|
||||||
|
text-align right
|
||||||
|
margin-bottom 0.5rem
|
||||||
|
font-size 0.9rem
|
||||||
|
|
||||||
.notification[data-seen=""]
|
.notification[data-seen=""]
|
||||||
opacity 1.0
|
opacity 1.0
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user