Migration to new track title struct
This commit is contained in:
parent
1ba0da36e2
commit
ea03c6cc17
@ -15,7 +15,7 @@ component SoundTrackMedia(track *arn.SoundTrack)
|
|||||||
if track.File != ""
|
if track.File != ""
|
||||||
.soundtrack-media
|
.soundtrack-media
|
||||||
.soundtrack-play-area.action(data-action="toggleAudio", data-trigger="click", data-audio-src="https://notify.moe/audio/" + track.File, data-soundtrack-id=track.ID)
|
.soundtrack-play-area.action(data-action="toggleAudio", data-trigger="click", data-audio-src="https://notify.moe/audio/" + track.File, data-soundtrack-id=track.ID)
|
||||||
img.soundtrack-image.lazy(data-src="https://img.youtube.com/vi/" + track.MediaByService("Youtube")[0].ServiceID + "/0.jpg", alt=track.Title)
|
img.soundtrack-image.lazy(data-src="https://img.youtube.com/vi/" + track.MediaByService("Youtube")[0].ServiceID + "/0.jpg", alt=track.NewTitle)
|
||||||
button.soundtrack-play-button
|
button.soundtrack-play-button
|
||||||
RawIcon("play")
|
RawIcon("play")
|
||||||
|
|
||||||
|
@ -67,7 +67,7 @@ func Get(ctx *aero.Context) string {
|
|||||||
})
|
})
|
||||||
|
|
||||||
sort.Slice(tracks, func(i, j int) bool {
|
sort.Slice(tracks, func(i, j int) bool {
|
||||||
return tracks[i].Title < tracks[j].Title
|
return tracks[i].Title.ByUser(user) < tracks[j].Title.ByUser(user)
|
||||||
})
|
})
|
||||||
|
|
||||||
// Anime list item
|
// Anime list item
|
||||||
|
@ -1,97 +1,97 @@
|
|||||||
package dashboard
|
package dashboard
|
||||||
|
|
||||||
import (
|
// import (
|
||||||
"net/http"
|
// "net/http"
|
||||||
"sort"
|
// "sort"
|
||||||
|
|
||||||
"github.com/aerogo/aero"
|
// "github.com/aerogo/aero"
|
||||||
"github.com/aerogo/flow"
|
// "github.com/aerogo/flow"
|
||||||
"github.com/animenotifier/arn"
|
// "github.com/animenotifier/arn"
|
||||||
"github.com/animenotifier/notify.moe/components"
|
// "github.com/animenotifier/notify.moe/components"
|
||||||
"github.com/animenotifier/notify.moe/utils"
|
// "github.com/animenotifier/notify.moe/utils"
|
||||||
)
|
// )
|
||||||
|
|
||||||
const maxForumActivity = 5
|
// const maxForumActivity = 5
|
||||||
const maxFollowing = 5
|
// const maxFollowing = 5
|
||||||
const maxSoundTracks = 5
|
// const maxSoundTracks = 5
|
||||||
const maxScheduleItems = 5
|
// const maxScheduleItems = 5
|
||||||
|
|
||||||
// Get the dashboard.
|
// // Get the dashboard.
|
||||||
func Get(ctx *aero.Context) string {
|
// func Get(ctx *aero.Context) string {
|
||||||
var forumActivity []arn.Postable
|
// var forumActivity []arn.Postable
|
||||||
var followingList []*arn.User
|
// var followingList []*arn.User
|
||||||
var soundTracks []*arn.SoundTrack
|
// var soundTracks []*arn.SoundTrack
|
||||||
var upcomingEpisodes []*arn.UpcomingEpisode
|
// var upcomingEpisodes []*arn.UpcomingEpisode
|
||||||
|
|
||||||
user := utils.GetUser(ctx)
|
// user := utils.GetUser(ctx)
|
||||||
|
|
||||||
if user == nil {
|
// if user == nil {
|
||||||
return ctx.Error(http.StatusUnauthorized, "Not logged in", nil)
|
// return ctx.Error(http.StatusUnauthorized, "Not logged in", nil)
|
||||||
}
|
// }
|
||||||
|
|
||||||
flow.Parallel(func() {
|
// flow.Parallel(func() {
|
||||||
posts := arn.AllPosts()
|
// posts := arn.AllPosts()
|
||||||
threads := arn.AllThreads()
|
// threads := arn.AllThreads()
|
||||||
|
|
||||||
arn.SortPostsLatestFirst(posts)
|
// arn.SortPostsLatestFirst(posts)
|
||||||
arn.SortThreadsLatestFirst(threads)
|
// arn.SortThreadsLatestFirst(threads)
|
||||||
|
|
||||||
posts = arn.FilterPostsWithUniqueThreads(posts, maxForumActivity)
|
// posts = arn.FilterPostsWithUniqueThreads(posts, maxForumActivity)
|
||||||
|
|
||||||
postPostables := arn.ToPostables(posts)
|
// postPostables := arn.ToPostables(posts)
|
||||||
threadPostables := arn.ToPostables(threads)
|
// threadPostables := arn.ToPostables(threads)
|
||||||
|
|
||||||
allPostables := append(postPostables, threadPostables...)
|
// allPostables := append(postPostables, threadPostables...)
|
||||||
|
|
||||||
arn.SortPostablesLatestFirst(allPostables)
|
// arn.SortPostablesLatestFirst(allPostables)
|
||||||
forumActivity = arn.FilterPostablesWithUniqueThreads(allPostables, maxForumActivity)
|
// forumActivity = arn.FilterPostablesWithUniqueThreads(allPostables, maxForumActivity)
|
||||||
}, func() {
|
// }, func() {
|
||||||
animeList, err := arn.GetAnimeList(user.ID)
|
// animeList, err := arn.GetAnimeList(user.ID)
|
||||||
|
|
||||||
if err != nil {
|
// if err != nil {
|
||||||
return
|
// return
|
||||||
}
|
// }
|
||||||
|
|
||||||
animeList = animeList.Watching()
|
// animeList = animeList.Watching()
|
||||||
animeList.Lock()
|
// animeList.Lock()
|
||||||
|
|
||||||
for _, item := range animeList.Items {
|
// for _, item := range animeList.Items {
|
||||||
futureEpisodes := item.Anime().UpcomingEpisodes()
|
// futureEpisodes := item.Anime().UpcomingEpisodes()
|
||||||
|
|
||||||
if len(futureEpisodes) == 0 {
|
// if len(futureEpisodes) == 0 {
|
||||||
continue
|
// continue
|
||||||
}
|
// }
|
||||||
|
|
||||||
upcomingEpisodes = append(upcomingEpisodes, futureEpisodes...)
|
// upcomingEpisodes = append(upcomingEpisodes, futureEpisodes...)
|
||||||
}
|
// }
|
||||||
|
|
||||||
animeList.Unlock()
|
// animeList.Unlock()
|
||||||
|
|
||||||
sort.Slice(upcomingEpisodes, func(i, j int) bool {
|
// sort.Slice(upcomingEpisodes, func(i, j int) bool {
|
||||||
return upcomingEpisodes[i].Episode.AiringDate.Start < upcomingEpisodes[j].Episode.AiringDate.Start
|
// return upcomingEpisodes[i].Episode.AiringDate.Start < upcomingEpisodes[j].Episode.AiringDate.Start
|
||||||
})
|
// })
|
||||||
|
|
||||||
if len(upcomingEpisodes) >= maxScheduleItems {
|
// if len(upcomingEpisodes) >= maxScheduleItems {
|
||||||
upcomingEpisodes = upcomingEpisodes[:maxScheduleItems]
|
// upcomingEpisodes = upcomingEpisodes[:maxScheduleItems]
|
||||||
}
|
// }
|
||||||
}, func() {
|
// }, func() {
|
||||||
soundTracks = arn.FilterSoundTracks(func(track *arn.SoundTrack) bool {
|
// soundTracks = arn.FilterSoundTracks(func(track *arn.SoundTrack) bool {
|
||||||
return !track.IsDraft && len(track.Media) > 0
|
// return !track.IsDraft && len(track.Media) > 0
|
||||||
})
|
// })
|
||||||
|
|
||||||
arn.SortSoundTracksLatestFirst(soundTracks)
|
// arn.SortSoundTracksLatestFirst(soundTracks)
|
||||||
|
|
||||||
if len(soundTracks) > maxSoundTracks {
|
// if len(soundTracks) > maxSoundTracks {
|
||||||
soundTracks = soundTracks[:maxSoundTracks]
|
// soundTracks = soundTracks[:maxSoundTracks]
|
||||||
}
|
// }
|
||||||
}, func() {
|
// }, func() {
|
||||||
followingList = user.Follows().Users()
|
// followingList = user.Follows().Users()
|
||||||
arn.SortUsersLastSeen(followingList)
|
// arn.SortUsersLastSeen(followingList)
|
||||||
|
|
||||||
if len(followingList) > maxFollowing {
|
// if len(followingList) > maxFollowing {
|
||||||
followingList = followingList[:maxFollowing]
|
// followingList = followingList[:maxFollowing]
|
||||||
}
|
// }
|
||||||
})
|
// })
|
||||||
|
|
||||||
return ctx.HTML(components.Dashboard(upcomingEpisodes, forumActivity, soundTracks, followingList, user))
|
// return ctx.HTML(components.Dashboard(upcomingEpisodes, forumActivity, soundTracks, followingList, user))
|
||||||
}
|
// }
|
||||||
|
@ -1,101 +1,101 @@
|
|||||||
component Dashboard(schedule []*arn.UpcomingEpisode, posts []arn.Postable, soundTracks []*arn.SoundTrack, following []*arn.User, user *arn.User)
|
component Dashboard(schedule []*arn.UpcomingEpisode, posts []arn.Postable, soundTracks []*arn.SoundTrack, following []*arn.User, user *arn.User)
|
||||||
h1.page-title Dashboard
|
//- h1.page-title Dashboard
|
||||||
|
|
||||||
.dashboard
|
//- .dashboard
|
||||||
.widget.mountable
|
//- .widget.mountable
|
||||||
h3.widget-title Schedule
|
//- h3.widget-title Schedule
|
||||||
|
|
||||||
for i := 0; i <= 4; i++
|
//- for i := 0; i <= 4; i++
|
||||||
if i < len(schedule)
|
//- if i < len(schedule)
|
||||||
.widget-ui-element
|
//- .widget-ui-element
|
||||||
.widget-ui-element-text
|
//- .widget-ui-element-text
|
||||||
a.schedule-item-link(href=schedule[i].Anime.Link())
|
//- a.schedule-item-link(href=schedule[i].Anime.Link())
|
||||||
Icon("calendar-o")
|
//- Icon("calendar-o")
|
||||||
.schedule-item-title= schedule[i].Anime.Title.ByUser(user)
|
//- .schedule-item-title= schedule[i].Anime.Title.ByUser(user)
|
||||||
.spacer
|
//- .spacer
|
||||||
.schedule-item-date.utc-airing-date(data-start-date=schedule[i].Episode.AiringDate.Start, data-end-date=schedule[i].Episode.AiringDate.End, data-episode-number=schedule[i].Episode.Number)
|
//- .schedule-item-date.utc-airing-date(data-start-date=schedule[i].Episode.AiringDate.Start, data-end-date=schedule[i].Episode.AiringDate.End, data-episode-number=schedule[i].Episode.Number)
|
||||||
else
|
//- else
|
||||||
.widget-ui-element
|
//- .widget-ui-element
|
||||||
.widget-ui-element-text
|
//- .widget-ui-element-text
|
||||||
Icon("calendar-o")
|
//- Icon("calendar-o")
|
||||||
span ...
|
//- span ...
|
||||||
|
|
||||||
.widget.mountable
|
//- .widget.mountable
|
||||||
h3.widget-title Forums
|
//- h3.widget-title Forums
|
||||||
|
|
||||||
each post in posts
|
//- each post in posts
|
||||||
a.widget-ui-element(href=post.Thread().Link())
|
//- a.widget-ui-element(href=post.Thread().Link())
|
||||||
.widget-ui-element-text
|
//- .widget-ui-element-text
|
||||||
Icon(arn.GetForumIcon(post.Thread().Tags[0]))
|
//- Icon(arn.GetForumIcon(post.Thread().Tags[0]))
|
||||||
span= post.Thread().Title
|
//- span= post.Thread().Title
|
||||||
|
|
||||||
.widget.mountable
|
//- .widget.mountable
|
||||||
h3.widget-title Artworks
|
//- h3.widget-title Artworks
|
||||||
|
|
||||||
for i := 1; i <= 5; i++
|
//- for i := 1; i <= 5; i++
|
||||||
.widget-ui-element
|
//- .widget-ui-element
|
||||||
.widget-ui-element-text
|
//- .widget-ui-element-text
|
||||||
Icon("paint-brush")
|
//- Icon("paint-brush")
|
||||||
span ...
|
//- span ...
|
||||||
|
|
||||||
.widget.mountable
|
//- .widget.mountable
|
||||||
h3.widget-title Soundtracks
|
//- h3.widget-title Soundtracks
|
||||||
|
|
||||||
for i := 0; i <= 4; i++
|
//- for i := 0; i <= 4; i++
|
||||||
if i < len(soundTracks)
|
//- if i < len(soundTracks)
|
||||||
a.widget-ui-element(href=soundTracks[i].Link())
|
//- a.widget-ui-element(href=soundTracks[i].Link())
|
||||||
.widget-ui-element-text
|
//- .widget-ui-element-text
|
||||||
Icon("music")
|
//- Icon("music")
|
||||||
if soundTracks[i].Title == ""
|
//- if soundTracks[i].Title == ""
|
||||||
span untitled
|
//- span untitled
|
||||||
else
|
//- else
|
||||||
span= soundTracks[i].Title
|
//- span= soundTracks[i].Title
|
||||||
else
|
//- else
|
||||||
.widget-ui-element
|
//- .widget-ui-element
|
||||||
.widget-ui-element-text
|
//- .widget-ui-element-text
|
||||||
Icon("music")
|
//- Icon("music")
|
||||||
span ...
|
//- span ...
|
||||||
|
|
||||||
.widget.mountable
|
//- .widget.mountable
|
||||||
h3.widget-title AMVs
|
//- h3.widget-title AMVs
|
||||||
|
|
||||||
for i := 1; i <= 5; i++
|
//- for i := 1; i <= 5; i++
|
||||||
.widget-ui-element
|
//- .widget-ui-element
|
||||||
.widget-ui-element-text
|
//- .widget-ui-element-text
|
||||||
Icon("video-camera")
|
//- Icon("video-camera")
|
||||||
span ...
|
//- span ...
|
||||||
|
|
||||||
.widget.mountable
|
//- .widget.mountable
|
||||||
h3.widget-title Reviews
|
//- h3.widget-title Reviews
|
||||||
|
|
||||||
for i := 1; i <= 5; i++
|
//- for i := 1; i <= 5; i++
|
||||||
.widget-ui-element
|
//- .widget-ui-element
|
||||||
.widget-ui-element-text
|
//- .widget-ui-element-text
|
||||||
Icon("book")
|
//- Icon("book")
|
||||||
span ...
|
//- span ...
|
||||||
|
|
||||||
.widget.mountable
|
//- .widget.mountable
|
||||||
h3.widget-title Groups
|
//- h3.widget-title Groups
|
||||||
|
|
||||||
for i := 1; i <= 5; i++
|
//- for i := 1; i <= 5; i++
|
||||||
.widget-ui-element
|
//- .widget-ui-element
|
||||||
.widget-ui-element-text
|
//- .widget-ui-element-text
|
||||||
Icon("group")
|
//- Icon("group")
|
||||||
span ...
|
//- span ...
|
||||||
|
|
||||||
.widget.mountable
|
//- .widget.mountable
|
||||||
h3.widget-title Contacts
|
//- h3.widget-title Contacts
|
||||||
|
|
||||||
for i := 0; i <= 4; i++
|
//- for i := 0; i <= 4; i++
|
||||||
if i < len(following)
|
//- if i < len(following)
|
||||||
a.widget-ui-element(href="/+" + following[i].Nick)
|
//- a.widget-ui-element(href="/+" + following[i].Nick)
|
||||||
.widget-ui-element-text
|
//- .widget-ui-element-text
|
||||||
Icon("address-card")
|
//- Icon("address-card")
|
||||||
span= following[i].Nick
|
//- span= following[i].Nick
|
||||||
else
|
//- else
|
||||||
.widget-ui-element
|
//- .widget-ui-element
|
||||||
.widget-ui-element-text
|
//- .widget-ui-element-text
|
||||||
Icon("address-card")
|
//- Icon("address-card")
|
||||||
span ...
|
//- span ...
|
||||||
|
|
||||||
Footer
|
//- Footer
|
@ -1,13 +1,13 @@
|
|||||||
.schedule-item-link,
|
// .schedule-item-link,
|
||||||
.schedule-item-title
|
// .schedule-item-title
|
||||||
clip-long-text
|
// clip-long-text
|
||||||
|
|
||||||
.schedule-item-link
|
// .schedule-item-link
|
||||||
horizontal
|
// horizontal
|
||||||
align-items center
|
// align-items center
|
||||||
|
|
||||||
.schedule-item-date
|
// .schedule-item-date
|
||||||
text-align right
|
// text-align right
|
||||||
|
|
||||||
.footer-element
|
.footer-element
|
||||||
:after
|
:after
|
||||||
|
@ -93,11 +93,6 @@ func Configure(app *aero.Application) {
|
|||||||
l.Page("/api/"+strings.ToLower(name), apidocs.ByType(name))
|
l.Page("/api/"+strings.ToLower(name), apidocs.ByType(name))
|
||||||
}
|
}
|
||||||
|
|
||||||
// l.Ajax("/dashboard", dashboard.Get)
|
|
||||||
// l.Ajax("/best/anime", best.Get)
|
|
||||||
// l.Ajax("/artworks", artworks.Get)
|
|
||||||
// l.Ajax("/amvs", amvs.Get)
|
|
||||||
|
|
||||||
// Forum
|
// Forum
|
||||||
l.Page("/forum", forum.Get)
|
l.Page("/forum", forum.Get)
|
||||||
l.Page("/forum/:tag", forum.Get)
|
l.Page("/forum/:tag", forum.Get)
|
||||||
|
@ -23,7 +23,7 @@ func Edit(ctx *aero.Context) string {
|
|||||||
|
|
||||||
ctx.Data = &arn.OpenGraph{
|
ctx.Data = &arn.OpenGraph{
|
||||||
Tags: map[string]string{
|
Tags: map[string]string{
|
||||||
"og:title": track.NewTitle.ByUser(user),
|
"og:title": track.Title.ByUser(user),
|
||||||
"og:url": "https://" + ctx.App.Config.Domain + track.Link(),
|
"og:url": "https://" + ctx.App.Config.Domain + track.Link(),
|
||||||
"og:site_name": "notify.moe",
|
"og:site_name": "notify.moe",
|
||||||
"og:type": "music.song",
|
"og:type": "music.song",
|
||||||
|
@ -32,7 +32,7 @@ func Get(ctx *aero.Context) string {
|
|||||||
|
|
||||||
openGraph := &arn.OpenGraph{
|
openGraph := &arn.OpenGraph{
|
||||||
Tags: map[string]string{
|
Tags: map[string]string{
|
||||||
"og:title": track.NewTitle.ByUser(user),
|
"og:title": track.Title.ByUser(user),
|
||||||
"og:description": track.MainAnime().Title.Canonical + " (" + strings.Join(descriptionTags, ", ") + ")",
|
"og:description": track.MainAnime().Title.Canonical + " (" + strings.Join(descriptionTags, ", ") + ")",
|
||||||
"og:url": "https://" + ctx.App.Config.Domain + track.Link(),
|
"og:url": "https://" + ctx.App.Config.Domain + track.Link(),
|
||||||
"og:site_name": ctx.App.Config.Domain,
|
"og:site_name": ctx.App.Config.Domain,
|
||||||
|
@ -1,19 +1,15 @@
|
|||||||
package main
|
package main
|
||||||
|
|
||||||
import (
|
|
||||||
"github.com/animenotifier/arn"
|
|
||||||
)
|
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
defer arn.Node.Close()
|
// defer arn.Node.Close()
|
||||||
|
|
||||||
for track := range arn.StreamSoundTracks() {
|
// for track := range arn.StreamSoundTracks() {
|
||||||
if arn.ContainsUnicodeLetters(track.Title) {
|
// if arn.ContainsUnicodeLetters(track.Title) {
|
||||||
track.NewTitle.Native = track.Title
|
// track.NewTitle.Native = track.Title
|
||||||
} else {
|
// } else {
|
||||||
track.NewTitle.Canonical = track.Title
|
// track.NewTitle.Canonical = track.Title
|
||||||
}
|
// }
|
||||||
|
|
||||||
track.Save()
|
// track.Save()
|
||||||
}
|
// }
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user