Implemented schedule
This commit is contained in:
parent
1911d9954b
commit
a63da27429
pages/dashboard
@ -1,6 +1,8 @@
|
|||||||
package dashboard
|
package dashboard
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"time"
|
||||||
|
|
||||||
"github.com/aerogo/aero"
|
"github.com/aerogo/aero"
|
||||||
"github.com/aerogo/flow"
|
"github.com/aerogo/flow"
|
||||||
"github.com/animenotifier/arn"
|
"github.com/animenotifier/arn"
|
||||||
@ -12,6 +14,7 @@ import (
|
|||||||
const maxPosts = 5
|
const maxPosts = 5
|
||||||
const maxFollowing = 5
|
const maxFollowing = 5
|
||||||
const maxSoundTracks = 5
|
const maxSoundTracks = 5
|
||||||
|
const maxScheduleItems = 5
|
||||||
|
|
||||||
// Get the dashboard or the frontpage when logged out.
|
// Get the dashboard or the frontpage when logged out.
|
||||||
func Get(ctx *aero.Context) string {
|
func Get(ctx *aero.Context) string {
|
||||||
@ -30,6 +33,7 @@ func dashboard(ctx *aero.Context) string {
|
|||||||
var userList interface{}
|
var userList interface{}
|
||||||
var followingList []*arn.User
|
var followingList []*arn.User
|
||||||
var soundTracks []*arn.SoundTrack
|
var soundTracks []*arn.SoundTrack
|
||||||
|
var upcomingEpisodes []*arn.UpcomingEpisode
|
||||||
|
|
||||||
user := utils.GetUser(ctx)
|
user := utils.GetUser(ctx)
|
||||||
|
|
||||||
@ -43,6 +47,43 @@ func dashboard(ctx *aero.Context) string {
|
|||||||
|
|
||||||
arn.SortPostsLatestFirst(posts)
|
arn.SortPostsLatestFirst(posts)
|
||||||
posts = arn.FilterPostsWithUniqueThreads(posts, maxPosts)
|
posts = arn.FilterPostsWithUniqueThreads(posts, maxPosts)
|
||||||
|
}, func() {
|
||||||
|
animeList, err := arn.GetAnimeList(user)
|
||||||
|
|
||||||
|
if err != nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
var keys []string
|
||||||
|
|
||||||
|
for _, item := range animeList.Items {
|
||||||
|
keys = append(keys, item.AnimeID)
|
||||||
|
}
|
||||||
|
|
||||||
|
objects, getErr := arn.DB.GetMany("Anime", keys)
|
||||||
|
|
||||||
|
if getErr != nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
allAnimeInList := objects.([]*arn.Anime)
|
||||||
|
now := time.Now().UTC().Format(time.RFC3339)
|
||||||
|
|
||||||
|
for _, anime := range allAnimeInList {
|
||||||
|
if len(upcomingEpisodes) >= maxScheduleItems {
|
||||||
|
break
|
||||||
|
}
|
||||||
|
|
||||||
|
for _, episode := range anime.Episodes {
|
||||||
|
if episode.AiringDate.Start > now {
|
||||||
|
upcomingEpisodes = append(upcomingEpisodes, &arn.UpcomingEpisode{
|
||||||
|
Anime: anime,
|
||||||
|
Episode: episode,
|
||||||
|
})
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}, func() {
|
}, func() {
|
||||||
var err error
|
var err error
|
||||||
soundTracks, err = arn.AllSoundTracks()
|
soundTracks, err = arn.AllSoundTracks()
|
||||||
@ -72,5 +113,5 @@ func dashboard(ctx *aero.Context) string {
|
|||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
return ctx.HTML(components.Dashboard(posts, soundTracks, followingList))
|
return ctx.HTML(components.Dashboard(upcomingEpisodes, posts, soundTracks, followingList))
|
||||||
}
|
}
|
||||||
|
@ -1,11 +1,18 @@
|
|||||||
component Dashboard(posts []*arn.Post, soundTracks []*arn.SoundTrack, following []*arn.User)
|
component Dashboard(schedule []*arn.UpcomingEpisode, posts []*arn.Post, soundTracks []*arn.SoundTrack, following []*arn.User)
|
||||||
h2.page-title Dash
|
h2.page-title Dash
|
||||||
|
|
||||||
.widgets
|
.widgets
|
||||||
.widget.mountable
|
.widget.mountable
|
||||||
h3.widget-title Schedule
|
h3.widget-title Schedule
|
||||||
|
|
||||||
for i := 1; i <= 5; i++
|
for i := 0; i <= 4; i++
|
||||||
|
if i < len(schedule)
|
||||||
|
a.widget-element.ajax(href=schedule[i].Anime.Link())
|
||||||
|
.widget-element-text
|
||||||
|
Icon("calendar-o")
|
||||||
|
.schedule-item-title= schedule[i].Anime.Title.Canonical
|
||||||
|
.schedule-item-episode= "# " + toString(schedule[i].Episode.Number)
|
||||||
|
else
|
||||||
.widget-element
|
.widget-element
|
||||||
.widget-element-text
|
.widget-element-text
|
||||||
Icon("calendar-o")
|
Icon("calendar-o")
|
||||||
|
5
pages/dashboard/dashboard.scarlet
Normal file
5
pages/dashboard/dashboard.scarlet
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
.schedule-item-title
|
||||||
|
flex 1
|
||||||
|
|
||||||
|
.schedule-item-episode
|
||||||
|
text-align right
|
Loading…
Reference in New Issue
Block a user