Added notifications overview
This commit is contained in:
parent
d5b01763bb
commit
c170bef1ea
@ -42,9 +42,9 @@ import (
|
|||||||
"github.com/animenotifier/notify.moe/pages/popular"
|
"github.com/animenotifier/notify.moe/pages/popular"
|
||||||
"github.com/animenotifier/notify.moe/pages/posts"
|
"github.com/animenotifier/notify.moe/pages/posts"
|
||||||
"github.com/animenotifier/notify.moe/pages/profile"
|
"github.com/animenotifier/notify.moe/pages/profile"
|
||||||
"github.com/animenotifier/notify.moe/pages/recommended"
|
|
||||||
"github.com/animenotifier/notify.moe/pages/quote"
|
"github.com/animenotifier/notify.moe/pages/quote"
|
||||||
"github.com/animenotifier/notify.moe/pages/quotes"
|
"github.com/animenotifier/notify.moe/pages/quotes"
|
||||||
|
"github.com/animenotifier/notify.moe/pages/recommended"
|
||||||
"github.com/animenotifier/notify.moe/pages/search"
|
"github.com/animenotifier/notify.moe/pages/search"
|
||||||
"github.com/animenotifier/notify.moe/pages/settings"
|
"github.com/animenotifier/notify.moe/pages/settings"
|
||||||
"github.com/animenotifier/notify.moe/pages/shop"
|
"github.com/animenotifier/notify.moe/pages/shop"
|
||||||
@ -143,6 +143,9 @@ func Configure(app *aero.Application) {
|
|||||||
l.Page("/group/:id/edit", group.Edit)
|
l.Page("/group/:id/edit", group.Edit)
|
||||||
l.Page("/group/:id/forum", group.Forum)
|
l.Page("/group/:id/forum", group.Forum)
|
||||||
|
|
||||||
|
// Notifications
|
||||||
|
l.Page("/notifications", notifications.All)
|
||||||
|
|
||||||
// User profiles
|
// User profiles
|
||||||
l.Page("/user", user.Get)
|
l.Page("/user", user.Get)
|
||||||
l.Page("/user/:nick", profile.Get)
|
l.Page("/user/:nick", profile.Get)
|
||||||
|
@ -2,13 +2,33 @@ package notifications
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"net/http"
|
"net/http"
|
||||||
|
"sort"
|
||||||
|
|
||||||
"github.com/aerogo/aero"
|
"github.com/aerogo/aero"
|
||||||
"github.com/animenotifier/arn"
|
"github.com/animenotifier/arn"
|
||||||
|
"github.com/animenotifier/notify.moe/components"
|
||||||
"github.com/animenotifier/notify.moe/utils"
|
"github.com/animenotifier/notify.moe/utils"
|
||||||
)
|
)
|
||||||
|
|
||||||
// Test ...
|
// All shows all notifications sent so far.
|
||||||
|
func All(ctx *aero.Context) string {
|
||||||
|
user := utils.GetUser(ctx)
|
||||||
|
|
||||||
|
if user == nil {
|
||||||
|
return ctx.Error(http.StatusBadRequest, "Not logged in", nil)
|
||||||
|
}
|
||||||
|
|
||||||
|
notifications := user.Notifications().Notifications()
|
||||||
|
|
||||||
|
// Sort by date
|
||||||
|
sort.Slice(notifications, func(i, j int) bool {
|
||||||
|
return notifications[i].Created > notifications[j].Created
|
||||||
|
})
|
||||||
|
|
||||||
|
return ctx.HTML(components.Notifications(notifications, user))
|
||||||
|
}
|
||||||
|
|
||||||
|
// Test sends a test notification to the logged in user.
|
||||||
func Test(ctx *aero.Context) string {
|
func Test(ctx *aero.Context) string {
|
||||||
user := utils.GetUser(ctx)
|
user := utils.GetUser(ctx)
|
||||||
|
|
||||||
|
16
pages/notifications/notifications.pixy
Normal file
16
pages/notifications/notifications.pixy
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
component Notifications(notifications []*arn.Notification, user *arn.User)
|
||||||
|
h1 Notifications
|
||||||
|
|
||||||
|
.notifications
|
||||||
|
each notification in notifications
|
||||||
|
Notification(notification)
|
||||||
|
|
||||||
|
component Notification(notification *arn.Notification)
|
||||||
|
.notification
|
||||||
|
.notification-icon
|
||||||
|
img.lazy(data-src=notification.Icon, alt=notification.Title)
|
||||||
|
|
||||||
|
.notification-info
|
||||||
|
h3= notification.Title
|
||||||
|
p= notification.Message
|
||||||
|
.notification-date.utc-date(data-date=notification.Created)
|
22
pages/notifications/notifications.scarlet
Normal file
22
pages/notifications/notifications.scarlet
Normal file
@ -0,0 +1,22 @@
|
|||||||
|
.notifications
|
||||||
|
vertical
|
||||||
|
|
||||||
|
.notification
|
||||||
|
horizontal
|
||||||
|
ui-element
|
||||||
|
padding 1rem
|
||||||
|
margin-bottom 0.5rem
|
||||||
|
|
||||||
|
.notification-icon
|
||||||
|
margin-right 1rem
|
||||||
|
|
||||||
|
img
|
||||||
|
width 64px
|
||||||
|
height 64px
|
||||||
|
|
||||||
|
.notification-info
|
||||||
|
vertical
|
||||||
|
|
||||||
|
.notification-date
|
||||||
|
opacity 0.5
|
||||||
|
font-size 0.9em
|
Loading…
Reference in New Issue
Block a user